babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363
  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/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. export const Epsilon = 0.001;
  272. /**
  273. * Class used to hold a RBG color
  274. */
  275. export class Color3 {
  276. /**
  277. * Defines the red component (between 0 and 1, default is 0)
  278. */
  279. r: number;
  280. /**
  281. * Defines the green component (between 0 and 1, default is 0)
  282. */
  283. g: number;
  284. /**
  285. * Defines the blue component (between 0 and 1, default is 0)
  286. */
  287. b: number;
  288. /**
  289. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  290. * @param r defines the red component (between 0 and 1, default is 0)
  291. * @param g defines the green component (between 0 and 1, default is 0)
  292. * @param b defines the blue component (between 0 and 1, default is 0)
  293. */
  294. constructor(
  295. /**
  296. * Defines the red component (between 0 and 1, default is 0)
  297. */
  298. r?: number,
  299. /**
  300. * Defines the green component (between 0 and 1, default is 0)
  301. */
  302. g?: number,
  303. /**
  304. * Defines the blue component (between 0 and 1, default is 0)
  305. */
  306. b?: number);
  307. /**
  308. * Creates a string with the Color3 current values
  309. * @returns the string representation of the Color3 object
  310. */
  311. toString(): string;
  312. /**
  313. * Returns the string "Color3"
  314. * @returns "Color3"
  315. */
  316. getClassName(): string;
  317. /**
  318. * Compute the Color3 hash code
  319. * @returns an unique number that can be used to hash Color3 objects
  320. */
  321. getHashCode(): number;
  322. /**
  323. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  324. * @param array defines the array where to store the r,g,b components
  325. * @param index defines an optional index in the target array to define where to start storing values
  326. * @returns the current Color3 object
  327. */
  328. toArray(array: FloatArray, index?: number): Color3;
  329. /**
  330. * Returns a new Color4 object from the current Color3 and the given alpha
  331. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  332. * @returns a new Color4 object
  333. */
  334. toColor4(alpha?: number): Color4;
  335. /**
  336. * Returns a new array populated with 3 numeric elements : red, green and blue values
  337. * @returns the new array
  338. */
  339. asArray(): number[];
  340. /**
  341. * Returns the luminance value
  342. * @returns a float value
  343. */
  344. toLuminance(): number;
  345. /**
  346. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  347. * @param otherColor defines the second operand
  348. * @returns the new Color3 object
  349. */
  350. multiply(otherColor: DeepImmutable<Color3>): Color3;
  351. /**
  352. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  353. * @param otherColor defines the second operand
  354. * @param result defines the Color3 object where to store the result
  355. * @returns the current Color3
  356. */
  357. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  358. /**
  359. * Determines equality between Color3 objects
  360. * @param otherColor defines the second operand
  361. * @returns true if the rgb values are equal to the given ones
  362. */
  363. equals(otherColor: DeepImmutable<Color3>): boolean;
  364. /**
  365. * Determines equality between the current Color3 object and a set of r,b,g values
  366. * @param r defines the red component to check
  367. * @param g defines the green component to check
  368. * @param b defines the blue component to check
  369. * @returns true if the rgb values are equal to the given ones
  370. */
  371. equalsFloats(r: number, g: number, b: number): boolean;
  372. /**
  373. * Multiplies in place each rgb value by scale
  374. * @param scale defines the scaling factor
  375. * @returns the updated Color3
  376. */
  377. scale(scale: number): Color3;
  378. /**
  379. * Multiplies the rgb values by scale and stores the result into "result"
  380. * @param scale defines the scaling factor
  381. * @param result defines the Color3 object where to store the result
  382. * @returns the unmodified current Color3
  383. */
  384. scaleToRef(scale: number, result: Color3): Color3;
  385. /**
  386. * Scale the current Color3 values by a factor and add the result to a given Color3
  387. * @param scale defines the scale factor
  388. * @param result defines color to store the result into
  389. * @returns the unmodified current Color3
  390. */
  391. scaleAndAddToRef(scale: number, result: Color3): Color3;
  392. /**
  393. * Clamps the rgb values by the min and max values and stores the result into "result"
  394. * @param min defines minimum clamping value (default is 0)
  395. * @param max defines maximum clamping value (default is 1)
  396. * @param result defines color to store the result into
  397. * @returns the original Color3
  398. */
  399. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  400. /**
  401. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  402. * @param otherColor defines the second operand
  403. * @returns the new Color3
  404. */
  405. add(otherColor: DeepImmutable<Color3>): Color3;
  406. /**
  407. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  408. * @param otherColor defines the second operand
  409. * @param result defines Color3 object to store the result into
  410. * @returns the unmodified current Color3
  411. */
  412. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  413. /**
  414. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  415. * @param otherColor defines the second operand
  416. * @returns the new Color3
  417. */
  418. subtract(otherColor: DeepImmutable<Color3>): Color3;
  419. /**
  420. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  421. * @param otherColor defines the second operand
  422. * @param result defines Color3 object to store the result into
  423. * @returns the unmodified current Color3
  424. */
  425. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  426. /**
  427. * Copy the current object
  428. * @returns a new Color3 copied the current one
  429. */
  430. clone(): Color3;
  431. /**
  432. * Copies the rgb values from the source in the current Color3
  433. * @param source defines the source Color3 object
  434. * @returns the updated Color3 object
  435. */
  436. copyFrom(source: DeepImmutable<Color3>): Color3;
  437. /**
  438. * Updates the Color3 rgb values from the given floats
  439. * @param r defines the red component to read from
  440. * @param g defines the green component to read from
  441. * @param b defines the blue component to read from
  442. * @returns the current Color3 object
  443. */
  444. copyFromFloats(r: number, g: number, b: number): Color3;
  445. /**
  446. * Updates the Color3 rgb values from the given floats
  447. * @param r defines the red component to read from
  448. * @param g defines the green component to read from
  449. * @param b defines the blue component to read from
  450. * @returns the current Color3 object
  451. */
  452. set(r: number, g: number, b: number): Color3;
  453. /**
  454. * Compute the Color3 hexadecimal code as a string
  455. * @returns a string containing the hexadecimal representation of the Color3 object
  456. */
  457. toHexString(): string;
  458. /**
  459. * Computes a new Color3 converted from the current one to linear space
  460. * @returns a new Color3 object
  461. */
  462. toLinearSpace(): Color3;
  463. /**
  464. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  465. * @param convertedColor defines the Color3 object where to store the linear space version
  466. * @returns the unmodified Color3
  467. */
  468. toLinearSpaceToRef(convertedColor: Color3): Color3;
  469. /**
  470. * Computes a new Color3 converted from the current one to gamma space
  471. * @returns a new Color3 object
  472. */
  473. toGammaSpace(): Color3;
  474. /**
  475. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the gamma space version
  477. * @returns the unmodified Color3
  478. */
  479. toGammaSpaceToRef(convertedColor: Color3): Color3;
  480. private static _BlackReadOnly;
  481. /**
  482. * Creates a new Color3 from the string containing valid hexadecimal values
  483. * @param hex defines a string containing valid hexadecimal values
  484. * @returns a new Color3 object
  485. */
  486. static FromHexString(hex: string): Color3;
  487. /**
  488. * Creates a new Vector3 from the starting index of the given array
  489. * @param array defines the source array
  490. * @param offset defines an offset in the source array
  491. * @returns a new Color3 object
  492. */
  493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  494. /**
  495. * Creates a new Color3 from integer values (< 256)
  496. * @param r defines the red component to read from (value between 0 and 255)
  497. * @param g defines the green component to read from (value between 0 and 255)
  498. * @param b defines the blue component to read from (value between 0 and 255)
  499. * @returns a new Color3 object
  500. */
  501. static FromInts(r: number, g: number, b: number): Color3;
  502. /**
  503. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  504. * @param start defines the start Color3 value
  505. * @param end defines the end Color3 value
  506. * @param amount defines the gradient value between start and end
  507. * @returns a new Color3 object
  508. */
  509. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  510. /**
  511. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  512. * @param left defines the start value
  513. * @param right defines the end value
  514. * @param amount defines the gradient factor
  515. * @param result defines the Color3 object where to store the result
  516. */
  517. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  518. /**
  519. * Returns a Color3 value containing a red color
  520. * @returns a new Color3 object
  521. */
  522. static Red(): Color3;
  523. /**
  524. * Returns a Color3 value containing a green color
  525. * @returns a new Color3 object
  526. */
  527. static Green(): Color3;
  528. /**
  529. * Returns a Color3 value containing a blue color
  530. * @returns a new Color3 object
  531. */
  532. static Blue(): Color3;
  533. /**
  534. * Returns a Color3 value containing a black color
  535. * @returns a new Color3 object
  536. */
  537. static Black(): Color3;
  538. /**
  539. * Gets a Color3 value containing a black color that must not be updated
  540. */
  541. static readonly BlackReadOnly: DeepImmutable<Color3>;
  542. /**
  543. * Returns a Color3 value containing a white color
  544. * @returns a new Color3 object
  545. */
  546. static White(): Color3;
  547. /**
  548. * Returns a Color3 value containing a purple color
  549. * @returns a new Color3 object
  550. */
  551. static Purple(): Color3;
  552. /**
  553. * Returns a Color3 value containing a magenta color
  554. * @returns a new Color3 object
  555. */
  556. static Magenta(): Color3;
  557. /**
  558. * Returns a Color3 value containing a yellow color
  559. * @returns a new Color3 object
  560. */
  561. static Yellow(): Color3;
  562. /**
  563. * Returns a Color3 value containing a gray color
  564. * @returns a new Color3 object
  565. */
  566. static Gray(): Color3;
  567. /**
  568. * Returns a Color3 value containing a teal color
  569. * @returns a new Color3 object
  570. */
  571. static Teal(): Color3;
  572. /**
  573. * Returns a Color3 value containing a random color
  574. * @returns a new Color3 object
  575. */
  576. static Random(): Color3;
  577. }
  578. /**
  579. * Class used to hold a RBGA color
  580. */
  581. export class Color4 {
  582. /**
  583. * Defines the red component (between 0 and 1, default is 0)
  584. */
  585. r: number;
  586. /**
  587. * Defines the green component (between 0 and 1, default is 0)
  588. */
  589. g: number;
  590. /**
  591. * Defines the blue component (between 0 and 1, default is 0)
  592. */
  593. b: number;
  594. /**
  595. * Defines the alpha component (between 0 and 1, default is 1)
  596. */
  597. a: number;
  598. /**
  599. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  600. * @param r defines the red component (between 0 and 1, default is 0)
  601. * @param g defines the green component (between 0 and 1, default is 0)
  602. * @param b defines the blue component (between 0 and 1, default is 0)
  603. * @param a defines the alpha component (between 0 and 1, default is 1)
  604. */
  605. constructor(
  606. /**
  607. * Defines the red component (between 0 and 1, default is 0)
  608. */
  609. r?: number,
  610. /**
  611. * Defines the green component (between 0 and 1, default is 0)
  612. */
  613. g?: number,
  614. /**
  615. * Defines the blue component (between 0 and 1, default is 0)
  616. */
  617. b?: number,
  618. /**
  619. * Defines the alpha component (between 0 and 1, default is 1)
  620. */
  621. a?: number);
  622. /**
  623. * Adds in place the given Color4 values to the current Color4 object
  624. * @param right defines the second operand
  625. * @returns the current updated Color4 object
  626. */
  627. addInPlace(right: DeepImmutable<Color4>): Color4;
  628. /**
  629. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  630. * @returns the new array
  631. */
  632. asArray(): number[];
  633. /**
  634. * Stores from the starting index in the given array the Color4 successive values
  635. * @param array defines the array where to store the r,g,b components
  636. * @param index defines an optional index in the target array to define where to start storing values
  637. * @returns the current Color4 object
  638. */
  639. toArray(array: number[], index?: number): Color4;
  640. /**
  641. * Determines equality between Color4 objects
  642. * @param otherColor defines the second operand
  643. * @returns true if the rgba values are equal to the given ones
  644. */
  645. equals(otherColor: DeepImmutable<Color4>): boolean;
  646. /**
  647. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  648. * @param right defines the second operand
  649. * @returns a new Color4 object
  650. */
  651. add(right: DeepImmutable<Color4>): Color4;
  652. /**
  653. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  654. * @param right defines the second operand
  655. * @returns a new Color4 object
  656. */
  657. subtract(right: DeepImmutable<Color4>): Color4;
  658. /**
  659. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  660. * @param right defines the second operand
  661. * @param result defines the Color4 object where to store the result
  662. * @returns the current Color4 object
  663. */
  664. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  665. /**
  666. * Creates a new Color4 with the current Color4 values multiplied by scale
  667. * @param scale defines the scaling factor to apply
  668. * @returns a new Color4 object
  669. */
  670. scale(scale: number): Color4;
  671. /**
  672. * Multiplies the current Color4 values by scale and stores the result in "result"
  673. * @param scale defines the scaling factor to apply
  674. * @param result defines the Color4 object where to store the result
  675. * @returns the current unmodified Color4
  676. */
  677. scaleToRef(scale: number, result: Color4): Color4;
  678. /**
  679. * Scale the current Color4 values by a factor and add the result to a given Color4
  680. * @param scale defines the scale factor
  681. * @param result defines the Color4 object where to store the result
  682. * @returns the unmodified current Color4
  683. */
  684. scaleAndAddToRef(scale: number, result: Color4): Color4;
  685. /**
  686. * Clamps the rgb values by the min and max values and stores the result into "result"
  687. * @param min defines minimum clamping value (default is 0)
  688. * @param max defines maximum clamping value (default is 1)
  689. * @param result defines color to store the result into.
  690. * @returns the cuurent Color4
  691. */
  692. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  693. /**
  694. * Multipy an Color4 value by another and return a new Color4 object
  695. * @param color defines the Color4 value to multiply by
  696. * @returns a new Color4 object
  697. */
  698. multiply(color: Color4): Color4;
  699. /**
  700. * Multipy a Color4 value by another and push the result in a reference value
  701. * @param color defines the Color4 value to multiply by
  702. * @param result defines the Color4 to fill the result in
  703. * @returns the result Color4
  704. */
  705. multiplyToRef(color: Color4, result: Color4): Color4;
  706. /**
  707. * Creates a string with the Color4 current values
  708. * @returns the string representation of the Color4 object
  709. */
  710. toString(): string;
  711. /**
  712. * Returns the string "Color4"
  713. * @returns "Color4"
  714. */
  715. getClassName(): string;
  716. /**
  717. * Compute the Color4 hash code
  718. * @returns an unique number that can be used to hash Color4 objects
  719. */
  720. getHashCode(): number;
  721. /**
  722. * Creates a new Color4 copied from the current one
  723. * @returns a new Color4 object
  724. */
  725. clone(): Color4;
  726. /**
  727. * Copies the given Color4 values into the current one
  728. * @param source defines the source Color4 object
  729. * @returns the current updated Color4 object
  730. */
  731. copyFrom(source: Color4): Color4;
  732. /**
  733. * Copies the given float values into the current one
  734. * @param r defines the red component to read from
  735. * @param g defines the green component to read from
  736. * @param b defines the blue component to read from
  737. * @param a defines the alpha component to read from
  738. * @returns the current updated Color4 object
  739. */
  740. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  741. /**
  742. * Copies the given float values into the current one
  743. * @param r defines the red component to read from
  744. * @param g defines the green component to read from
  745. * @param b defines the blue component to read from
  746. * @param a defines the alpha component to read from
  747. * @returns the current updated Color4 object
  748. */
  749. set(r: number, g: number, b: number, a: number): Color4;
  750. /**
  751. * Compute the Color4 hexadecimal code as a string
  752. * @returns a string containing the hexadecimal representation of the Color4 object
  753. */
  754. toHexString(): string;
  755. /**
  756. * Computes a new Color4 converted from the current one to linear space
  757. * @returns a new Color4 object
  758. */
  759. toLinearSpace(): Color4;
  760. /**
  761. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  762. * @param convertedColor defines the Color4 object where to store the linear space version
  763. * @returns the unmodified Color4
  764. */
  765. toLinearSpaceToRef(convertedColor: Color4): Color4;
  766. /**
  767. * Computes a new Color4 converted from the current one to gamma space
  768. * @returns a new Color4 object
  769. */
  770. toGammaSpace(): Color4;
  771. /**
  772. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  773. * @param convertedColor defines the Color4 object where to store the gamma space version
  774. * @returns the unmodified Color4
  775. */
  776. toGammaSpaceToRef(convertedColor: Color4): Color4;
  777. /**
  778. * Creates a new Color4 from the string containing valid hexadecimal values
  779. * @param hex defines a string containing valid hexadecimal values
  780. * @returns a new Color4 object
  781. */
  782. static FromHexString(hex: string): Color4;
  783. /**
  784. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  785. * @param left defines the start value
  786. * @param right defines the end value
  787. * @param amount defines the gradient factor
  788. * @returns a new Color4 object
  789. */
  790. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  791. /**
  792. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  793. * @param left defines the start value
  794. * @param right defines the end value
  795. * @param amount defines the gradient factor
  796. * @param result defines the Color4 object where to store data
  797. */
  798. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  799. /**
  800. * Creates a new Color4 from a Color3 and an alpha value
  801. * @param color3 defines the source Color3 to read from
  802. * @param alpha defines the alpha component (1.0 by default)
  803. * @returns a new Color4 object
  804. */
  805. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  806. /**
  807. * Creates a new Color4 from the starting index element of the given array
  808. * @param array defines the source array to read from
  809. * @param offset defines the offset in the source array
  810. * @returns a new Color4 object
  811. */
  812. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  813. /**
  814. * Creates a new Color3 from integer values (< 256)
  815. * @param r defines the red component to read from (value between 0 and 255)
  816. * @param g defines the green component to read from (value between 0 and 255)
  817. * @param b defines the blue component to read from (value between 0 and 255)
  818. * @param a defines the alpha component to read from (value between 0 and 255)
  819. * @returns a new Color3 object
  820. */
  821. static FromInts(r: number, g: number, b: number, a: number): Color4;
  822. /**
  823. * Check the content of a given array and convert it to an array containing RGBA data
  824. * If the original array was already containing count * 4 values then it is returned directly
  825. * @param colors defines the array to check
  826. * @param count defines the number of RGBA data to expect
  827. * @returns an array containing count * 4 values (RGBA)
  828. */
  829. static CheckColors4(colors: number[], count: number): number[];
  830. }
  831. /**
  832. * Class representing a vector containing 2 coordinates
  833. */
  834. export class Vector2 {
  835. /** defines the first coordinate */
  836. x: number;
  837. /** defines the second coordinate */
  838. y: number;
  839. /**
  840. * Creates a new Vector2 from the given x and y coordinates
  841. * @param x defines the first coordinate
  842. * @param y defines the second coordinate
  843. */
  844. constructor(
  845. /** defines the first coordinate */
  846. x?: number,
  847. /** defines the second coordinate */
  848. y?: number);
  849. /**
  850. * Gets a string with the Vector2 coordinates
  851. * @returns a string with the Vector2 coordinates
  852. */
  853. toString(): string;
  854. /**
  855. * Gets class name
  856. * @returns the string "Vector2"
  857. */
  858. getClassName(): string;
  859. /**
  860. * Gets current vector hash code
  861. * @returns the Vector2 hash code as a number
  862. */
  863. getHashCode(): number;
  864. /**
  865. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  866. * @param array defines the source array
  867. * @param index defines the offset in source array
  868. * @returns the current Vector2
  869. */
  870. toArray(array: FloatArray, index?: number): Vector2;
  871. /**
  872. * Copy the current vector to an array
  873. * @returns a new array with 2 elements: the Vector2 coordinates.
  874. */
  875. asArray(): number[];
  876. /**
  877. * Sets the Vector2 coordinates with the given Vector2 coordinates
  878. * @param source defines the source Vector2
  879. * @returns the current updated Vector2
  880. */
  881. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  882. /**
  883. * Sets the Vector2 coordinates with the given floats
  884. * @param x defines the first coordinate
  885. * @param y defines the second coordinate
  886. * @returns the current updated Vector2
  887. */
  888. copyFromFloats(x: number, y: number): Vector2;
  889. /**
  890. * Sets the Vector2 coordinates with the given floats
  891. * @param x defines the first coordinate
  892. * @param y defines the second coordinate
  893. * @returns the current updated Vector2
  894. */
  895. set(x: number, y: number): Vector2;
  896. /**
  897. * Add another vector with the current one
  898. * @param otherVector defines the other vector
  899. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  900. */
  901. add(otherVector: DeepImmutable<Vector2>): Vector2;
  902. /**
  903. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  904. * @param otherVector defines the other vector
  905. * @param result defines the target vector
  906. * @returns the unmodified current Vector2
  907. */
  908. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  909. /**
  910. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  911. * @param otherVector defines the other vector
  912. * @returns the current updated Vector2
  913. */
  914. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  915. /**
  916. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2
  919. */
  920. addVector3(otherVector: Vector3): Vector2;
  921. /**
  922. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  923. * @param otherVector defines the other vector
  924. * @returns a new Vector2
  925. */
  926. subtract(otherVector: Vector2): Vector2;
  927. /**
  928. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  929. * @param otherVector defines the other vector
  930. * @param result defines the target vector
  931. * @returns the unmodified current Vector2
  932. */
  933. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  934. /**
  935. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @returns the current updated Vector2
  938. */
  939. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  940. /**
  941. * Multiplies in place the current Vector2 coordinates by the given ones
  942. * @param otherVector defines the other vector
  943. * @returns the current updated Vector2
  944. */
  945. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  946. /**
  947. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns a new Vector2
  950. */
  951. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  954. * @param otherVector defines the other vector
  955. * @param result defines the target vector
  956. * @returns the unmodified current Vector2
  957. */
  958. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  959. /**
  960. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  961. * @param x defines the first coordinate
  962. * @param y defines the second coordinate
  963. * @returns a new Vector2
  964. */
  965. multiplyByFloats(x: number, y: number): Vector2;
  966. /**
  967. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns a new Vector2
  970. */
  971. divide(otherVector: Vector2): Vector2;
  972. /**
  973. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  974. * @param otherVector defines the other vector
  975. * @param result defines the target vector
  976. * @returns the unmodified current Vector2
  977. */
  978. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  979. /**
  980. * Divides the current Vector2 coordinates by the given ones
  981. * @param otherVector defines the other vector
  982. * @returns the current updated Vector2
  983. */
  984. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  985. /**
  986. * Gets a new Vector2 with current Vector2 negated coordinates
  987. * @returns a new Vector2
  988. */
  989. negate(): Vector2;
  990. /**
  991. * Multiply the Vector2 coordinates by scale
  992. * @param scale defines the scaling factor
  993. * @returns the current updated Vector2
  994. */
  995. scaleInPlace(scale: number): Vector2;
  996. /**
  997. * Returns a new Vector2 scaled by "scale" from the current Vector2
  998. * @param scale defines the scaling factor
  999. * @returns a new Vector2
  1000. */
  1001. scale(scale: number): Vector2;
  1002. /**
  1003. * Scale the current Vector2 values by a factor to a given Vector2
  1004. * @param scale defines the scale factor
  1005. * @param result defines the Vector2 object where to store the result
  1006. * @returns the unmodified current Vector2
  1007. */
  1008. scaleToRef(scale: number, result: Vector2): Vector2;
  1009. /**
  1010. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1011. * @param scale defines the scale factor
  1012. * @param result defines the Vector2 object where to store the result
  1013. * @returns the unmodified current Vector2
  1014. */
  1015. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1016. /**
  1017. * Gets a boolean if two vectors are equals
  1018. * @param otherVector defines the other vector
  1019. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1020. */
  1021. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1022. /**
  1023. * Gets a boolean if two vectors are equals (using an epsilon value)
  1024. * @param otherVector defines the other vector
  1025. * @param epsilon defines the minimal distance to consider equality
  1026. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1027. */
  1028. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1029. /**
  1030. * Gets a new Vector2 from current Vector2 floored values
  1031. * @returns a new Vector2
  1032. */
  1033. floor(): Vector2;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. fract(): Vector2;
  1039. /**
  1040. * Gets the length of the vector
  1041. * @returns the vector length (float)
  1042. */
  1043. length(): number;
  1044. /**
  1045. * Gets the vector squared length
  1046. * @returns the vector squared length (float)
  1047. */
  1048. lengthSquared(): number;
  1049. /**
  1050. * Normalize the vector
  1051. * @returns the current updated Vector2
  1052. */
  1053. normalize(): Vector2;
  1054. /**
  1055. * Gets a new Vector2 copied from the Vector2
  1056. * @returns a new Vector2
  1057. */
  1058. clone(): Vector2;
  1059. /**
  1060. * Gets a new Vector2(0, 0)
  1061. * @returns a new Vector2
  1062. */
  1063. static Zero(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(1, 1)
  1066. * @returns a new Vector2
  1067. */
  1068. static One(): Vector2;
  1069. /**
  1070. * Gets a new Vector2 set from the given index element of the given array
  1071. * @param array defines the data source
  1072. * @param offset defines the offset in the data source
  1073. * @returns a new Vector2
  1074. */
  1075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1076. /**
  1077. * Sets "result" from the given index element of the given array
  1078. * @param array defines the data source
  1079. * @param offset defines the offset in the data source
  1080. * @param result defines the target vector
  1081. */
  1082. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1083. /**
  1084. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1085. * @param value1 defines 1st point of control
  1086. * @param value2 defines 2nd point of control
  1087. * @param value3 defines 3rd point of control
  1088. * @param value4 defines 4th point of control
  1089. * @param amount defines the interpolation factor
  1090. * @returns a new Vector2
  1091. */
  1092. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1093. /**
  1094. * 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".
  1095. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1096. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1097. * @param value defines the value to clamp
  1098. * @param min defines the lower limit
  1099. * @param max defines the upper limit
  1100. * @returns a new Vector2
  1101. */
  1102. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1103. /**
  1104. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1105. * @param value1 defines the 1st control point
  1106. * @param tangent1 defines the outgoing tangent
  1107. * @param value2 defines the 2nd control point
  1108. * @param tangent2 defines the incoming tangent
  1109. * @param amount defines the interpolation factor
  1110. * @returns a new Vector2
  1111. */
  1112. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1113. /**
  1114. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1115. * @param start defines the start vector
  1116. * @param end defines the end vector
  1117. * @param amount defines the interpolation factor
  1118. * @returns a new Vector2
  1119. */
  1120. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1121. /**
  1122. * Gets the dot product of the vector "left" and the vector "right"
  1123. * @param left defines first vector
  1124. * @param right defines second vector
  1125. * @returns the dot product (float)
  1126. */
  1127. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1128. /**
  1129. * Returns a new Vector2 equal to the normalized given vector
  1130. * @param vector defines the vector to normalize
  1131. * @returns a new Vector2
  1132. */
  1133. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1134. /**
  1135. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1136. * @param left defines 1st vector
  1137. * @param right defines 2nd vector
  1138. * @returns a new Vector2
  1139. */
  1140. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1141. /**
  1142. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1143. * @param left defines 1st vector
  1144. * @param right defines 2nd vector
  1145. * @returns a new Vector2
  1146. */
  1147. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1148. /**
  1149. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1150. * @param vector defines the vector to transform
  1151. * @param transformation defines the matrix to apply
  1152. * @returns a new Vector2
  1153. */
  1154. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1155. /**
  1156. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1157. * @param vector defines the vector to transform
  1158. * @param transformation defines the matrix to apply
  1159. * @param result defines the target vector
  1160. */
  1161. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1162. /**
  1163. * Determines if a given vector is included in a triangle
  1164. * @param p defines the vector to test
  1165. * @param p0 defines 1st triangle point
  1166. * @param p1 defines 2nd triangle point
  1167. * @param p2 defines 3rd triangle point
  1168. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1169. */
  1170. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1171. /**
  1172. * Gets the distance between the vectors "value1" and "value2"
  1173. * @param value1 defines first vector
  1174. * @param value2 defines second vector
  1175. * @returns the distance between vectors
  1176. */
  1177. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1178. /**
  1179. * Returns the squared distance between the vectors "value1" and "value2"
  1180. * @param value1 defines first vector
  1181. * @param value2 defines second vector
  1182. * @returns the squared distance between vectors
  1183. */
  1184. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1185. /**
  1186. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1187. * @param value1 defines first vector
  1188. * @param value2 defines second vector
  1189. * @returns a new Vector2
  1190. */
  1191. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1192. /**
  1193. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1194. * @param p defines the middle point
  1195. * @param segA defines one point of the segment
  1196. * @param segB defines the other point of the segment
  1197. * @returns the shortest distance
  1198. */
  1199. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1200. }
  1201. /**
  1202. * Classed used to store (x,y,z) vector representation
  1203. * A Vector3 is the main object used in 3D geometry
  1204. * It can represent etiher the coordinates of a point the space, either a direction
  1205. * Reminder: js uses a left handed forward facing system
  1206. */
  1207. export class Vector3 {
  1208. /**
  1209. * Defines the first coordinates (on X axis)
  1210. */
  1211. x: number;
  1212. /**
  1213. * Defines the second coordinates (on Y axis)
  1214. */
  1215. y: number;
  1216. /**
  1217. * Defines the third coordinates (on Z axis)
  1218. */
  1219. z: number;
  1220. private static _UpReadOnly;
  1221. /**
  1222. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1223. * @param x defines the first coordinates (on X axis)
  1224. * @param y defines the second coordinates (on Y axis)
  1225. * @param z defines the third coordinates (on Z axis)
  1226. */
  1227. constructor(
  1228. /**
  1229. * Defines the first coordinates (on X axis)
  1230. */
  1231. x?: number,
  1232. /**
  1233. * Defines the second coordinates (on Y axis)
  1234. */
  1235. y?: number,
  1236. /**
  1237. * Defines the third coordinates (on Z axis)
  1238. */
  1239. z?: number);
  1240. /**
  1241. * Creates a string representation of the Vector3
  1242. * @returns a string with the Vector3 coordinates.
  1243. */
  1244. toString(): string;
  1245. /**
  1246. * Gets the class name
  1247. * @returns the string "Vector3"
  1248. */
  1249. getClassName(): string;
  1250. /**
  1251. * Creates the Vector3 hash code
  1252. * @returns a number which tends to be unique between Vector3 instances
  1253. */
  1254. getHashCode(): number;
  1255. /**
  1256. * Creates an array containing three elements : the coordinates of the Vector3
  1257. * @returns a new array of numbers
  1258. */
  1259. asArray(): number[];
  1260. /**
  1261. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1262. * @param array defines the destination array
  1263. * @param index defines the offset in the destination array
  1264. * @returns the current Vector3
  1265. */
  1266. toArray(array: FloatArray, index?: number): Vector3;
  1267. /**
  1268. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1269. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1270. */
  1271. toQuaternion(): Quaternion;
  1272. /**
  1273. * Adds the given vector to the current Vector3
  1274. * @param otherVector defines the second operand
  1275. * @returns the current updated Vector3
  1276. */
  1277. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1278. /**
  1279. * Adds the given coordinates to the current Vector3
  1280. * @param x defines the x coordinate of the operand
  1281. * @param y defines the y coordinate of the operand
  1282. * @param z defines the z coordinate of the operand
  1283. * @returns the current updated Vector3
  1284. */
  1285. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1286. /**
  1287. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1288. * @param otherVector defines the second operand
  1289. * @returns the resulting Vector3
  1290. */
  1291. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1292. /**
  1293. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1294. * @param otherVector defines the second operand
  1295. * @param result defines the Vector3 object where to store the result
  1296. * @returns the current Vector3
  1297. */
  1298. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1299. /**
  1300. * Subtract the given vector from the current Vector3
  1301. * @param otherVector defines the second operand
  1302. * @returns the current updated Vector3
  1303. */
  1304. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the resulting Vector3
  1309. */
  1310. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1313. * @param otherVector defines the second operand
  1314. * @param result defines the Vector3 object where to store the result
  1315. * @returns the current Vector3
  1316. */
  1317. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1318. /**
  1319. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1320. * @param x defines the x coordinate of the operand
  1321. * @param y defines the y coordinate of the operand
  1322. * @param z defines the z coordinate of the operand
  1323. * @returns the resulting Vector3
  1324. */
  1325. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1326. /**
  1327. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1328. * @param x defines the x coordinate of the operand
  1329. * @param y defines the y coordinate of the operand
  1330. * @param z defines the z coordinate of the operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1335. /**
  1336. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1337. * @returns a new Vector3
  1338. */
  1339. negate(): Vector3;
  1340. /**
  1341. * Multiplies the Vector3 coordinates by the float "scale"
  1342. * @param scale defines the multiplier factor
  1343. * @returns the current updated Vector3
  1344. */
  1345. scaleInPlace(scale: number): Vector3;
  1346. /**
  1347. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns a new Vector3
  1350. */
  1351. scale(scale: number): Vector3;
  1352. /**
  1353. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1354. * @param scale defines the multiplier factor
  1355. * @param result defines the Vector3 object where to store the result
  1356. * @returns the current Vector3
  1357. */
  1358. scaleToRef(scale: number, result: Vector3): Vector3;
  1359. /**
  1360. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1361. * @param scale defines the scale factor
  1362. * @param result defines the Vector3 object where to store the result
  1363. * @returns the unmodified current Vector3
  1364. */
  1365. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1366. /**
  1367. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1368. * @param otherVector defines the second operand
  1369. * @returns true if both vectors are equals
  1370. */
  1371. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1374. * @param otherVector defines the second operand
  1375. * @param epsilon defines the minimal distance to define values as equals
  1376. * @returns true if both vectors are distant less than epsilon
  1377. */
  1378. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1379. /**
  1380. * Returns true if the current Vector3 coordinates equals the given floats
  1381. * @param x defines the x coordinate of the operand
  1382. * @param y defines the y coordinate of the operand
  1383. * @param z defines the z coordinate of the operand
  1384. * @returns true if both vectors are equals
  1385. */
  1386. equalsToFloats(x: number, y: number, z: number): boolean;
  1387. /**
  1388. * Multiplies the current Vector3 coordinates by the given ones
  1389. * @param otherVector defines the second operand
  1390. * @returns the current updated Vector3
  1391. */
  1392. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1393. /**
  1394. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1395. * @param otherVector defines the second operand
  1396. * @returns the new Vector3
  1397. */
  1398. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1401. * @param otherVector defines the second operand
  1402. * @param result defines the Vector3 object where to store the result
  1403. * @returns the current Vector3
  1404. */
  1405. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1406. /**
  1407. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1408. * @param x defines the x coordinate of the operand
  1409. * @param y defines the y coordinate of the operand
  1410. * @param z defines the z coordinate of the operand
  1411. * @returns the new Vector3
  1412. */
  1413. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1416. * @param otherVector defines the second operand
  1417. * @returns the new Vector3
  1418. */
  1419. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1420. /**
  1421. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1422. * @param otherVector defines the second operand
  1423. * @param result defines the Vector3 object where to store the result
  1424. * @returns the current Vector3
  1425. */
  1426. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1427. /**
  1428. * Divides the current Vector3 coordinates by the given ones.
  1429. * @param otherVector defines the second operand
  1430. * @returns the current updated Vector3
  1431. */
  1432. divideInPlace(otherVector: Vector3): Vector3;
  1433. /**
  1434. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1435. * @param other defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1447. * @param x defines the x coordinate of the operand
  1448. * @param y defines the y coordinate of the operand
  1449. * @param z defines the z coordinate of the operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1455. * @param x defines the x coordinate of the operand
  1456. * @param y defines the y coordinate of the operand
  1457. * @param z defines the z coordinate of the operand
  1458. * @returns the current updated Vector3
  1459. */
  1460. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1461. /**
  1462. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1463. * Check if is non uniform within a certain amount of decimal places to account for this
  1464. * @param epsilon the amount the values can differ
  1465. * @returns if the the vector is non uniform to a certain number of decimal places
  1466. */
  1467. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1468. /**
  1469. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1470. */
  1471. readonly isNonUniform: boolean;
  1472. /**
  1473. * Gets a new Vector3 from current Vector3 floored values
  1474. * @returns a new Vector3
  1475. */
  1476. floor(): Vector3;
  1477. /**
  1478. * Gets a new Vector3 from current Vector3 floored values
  1479. * @returns a new Vector3
  1480. */
  1481. fract(): Vector3;
  1482. /**
  1483. * Gets the length of the Vector3
  1484. * @returns the length of the Vecto3
  1485. */
  1486. length(): number;
  1487. /**
  1488. * Gets the squared length of the Vector3
  1489. * @returns squared length of the Vector3
  1490. */
  1491. lengthSquared(): number;
  1492. /**
  1493. * Normalize the current Vector3.
  1494. * Please note that this is an in place operation.
  1495. * @returns the current updated Vector3
  1496. */
  1497. normalize(): Vector3;
  1498. /**
  1499. * Reorders the x y z properties of the vector in place
  1500. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1501. * @returns the current updated vector
  1502. */
  1503. reorderInPlace(order: string): this;
  1504. /**
  1505. * Rotates the vector around 0,0,0 by a quaternion
  1506. * @param quaternion the rotation quaternion
  1507. * @param result vector to store the result
  1508. * @returns the resulting vector
  1509. */
  1510. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1511. /**
  1512. * Rotates a vector around a given point
  1513. * @param quaternion the rotation quaternion
  1514. * @param point the point to rotate around
  1515. * @param result vector to store the result
  1516. * @returns the resulting vector
  1517. */
  1518. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1519. /**
  1520. * Normalize the current Vector3 with the given input length.
  1521. * Please note that this is an in place operation.
  1522. * @param len the length of the vector
  1523. * @returns the current updated Vector3
  1524. */
  1525. normalizeFromLength(len: number): Vector3;
  1526. /**
  1527. * Normalize the current Vector3 to a new vector
  1528. * @returns the new Vector3
  1529. */
  1530. normalizeToNew(): Vector3;
  1531. /**
  1532. * Normalize the current Vector3 to the reference
  1533. * @param reference define the Vector3 to update
  1534. * @returns the updated Vector3
  1535. */
  1536. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1537. /**
  1538. * Creates a new Vector3 copied from the current Vector3
  1539. * @returns the new Vector3
  1540. */
  1541. clone(): Vector3;
  1542. /**
  1543. * Copies the given vector coordinates to the current Vector3 ones
  1544. * @param source defines the source Vector3
  1545. * @returns the current updated Vector3
  1546. */
  1547. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1548. /**
  1549. * Copies the given floats to the current Vector3 coordinates
  1550. * @param x defines the x coordinate of the operand
  1551. * @param y defines the y coordinate of the operand
  1552. * @param z defines the z coordinate of the operand
  1553. * @returns the current updated Vector3
  1554. */
  1555. copyFromFloats(x: number, y: number, z: number): Vector3;
  1556. /**
  1557. * Copies the given floats to the current Vector3 coordinates
  1558. * @param x defines the x coordinate of the operand
  1559. * @param y defines the y coordinate of the operand
  1560. * @param z defines the z coordinate of the operand
  1561. * @returns the current updated Vector3
  1562. */
  1563. set(x: number, y: number, z: number): Vector3;
  1564. /**
  1565. * Copies the given float to the current Vector3 coordinates
  1566. * @param v defines the x, y and z coordinates of the operand
  1567. * @returns the current updated Vector3
  1568. */
  1569. setAll(v: number): Vector3;
  1570. /**
  1571. * Get the clip factor between two vectors
  1572. * @param vector0 defines the first operand
  1573. * @param vector1 defines the second operand
  1574. * @param axis defines the axis to use
  1575. * @param size defines the size along the axis
  1576. * @returns the clip factor
  1577. */
  1578. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1579. /**
  1580. * Get angle between two vectors
  1581. * @param vector0 angle between vector0 and vector1
  1582. * @param vector1 angle between vector0 and vector1
  1583. * @param normal direction of the normal
  1584. * @return the angle between vector0 and vector1
  1585. */
  1586. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1587. /**
  1588. * Returns a new Vector3 set from the index "offset" of the given array
  1589. * @param array defines the source array
  1590. * @param offset defines the offset in the source array
  1591. * @returns the new Vector3
  1592. */
  1593. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1594. /**
  1595. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1596. * This function is deprecated. Use FromArray instead
  1597. * @param array defines the source array
  1598. * @param offset defines the offset in the source array
  1599. * @returns the new Vector3
  1600. */
  1601. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1602. /**
  1603. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1604. * @param array defines the source array
  1605. * @param offset defines the offset in the source array
  1606. * @param result defines the Vector3 where to store the result
  1607. */
  1608. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1609. /**
  1610. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1611. * This function is deprecated. Use FromArrayToRef instead.
  1612. * @param array defines the source array
  1613. * @param offset defines the offset in the source array
  1614. * @param result defines the Vector3 where to store the result
  1615. */
  1616. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1617. /**
  1618. * Sets the given vector "result" with the given floats.
  1619. * @param x defines the x coordinate of the source
  1620. * @param y defines the y coordinate of the source
  1621. * @param z defines the z coordinate of the source
  1622. * @param result defines the Vector3 where to store the result
  1623. */
  1624. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1625. /**
  1626. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1627. * @returns a new empty Vector3
  1628. */
  1629. static Zero(): Vector3;
  1630. /**
  1631. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1632. * @returns a new unit Vector3
  1633. */
  1634. static One(): Vector3;
  1635. /**
  1636. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1637. * @returns a new up Vector3
  1638. */
  1639. static Up(): Vector3;
  1640. /**
  1641. * Gets a up Vector3 that must not be updated
  1642. */
  1643. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1644. /**
  1645. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1646. * @returns a new down Vector3
  1647. */
  1648. static Down(): Vector3;
  1649. /**
  1650. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1651. * @returns a new forward Vector3
  1652. */
  1653. static Forward(): Vector3;
  1654. /**
  1655. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1656. * @returns a new forward Vector3
  1657. */
  1658. static Backward(): Vector3;
  1659. /**
  1660. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1661. * @returns a new right Vector3
  1662. */
  1663. static Right(): Vector3;
  1664. /**
  1665. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1666. * @returns a new left Vector3
  1667. */
  1668. static Left(): Vector3;
  1669. /**
  1670. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1671. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1672. * @param vector defines the Vector3 to transform
  1673. * @param transformation defines the transformation matrix
  1674. * @returns the transformed Vector3
  1675. */
  1676. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1677. /**
  1678. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1679. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1680. * @param vector defines the Vector3 to transform
  1681. * @param transformation defines the transformation matrix
  1682. * @param result defines the Vector3 where to store the result
  1683. */
  1684. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1685. /**
  1686. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1687. * This method computes tranformed coordinates only, not transformed direction vectors
  1688. * @param x define the x coordinate of the source vector
  1689. * @param y define the y coordinate of the source vector
  1690. * @param z define the z coordinate of the source vector
  1691. * @param transformation defines the transformation matrix
  1692. * @param result defines the Vector3 where to store the result
  1693. */
  1694. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1695. /**
  1696. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1697. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1698. * @param vector defines the Vector3 to transform
  1699. * @param transformation defines the transformation matrix
  1700. * @returns the new Vector3
  1701. */
  1702. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1703. /**
  1704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1705. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1706. * @param vector defines the Vector3 to transform
  1707. * @param transformation defines the transformation matrix
  1708. * @param result defines the Vector3 where to store the result
  1709. */
  1710. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1711. /**
  1712. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1713. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1714. * @param x define the x coordinate of the source vector
  1715. * @param y define the y coordinate of the source vector
  1716. * @param z define the z coordinate of the source vector
  1717. * @param transformation defines the transformation matrix
  1718. * @param result defines the Vector3 where to store the result
  1719. */
  1720. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1721. /**
  1722. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1723. * @param value1 defines the first control point
  1724. * @param value2 defines the second control point
  1725. * @param value3 defines the third control point
  1726. * @param value4 defines the fourth control point
  1727. * @param amount defines the amount on the spline to use
  1728. * @returns the new Vector3
  1729. */
  1730. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1731. /**
  1732. * 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"
  1733. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1734. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1735. * @param value defines the current value
  1736. * @param min defines the lower range value
  1737. * @param max defines the upper range value
  1738. * @returns the new Vector3
  1739. */
  1740. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1741. /**
  1742. * 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"
  1743. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1744. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1745. * @param value defines the current value
  1746. * @param min defines the lower range value
  1747. * @param max defines the upper range value
  1748. * @param result defines the Vector3 where to store the result
  1749. */
  1750. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1751. /**
  1752. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1753. * @param value1 defines the first control point
  1754. * @param tangent1 defines the first tangent vector
  1755. * @param value2 defines the second control point
  1756. * @param tangent2 defines the second tangent vector
  1757. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1758. * @returns the new Vector3
  1759. */
  1760. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1761. /**
  1762. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1763. * @param start defines the start value
  1764. * @param end defines the end value
  1765. * @param amount max defines amount between both (between 0 and 1)
  1766. * @returns the new Vector3
  1767. */
  1768. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1769. /**
  1770. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1771. * @param start defines the start value
  1772. * @param end defines the end value
  1773. * @param amount max defines amount between both (between 0 and 1)
  1774. * @param result defines the Vector3 where to store the result
  1775. */
  1776. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1777. /**
  1778. * Returns the dot product (float) between the vectors "left" and "right"
  1779. * @param left defines the left operand
  1780. * @param right defines the right operand
  1781. * @returns the dot product
  1782. */
  1783. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1784. /**
  1785. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1786. * The cross product is then orthogonal to both "left" and "right"
  1787. * @param left defines the left operand
  1788. * @param right defines the right operand
  1789. * @returns the cross product
  1790. */
  1791. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1792. /**
  1793. * Sets the given vector "result" with the cross product of "left" and "right"
  1794. * The cross product is then orthogonal to both "left" and "right"
  1795. * @param left defines the left operand
  1796. * @param right defines the right operand
  1797. * @param result defines the Vector3 where to store the result
  1798. */
  1799. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1800. /**
  1801. * Returns a new Vector3 as the normalization of the given vector
  1802. * @param vector defines the Vector3 to normalize
  1803. * @returns the new Vector3
  1804. */
  1805. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1806. /**
  1807. * Sets the given vector "result" with the normalization of the given first vector
  1808. * @param vector defines the Vector3 to normalize
  1809. * @param result defines the Vector3 where to store the result
  1810. */
  1811. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1812. /**
  1813. * Project a Vector3 onto screen space
  1814. * @param vector defines the Vector3 to project
  1815. * @param world defines the world matrix to use
  1816. * @param transform defines the transform (view x projection) matrix to use
  1817. * @param viewport defines the screen viewport to use
  1818. * @returns the new Vector3
  1819. */
  1820. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1821. /** @hidden */
  1822. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1823. /**
  1824. * Unproject from screen space to object space
  1825. * @param source defines the screen space Vector3 to use
  1826. * @param viewportWidth defines the current width of the viewport
  1827. * @param viewportHeight defines the current height of the viewport
  1828. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1829. * @param transform defines the transform (view x projection) matrix to use
  1830. * @returns the new Vector3
  1831. */
  1832. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1833. /**
  1834. * Unproject from screen space to object space
  1835. * @param source defines the screen space Vector3 to use
  1836. * @param viewportWidth defines the current width of the viewport
  1837. * @param viewportHeight defines the current height of the viewport
  1838. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1839. * @param view defines the view matrix to use
  1840. * @param projection defines the projection matrix to use
  1841. * @returns the new Vector3
  1842. */
  1843. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param view defines the view matrix to use
  1851. * @param projection defines the projection matrix to use
  1852. * @param result defines the Vector3 where to store the result
  1853. */
  1854. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1855. /**
  1856. * Unproject from screen space to object space
  1857. * @param sourceX defines the screen space x coordinate to use
  1858. * @param sourceY defines the screen space y coordinate to use
  1859. * @param sourceZ defines the screen space z coordinate to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @param result defines the Vector3 where to store the result
  1866. */
  1867. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1868. /**
  1869. * Gets the minimal coordinate values between two Vector3
  1870. * @param left defines the first operand
  1871. * @param right defines the second operand
  1872. * @returns the new Vector3
  1873. */
  1874. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1875. /**
  1876. * Gets the maximal coordinate values between two Vector3
  1877. * @param left defines the first operand
  1878. * @param right defines the second operand
  1879. * @returns the new Vector3
  1880. */
  1881. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1882. /**
  1883. * Returns the distance between the vectors "value1" and "value2"
  1884. * @param value1 defines the first operand
  1885. * @param value2 defines the second operand
  1886. * @returns the distance
  1887. */
  1888. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1889. /**
  1890. * Returns the squared distance between the vectors "value1" and "value2"
  1891. * @param value1 defines the first operand
  1892. * @param value2 defines the second operand
  1893. * @returns the squared distance
  1894. */
  1895. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1896. /**
  1897. * Returns a new Vector3 located at the center between "value1" and "value2"
  1898. * @param value1 defines the first operand
  1899. * @param value2 defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1905. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1906. * to something in order to rotate it from its local system to the given target system
  1907. * Note: axis1, axis2 and axis3 are normalized during this operation
  1908. * @param axis1 defines the first axis
  1909. * @param axis2 defines the second axis
  1910. * @param axis3 defines the third axis
  1911. * @returns a new Vector3
  1912. */
  1913. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1914. /**
  1915. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1916. * @param axis1 defines the first axis
  1917. * @param axis2 defines the second axis
  1918. * @param axis3 defines the third axis
  1919. * @param ref defines the Vector3 where to store the result
  1920. */
  1921. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1922. }
  1923. /**
  1924. * Vector4 class created for EulerAngle class conversion to Quaternion
  1925. */
  1926. export class Vector4 {
  1927. /** x value of the vector */
  1928. x: number;
  1929. /** y value of the vector */
  1930. y: number;
  1931. /** z value of the vector */
  1932. z: number;
  1933. /** w value of the vector */
  1934. w: number;
  1935. /**
  1936. * Creates a Vector4 object from the given floats.
  1937. * @param x x value of the vector
  1938. * @param y y value of the vector
  1939. * @param z z value of the vector
  1940. * @param w w value of the vector
  1941. */
  1942. constructor(
  1943. /** x value of the vector */
  1944. x: number,
  1945. /** y value of the vector */
  1946. y: number,
  1947. /** z value of the vector */
  1948. z: number,
  1949. /** w value of the vector */
  1950. w: number);
  1951. /**
  1952. * Returns the string with the Vector4 coordinates.
  1953. * @returns a string containing all the vector values
  1954. */
  1955. toString(): string;
  1956. /**
  1957. * Returns the string "Vector4".
  1958. * @returns "Vector4"
  1959. */
  1960. getClassName(): string;
  1961. /**
  1962. * Returns the Vector4 hash code.
  1963. * @returns a unique hash code
  1964. */
  1965. getHashCode(): number;
  1966. /**
  1967. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1968. * @returns the resulting array
  1969. */
  1970. asArray(): number[];
  1971. /**
  1972. * Populates the given array from the given index with the Vector4 coordinates.
  1973. * @param array array to populate
  1974. * @param index index of the array to start at (default: 0)
  1975. * @returns the Vector4.
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector4;
  1978. /**
  1979. * Adds the given vector to the current Vector4.
  1980. * @param otherVector the vector to add
  1981. * @returns the updated Vector4.
  1982. */
  1983. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1984. /**
  1985. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1986. * @param otherVector the vector to add
  1987. * @returns the resulting vector
  1988. */
  1989. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1990. /**
  1991. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1992. * @param otherVector the vector to add
  1993. * @param result the vector to store the result
  1994. * @returns the current Vector4.
  1995. */
  1996. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1997. /**
  1998. * Subtract in place the given vector from the current Vector4.
  1999. * @param otherVector the vector to subtract
  2000. * @returns the updated Vector4.
  2001. */
  2002. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2003. /**
  2004. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2005. * @param otherVector the vector to add
  2006. * @returns the new vector with the result
  2007. */
  2008. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2009. /**
  2010. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2011. * @param otherVector the vector to subtract
  2012. * @param result the vector to store the result
  2013. * @returns the current Vector4.
  2014. */
  2015. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2016. /**
  2017. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2018. */
  2019. /**
  2020. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2021. * @param x value to subtract
  2022. * @param y value to subtract
  2023. * @param z value to subtract
  2024. * @param w value to subtract
  2025. * @returns new vector containing the result
  2026. */
  2027. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2028. /**
  2029. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2030. * @param x value to subtract
  2031. * @param y value to subtract
  2032. * @param z value to subtract
  2033. * @param w value to subtract
  2034. * @param result the vector to store the result in
  2035. * @returns the current Vector4.
  2036. */
  2037. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2038. /**
  2039. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2040. * @returns a new vector with the negated values
  2041. */
  2042. negate(): Vector4;
  2043. /**
  2044. * Multiplies the current Vector4 coordinates by scale (float).
  2045. * @param scale the number to scale with
  2046. * @returns the updated Vector4.
  2047. */
  2048. scaleInPlace(scale: number): Vector4;
  2049. /**
  2050. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2051. * @param scale the number to scale with
  2052. * @returns a new vector with the result
  2053. */
  2054. scale(scale: number): Vector4;
  2055. /**
  2056. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2057. * @param scale the number to scale with
  2058. * @param result a vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. scaleToRef(scale: number, result: Vector4): Vector4;
  2062. /**
  2063. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2064. * @param scale defines the scale factor
  2065. * @param result defines the Vector4 object where to store the result
  2066. * @returns the unmodified current Vector4
  2067. */
  2068. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2069. /**
  2070. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2071. * @param otherVector the vector to compare against
  2072. * @returns true if they are equal
  2073. */
  2074. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2075. /**
  2076. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2077. * @param otherVector vector to compare against
  2078. * @param epsilon (Default: very small number)
  2079. * @returns true if they are equal
  2080. */
  2081. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2082. /**
  2083. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2084. * @param x x value to compare against
  2085. * @param y y value to compare against
  2086. * @param z z value to compare against
  2087. * @param w w value to compare against
  2088. * @returns true if equal
  2089. */
  2090. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2091. /**
  2092. * Multiplies in place the current Vector4 by the given one.
  2093. * @param otherVector vector to multiple with
  2094. * @returns the updated Vector4.
  2095. */
  2096. multiplyInPlace(otherVector: Vector4): Vector4;
  2097. /**
  2098. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2099. * @param otherVector vector to multiple with
  2100. * @returns resulting new vector
  2101. */
  2102. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2103. /**
  2104. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2105. * @param otherVector vector to multiple with
  2106. * @param result vector to store the result
  2107. * @returns the current Vector4.
  2108. */
  2109. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2110. /**
  2111. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2112. * @param x x value multiply with
  2113. * @param y y value multiply with
  2114. * @param z z value multiply with
  2115. * @param w w value multiply with
  2116. * @returns resulting new vector
  2117. */
  2118. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2119. /**
  2120. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2121. * @param otherVector vector to devide with
  2122. * @returns resulting new vector
  2123. */
  2124. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2125. /**
  2126. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2127. * @param otherVector vector to devide with
  2128. * @param result vector to store the result
  2129. * @returns the current Vector4.
  2130. */
  2131. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2132. /**
  2133. * Divides the current Vector3 coordinates by the given ones.
  2134. * @param otherVector vector to devide with
  2135. * @returns the updated Vector3.
  2136. */
  2137. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2138. /**
  2139. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2140. * @param other defines the second operand
  2141. * @returns the current updated Vector4
  2142. */
  2143. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2144. /**
  2145. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2146. * @param other defines the second operand
  2147. * @returns the current updated Vector4
  2148. */
  2149. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2150. /**
  2151. * Gets a new Vector4 from current Vector4 floored values
  2152. * @returns a new Vector4
  2153. */
  2154. floor(): Vector4;
  2155. /**
  2156. * Gets a new Vector4 from current Vector3 floored values
  2157. * @returns a new Vector4
  2158. */
  2159. fract(): Vector4;
  2160. /**
  2161. * Returns the Vector4 length (float).
  2162. * @returns the length
  2163. */
  2164. length(): number;
  2165. /**
  2166. * Returns the Vector4 squared length (float).
  2167. * @returns the length squared
  2168. */
  2169. lengthSquared(): number;
  2170. /**
  2171. * Normalizes in place the Vector4.
  2172. * @returns the updated Vector4.
  2173. */
  2174. normalize(): Vector4;
  2175. /**
  2176. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2177. * @returns this converted to a new vector3
  2178. */
  2179. toVector3(): Vector3;
  2180. /**
  2181. * Returns a new Vector4 copied from the current one.
  2182. * @returns the new cloned vector
  2183. */
  2184. clone(): Vector4;
  2185. /**
  2186. * Updates the current Vector4 with the given one coordinates.
  2187. * @param source the source vector to copy from
  2188. * @returns the updated Vector4.
  2189. */
  2190. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2191. /**
  2192. * Updates the current Vector4 coordinates with the given floats.
  2193. * @param x float to copy from
  2194. * @param y float to copy from
  2195. * @param z float to copy from
  2196. * @param w float to copy from
  2197. * @returns the updated Vector4.
  2198. */
  2199. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2200. /**
  2201. * Updates the current Vector4 coordinates with the given floats.
  2202. * @param x float to set from
  2203. * @param y float to set from
  2204. * @param z float to set from
  2205. * @param w float to set from
  2206. * @returns the updated Vector4.
  2207. */
  2208. set(x: number, y: number, z: number, w: number): Vector4;
  2209. /**
  2210. * Copies the given float to the current Vector3 coordinates
  2211. * @param v defines the x, y, z and w coordinates of the operand
  2212. * @returns the current updated Vector3
  2213. */
  2214. setAll(v: number): Vector4;
  2215. /**
  2216. * Returns a new Vector4 set from the starting index of the given array.
  2217. * @param array the array to pull values from
  2218. * @param offset the offset into the array to start at
  2219. * @returns the new vector
  2220. */
  2221. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2222. /**
  2223. * Updates the given vector "result" from the starting index of the given array.
  2224. * @param array the array to pull values from
  2225. * @param offset the offset into the array to start at
  2226. * @param result the vector to store the result in
  2227. */
  2228. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2229. /**
  2230. * Updates the given vector "result" from the starting index of the given Float32Array.
  2231. * @param array the array to pull values from
  2232. * @param offset the offset into the array to start at
  2233. * @param result the vector to store the result in
  2234. */
  2235. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2236. /**
  2237. * Updates the given vector "result" coordinates from the given floats.
  2238. * @param x float to set from
  2239. * @param y float to set from
  2240. * @param z float to set from
  2241. * @param w float to set from
  2242. * @param result the vector to the floats in
  2243. */
  2244. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2245. /**
  2246. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2247. * @returns the new vector
  2248. */
  2249. static Zero(): Vector4;
  2250. /**
  2251. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2252. * @returns the new vector
  2253. */
  2254. static One(): Vector4;
  2255. /**
  2256. * Returns a new normalized Vector4 from the given one.
  2257. * @param vector the vector to normalize
  2258. * @returns the vector
  2259. */
  2260. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2261. /**
  2262. * Updates the given vector "result" from the normalization of the given one.
  2263. * @param vector the vector to normalize
  2264. * @param result the vector to store the result in
  2265. */
  2266. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2267. /**
  2268. * Returns a vector with the minimum values from the left and right vectors
  2269. * @param left left vector to minimize
  2270. * @param right right vector to minimize
  2271. * @returns a new vector with the minimum of the left and right vector values
  2272. */
  2273. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2274. /**
  2275. * Returns a vector with the maximum values from the left and right vectors
  2276. * @param left left vector to maximize
  2277. * @param right right vector to maximize
  2278. * @returns a new vector with the maximum of the left and right vector values
  2279. */
  2280. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2281. /**
  2282. * Returns the distance (float) between the vectors "value1" and "value2".
  2283. * @param value1 value to calulate the distance between
  2284. * @param value2 value to calulate the distance between
  2285. * @return the distance between the two vectors
  2286. */
  2287. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2288. /**
  2289. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2290. * @param value1 value to calulate the distance between
  2291. * @param value2 value to calulate the distance between
  2292. * @return the distance between the two vectors squared
  2293. */
  2294. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2295. /**
  2296. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2297. * @param value1 value to calulate the center between
  2298. * @param value2 value to calulate the center between
  2299. * @return the center between the two vectors
  2300. */
  2301. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2304. * This methods computes transformed normalized direction vectors only.
  2305. * @param vector the vector to transform
  2306. * @param transformation the transformation matrix to apply
  2307. * @returns the new vector
  2308. */
  2309. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2310. /**
  2311. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2312. * This methods computes transformed normalized direction vectors only.
  2313. * @param vector the vector to transform
  2314. * @param transformation the transformation matrix to apply
  2315. * @param result the vector to store the result in
  2316. */
  2317. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2318. /**
  2319. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2320. * This methods computes transformed normalized direction vectors only.
  2321. * @param x value to transform
  2322. * @param y value to transform
  2323. * @param z value to transform
  2324. * @param w value to transform
  2325. * @param transformation the transformation matrix to apply
  2326. * @param result the vector to store the results in
  2327. */
  2328. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2329. /**
  2330. * Creates a new Vector4 from a Vector3
  2331. * @param source defines the source data
  2332. * @param w defines the 4th component (default is 0)
  2333. * @returns a new Vector4
  2334. */
  2335. static FromVector3(source: Vector3, w?: number): Vector4;
  2336. }
  2337. /**
  2338. * Interface for the size containing width and height
  2339. */
  2340. export interface ISize {
  2341. /**
  2342. * Width
  2343. */
  2344. width: number;
  2345. /**
  2346. * Heighht
  2347. */
  2348. height: number;
  2349. }
  2350. /**
  2351. * Size containing widht and height
  2352. */
  2353. export class Size implements ISize {
  2354. /**
  2355. * Width
  2356. */
  2357. width: number;
  2358. /**
  2359. * Height
  2360. */
  2361. height: number;
  2362. /**
  2363. * Creates a Size object from the given width and height (floats).
  2364. * @param width width of the new size
  2365. * @param height height of the new size
  2366. */
  2367. constructor(width: number, height: number);
  2368. /**
  2369. * Returns a string with the Size width and height
  2370. * @returns a string with the Size width and height
  2371. */
  2372. toString(): string;
  2373. /**
  2374. * "Size"
  2375. * @returns the string "Size"
  2376. */
  2377. getClassName(): string;
  2378. /**
  2379. * Returns the Size hash code.
  2380. * @returns a hash code for a unique width and height
  2381. */
  2382. getHashCode(): number;
  2383. /**
  2384. * Updates the current size from the given one.
  2385. * @param src the given size
  2386. */
  2387. copyFrom(src: Size): void;
  2388. /**
  2389. * Updates in place the current Size from the given floats.
  2390. * @param width width of the new size
  2391. * @param height height of the new size
  2392. * @returns the updated Size.
  2393. */
  2394. copyFromFloats(width: number, height: number): Size;
  2395. /**
  2396. * Updates in place the current Size from the given floats.
  2397. * @param width width to set
  2398. * @param height height to set
  2399. * @returns the updated Size.
  2400. */
  2401. set(width: number, height: number): Size;
  2402. /**
  2403. * Multiplies the width and height by numbers
  2404. * @param w factor to multiple the width by
  2405. * @param h factor to multiple the height by
  2406. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2407. */
  2408. multiplyByFloats(w: number, h: number): Size;
  2409. /**
  2410. * Clones the size
  2411. * @returns a new Size copied from the given one.
  2412. */
  2413. clone(): Size;
  2414. /**
  2415. * True if the current Size and the given one width and height are strictly equal.
  2416. * @param other the other size to compare against
  2417. * @returns True if the current Size and the given one width and height are strictly equal.
  2418. */
  2419. equals(other: Size): boolean;
  2420. /**
  2421. * The surface of the Size : width * height (float).
  2422. */
  2423. readonly surface: number;
  2424. /**
  2425. * Create a new size of zero
  2426. * @returns a new Size set to (0.0, 0.0)
  2427. */
  2428. static Zero(): Size;
  2429. /**
  2430. * Sums the width and height of two sizes
  2431. * @param otherSize size to add to this size
  2432. * @returns a new Size set as the addition result of the current Size and the given one.
  2433. */
  2434. add(otherSize: Size): Size;
  2435. /**
  2436. * Subtracts the width and height of two
  2437. * @param otherSize size to subtract to this size
  2438. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2439. */
  2440. subtract(otherSize: Size): Size;
  2441. /**
  2442. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2443. * @param start starting size to lerp between
  2444. * @param end end size to lerp between
  2445. * @param amount amount to lerp between the start and end values
  2446. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2447. */
  2448. static Lerp(start: Size, end: Size, amount: number): Size;
  2449. }
  2450. /**
  2451. * Class used to store quaternion data
  2452. * @see https://en.wikipedia.org/wiki/Quaternion
  2453. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2454. */
  2455. export class Quaternion {
  2456. /** defines the first component (0 by default) */
  2457. x: number;
  2458. /** defines the second component (0 by default) */
  2459. y: number;
  2460. /** defines the third component (0 by default) */
  2461. z: number;
  2462. /** defines the fourth component (1.0 by default) */
  2463. w: number;
  2464. /**
  2465. * Creates a new Quaternion from the given floats
  2466. * @param x defines the first component (0 by default)
  2467. * @param y defines the second component (0 by default)
  2468. * @param z defines the third component (0 by default)
  2469. * @param w defines the fourth component (1.0 by default)
  2470. */
  2471. constructor(
  2472. /** defines the first component (0 by default) */
  2473. x?: number,
  2474. /** defines the second component (0 by default) */
  2475. y?: number,
  2476. /** defines the third component (0 by default) */
  2477. z?: number,
  2478. /** defines the fourth component (1.0 by default) */
  2479. w?: number);
  2480. /**
  2481. * Gets a string representation for the current quaternion
  2482. * @returns a string with the Quaternion coordinates
  2483. */
  2484. toString(): string;
  2485. /**
  2486. * Gets the class name of the quaternion
  2487. * @returns the string "Quaternion"
  2488. */
  2489. getClassName(): string;
  2490. /**
  2491. * Gets a hash code for this quaternion
  2492. * @returns the quaternion hash code
  2493. */
  2494. getHashCode(): number;
  2495. /**
  2496. * Copy the quaternion to an array
  2497. * @returns a new array populated with 4 elements from the quaternion coordinates
  2498. */
  2499. asArray(): number[];
  2500. /**
  2501. * Check if two quaternions are equals
  2502. * @param otherQuaternion defines the second operand
  2503. * @return true if the current quaternion and the given one coordinates are strictly equals
  2504. */
  2505. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2506. /**
  2507. * Clone the current quaternion
  2508. * @returns a new quaternion copied from the current one
  2509. */
  2510. clone(): Quaternion;
  2511. /**
  2512. * Copy a quaternion to the current one
  2513. * @param other defines the other quaternion
  2514. * @returns the updated current quaternion
  2515. */
  2516. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2517. /**
  2518. * Updates the current quaternion with the given float coordinates
  2519. * @param x defines the x coordinate
  2520. * @param y defines the y coordinate
  2521. * @param z defines the z coordinate
  2522. * @param w defines the w coordinate
  2523. * @returns the updated current quaternion
  2524. */
  2525. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2526. /**
  2527. * Updates the current quaternion from the given float coordinates
  2528. * @param x defines the x coordinate
  2529. * @param y defines the y coordinate
  2530. * @param z defines the z coordinate
  2531. * @param w defines the w coordinate
  2532. * @returns the updated current quaternion
  2533. */
  2534. set(x: number, y: number, z: number, w: number): Quaternion;
  2535. /**
  2536. * Adds two quaternions
  2537. * @param other defines the second operand
  2538. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2539. */
  2540. add(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Add a quaternion to the current one
  2543. * @param other defines the quaternion to add
  2544. * @returns the current quaternion
  2545. */
  2546. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2547. /**
  2548. * Subtract two quaternions
  2549. * @param other defines the second operand
  2550. * @returns a new quaternion as the subtraction result of the given one from the current one
  2551. */
  2552. subtract(other: Quaternion): Quaternion;
  2553. /**
  2554. * Multiplies the current quaternion by a scale factor
  2555. * @param value defines the scale factor
  2556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2557. */
  2558. scale(value: number): Quaternion;
  2559. /**
  2560. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2561. * @param scale defines the scale factor
  2562. * @param result defines the Quaternion object where to store the result
  2563. * @returns the unmodified current quaternion
  2564. */
  2565. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2566. /**
  2567. * Multiplies in place the current quaternion by a scale factor
  2568. * @param value defines the scale factor
  2569. * @returns the current modified quaternion
  2570. */
  2571. scaleInPlace(value: number): Quaternion;
  2572. /**
  2573. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2574. * @param scale defines the scale factor
  2575. * @param result defines the Quaternion object where to store the result
  2576. * @returns the unmodified current quaternion
  2577. */
  2578. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2579. /**
  2580. * Multiplies two quaternions
  2581. * @param q1 defines the second operand
  2582. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2583. */
  2584. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2585. /**
  2586. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2587. * @param q1 defines the second operand
  2588. * @param result defines the target quaternion
  2589. * @returns the current quaternion
  2590. */
  2591. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2592. /**
  2593. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2594. * @param q1 defines the second operand
  2595. * @returns the currentupdated quaternion
  2596. */
  2597. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2598. /**
  2599. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2600. * @param ref defines the target quaternion
  2601. * @returns the current quaternion
  2602. */
  2603. conjugateToRef(ref: Quaternion): Quaternion;
  2604. /**
  2605. * Conjugates in place (1-q) the current quaternion
  2606. * @returns the current updated quaternion
  2607. */
  2608. conjugateInPlace(): Quaternion;
  2609. /**
  2610. * Conjugates in place (1-q) the current quaternion
  2611. * @returns a new quaternion
  2612. */
  2613. conjugate(): Quaternion;
  2614. /**
  2615. * Gets length of current quaternion
  2616. * @returns the quaternion length (float)
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Normalize in place the current quaternion
  2621. * @returns the current updated quaternion
  2622. */
  2623. normalize(): Quaternion;
  2624. /**
  2625. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2626. * @param order is a reserved parameter and is ignore for now
  2627. * @returns a new Vector3 containing the Euler angles
  2628. */
  2629. toEulerAngles(order?: string): Vector3;
  2630. /**
  2631. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2632. * @param result defines the vector which will be filled with the Euler angles
  2633. * @param order is a reserved parameter and is ignore for now
  2634. * @returns the current unchanged quaternion
  2635. */
  2636. toEulerAnglesToRef(result: Vector3): Quaternion;
  2637. /**
  2638. * Updates the given rotation matrix with the current quaternion values
  2639. * @param result defines the target matrix
  2640. * @returns the current unchanged quaternion
  2641. */
  2642. toRotationMatrix(result: Matrix): Quaternion;
  2643. /**
  2644. * Updates the current quaternion from the given rotation matrix values
  2645. * @param matrix defines the source matrix
  2646. * @returns the current updated quaternion
  2647. */
  2648. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2649. /**
  2650. * Creates a new quaternion from a rotation matrix
  2651. * @param matrix defines the source matrix
  2652. * @returns a new quaternion created from the given rotation matrix values
  2653. */
  2654. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2655. /**
  2656. * Updates the given quaternion with the given rotation matrix values
  2657. * @param matrix defines the source matrix
  2658. * @param result defines the target quaternion
  2659. */
  2660. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2661. /**
  2662. * Returns the dot product (float) between the quaternions "left" and "right"
  2663. * @param left defines the left operand
  2664. * @param right defines the right operand
  2665. * @returns the dot product
  2666. */
  2667. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2668. /**
  2669. * Checks if the two quaternions are close to each other
  2670. * @param quat0 defines the first quaternion to check
  2671. * @param quat1 defines the second quaternion to check
  2672. * @returns true if the two quaternions are close to each other
  2673. */
  2674. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2675. /**
  2676. * Creates an empty quaternion
  2677. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2678. */
  2679. static Zero(): Quaternion;
  2680. /**
  2681. * Inverse a given quaternion
  2682. * @param q defines the source quaternion
  2683. * @returns a new quaternion as the inverted current quaternion
  2684. */
  2685. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2686. /**
  2687. * Inverse a given quaternion
  2688. * @param q defines the source quaternion
  2689. * @param result the quaternion the result will be stored in
  2690. * @returns the result quaternion
  2691. */
  2692. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2693. /**
  2694. * Creates an identity quaternion
  2695. * @returns the identity quaternion
  2696. */
  2697. static Identity(): Quaternion;
  2698. /**
  2699. * Gets a boolean indicating if the given quaternion is identity
  2700. * @param quaternion defines the quaternion to check
  2701. * @returns true if the quaternion is identity
  2702. */
  2703. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2704. /**
  2705. * Creates a quaternion from a rotation around an axis
  2706. * @param axis defines the axis to use
  2707. * @param angle defines the angle to use
  2708. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2709. */
  2710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2711. /**
  2712. * Creates a rotation around an axis and stores it into the given quaternion
  2713. * @param axis defines the axis to use
  2714. * @param angle defines the angle to use
  2715. * @param result defines the target quaternion
  2716. * @returns the target quaternion
  2717. */
  2718. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2719. /**
  2720. * Creates a new quaternion from data stored into an array
  2721. * @param array defines the data source
  2722. * @param offset defines the offset in the source array where the data starts
  2723. * @returns a new quaternion
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2726. /**
  2727. * Create a quaternion from Euler rotation angles
  2728. * @param x Pitch
  2729. * @param y Yaw
  2730. * @param z Roll
  2731. * @returns the new Quaternion
  2732. */
  2733. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2734. /**
  2735. * Updates a quaternion from Euler rotation angles
  2736. * @param x Pitch
  2737. * @param y Yaw
  2738. * @param z Roll
  2739. * @param result the quaternion to store the result
  2740. * @returns the updated quaternion
  2741. */
  2742. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation vector
  2745. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2746. * @returns the new Quaternion
  2747. */
  2748. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2749. /**
  2750. * Updates a quaternion from Euler rotation vector
  2751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2752. * @param result the quaternion to store the result
  2753. * @returns the updated quaternion
  2754. */
  2755. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2756. /**
  2757. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2758. * @param yaw defines the rotation around Y axis
  2759. * @param pitch defines the rotation around X axis
  2760. * @param roll defines the rotation around Z axis
  2761. * @returns the new quaternion
  2762. */
  2763. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2764. /**
  2765. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2766. * @param yaw defines the rotation around Y axis
  2767. * @param pitch defines the rotation around X axis
  2768. * @param roll defines the rotation around Z axis
  2769. * @param result defines the target quaternion
  2770. */
  2771. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2772. /**
  2773. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2774. * @param alpha defines the rotation around first axis
  2775. * @param beta defines the rotation around second axis
  2776. * @param gamma defines the rotation around third axis
  2777. * @returns the new quaternion
  2778. */
  2779. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2782. * @param alpha defines the rotation around first axis
  2783. * @param beta defines the rotation around second axis
  2784. * @param gamma defines the rotation around third axis
  2785. * @param result defines the target quaternion
  2786. */
  2787. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2788. /**
  2789. * 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)
  2790. * @param axis1 defines the first axis
  2791. * @param axis2 defines the second axis
  2792. * @param axis3 defines the third axis
  2793. * @returns the new quaternion
  2794. */
  2795. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2796. /**
  2797. * 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
  2798. * @param axis1 defines the first axis
  2799. * @param axis2 defines the second axis
  2800. * @param axis3 defines the third axis
  2801. * @param ref defines the target quaternion
  2802. */
  2803. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2804. /**
  2805. * Interpolates between two quaternions
  2806. * @param left defines first quaternion
  2807. * @param right defines second quaternion
  2808. * @param amount defines the gradient to use
  2809. * @returns the new interpolated quaternion
  2810. */
  2811. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2812. /**
  2813. * Interpolates between two quaternions and stores it into a target quaternion
  2814. * @param left defines first quaternion
  2815. * @param right defines second quaternion
  2816. * @param amount defines the gradient to use
  2817. * @param result defines the target quaternion
  2818. */
  2819. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2820. /**
  2821. * Interpolate between two quaternions using Hermite interpolation
  2822. * @param value1 defines first quaternion
  2823. * @param tangent1 defines the incoming tangent
  2824. * @param value2 defines second quaternion
  2825. * @param tangent2 defines the outgoing tangent
  2826. * @param amount defines the target quaternion
  2827. * @returns the new interpolated quaternion
  2828. */
  2829. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2830. }
  2831. /**
  2832. * Class used to store matrix data (4x4)
  2833. */
  2834. export class Matrix {
  2835. private static _updateFlagSeed;
  2836. private static _identityReadOnly;
  2837. private _isIdentity;
  2838. private _isIdentityDirty;
  2839. private _isIdentity3x2;
  2840. private _isIdentity3x2Dirty;
  2841. /**
  2842. * Gets the update flag of the matrix which is an unique number for the matrix.
  2843. * It will be incremented every time the matrix data change.
  2844. * You can use it to speed the comparison between two versions of the same matrix.
  2845. */
  2846. updateFlag: number;
  2847. private readonly _m;
  2848. /**
  2849. * Gets the internal data of the matrix
  2850. */
  2851. readonly m: DeepImmutable<Float32Array>;
  2852. /** @hidden */
  2853. _markAsUpdated(): void;
  2854. /** @hidden */
  2855. private _updateIdentityStatus;
  2856. /**
  2857. * Creates an empty matrix (filled with zeros)
  2858. */
  2859. constructor();
  2860. /**
  2861. * Check if the current matrix is identity
  2862. * @returns true is the matrix is the identity matrix
  2863. */
  2864. isIdentity(): boolean;
  2865. /**
  2866. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2867. * @returns true is the matrix is the identity matrix
  2868. */
  2869. isIdentityAs3x2(): boolean;
  2870. /**
  2871. * Gets the determinant of the matrix
  2872. * @returns the matrix determinant
  2873. */
  2874. determinant(): number;
  2875. /**
  2876. * Returns the matrix as a Float32Array
  2877. * @returns the matrix underlying array
  2878. */
  2879. toArray(): DeepImmutable<Float32Array>;
  2880. /**
  2881. * Returns the matrix as a Float32Array
  2882. * @returns the matrix underlying array.
  2883. */
  2884. asArray(): DeepImmutable<Float32Array>;
  2885. /**
  2886. * Inverts the current matrix in place
  2887. * @returns the current inverted matrix
  2888. */
  2889. invert(): Matrix;
  2890. /**
  2891. * Sets all the matrix elements to zero
  2892. * @returns the current matrix
  2893. */
  2894. reset(): Matrix;
  2895. /**
  2896. * Adds the current matrix with a second one
  2897. * @param other defines the matrix to add
  2898. * @returns a new matrix as the addition of the current matrix and the given one
  2899. */
  2900. add(other: DeepImmutable<Matrix>): Matrix;
  2901. /**
  2902. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2903. * @param other defines the matrix to add
  2904. * @param result defines the target matrix
  2905. * @returns the current matrix
  2906. */
  2907. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2908. /**
  2909. * Adds in place the given matrix to the current matrix
  2910. * @param other defines the second operand
  2911. * @returns the current updated matrix
  2912. */
  2913. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2914. /**
  2915. * Sets the given matrix to the current inverted Matrix
  2916. * @param other defines the target matrix
  2917. * @returns the unmodified current matrix
  2918. */
  2919. invertToRef(other: Matrix): Matrix;
  2920. /**
  2921. * add a value at the specified position in the current Matrix
  2922. * @param index the index of the value within the matrix. between 0 and 15.
  2923. * @param value the value to be added
  2924. * @returns the current updated matrix
  2925. */
  2926. addAtIndex(index: number, value: number): Matrix;
  2927. /**
  2928. * mutiply the specified position in the current Matrix by a value
  2929. * @param index the index of the value within the matrix. between 0 and 15.
  2930. * @param value the value to be added
  2931. * @returns the current updated matrix
  2932. */
  2933. multiplyAtIndex(index: number, value: number): Matrix;
  2934. /**
  2935. * Inserts the translation vector (using 3 floats) in the current matrix
  2936. * @param x defines the 1st component of the translation
  2937. * @param y defines the 2nd component of the translation
  2938. * @param z defines the 3rd component of the translation
  2939. * @returns the current updated matrix
  2940. */
  2941. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2942. /**
  2943. * Inserts the translation vector in the current matrix
  2944. * @param vector3 defines the translation to insert
  2945. * @returns the current updated matrix
  2946. */
  2947. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2948. /**
  2949. * Gets the translation value of the current matrix
  2950. * @returns a new Vector3 as the extracted translation from the matrix
  2951. */
  2952. getTranslation(): Vector3;
  2953. /**
  2954. * Fill a Vector3 with the extracted translation from the matrix
  2955. * @param result defines the Vector3 where to store the translation
  2956. * @returns the current matrix
  2957. */
  2958. getTranslationToRef(result: Vector3): Matrix;
  2959. /**
  2960. * Remove rotation and scaling part from the matrix
  2961. * @returns the updated matrix
  2962. */
  2963. removeRotationAndScaling(): Matrix;
  2964. /**
  2965. * Multiply two matrices
  2966. * @param other defines the second operand
  2967. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2968. */
  2969. multiply(other: DeepImmutable<Matrix>): Matrix;
  2970. /**
  2971. * Copy the current matrix from the given one
  2972. * @param other defines the source matrix
  2973. * @returns the current updated matrix
  2974. */
  2975. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2976. /**
  2977. * Populates the given array from the starting index with the current matrix values
  2978. * @param array defines the target array
  2979. * @param offset defines the offset in the target array where to start storing values
  2980. * @returns the current matrix
  2981. */
  2982. copyToArray(array: Float32Array, offset?: number): Matrix;
  2983. /**
  2984. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2985. * @param other defines the second operand
  2986. * @param result defines the matrix where to store the multiplication
  2987. * @returns the current matrix
  2988. */
  2989. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2990. /**
  2991. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the array where to store the multiplication
  2994. * @param offset defines the offset in the target array where to start storing values
  2995. * @returns the current matrix
  2996. */
  2997. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2998. /**
  2999. * Check equality between this matrix and a second one
  3000. * @param value defines the second matrix to compare
  3001. * @returns true is the current matrix and the given one values are strictly equal
  3002. */
  3003. equals(value: DeepImmutable<Matrix>): boolean;
  3004. /**
  3005. * Clone the current matrix
  3006. * @returns a new matrix from the current matrix
  3007. */
  3008. clone(): Matrix;
  3009. /**
  3010. * Returns the name of the current matrix class
  3011. * @returns the string "Matrix"
  3012. */
  3013. getClassName(): string;
  3014. /**
  3015. * Gets the hash code of the current matrix
  3016. * @returns the hash code
  3017. */
  3018. getHashCode(): number;
  3019. /**
  3020. * Decomposes the current Matrix into a translation, rotation and scaling components
  3021. * @param scale defines the scale vector3 given as a reference to update
  3022. * @param rotation defines the rotation quaternion given as a reference to update
  3023. * @param translation defines the translation vector3 given as a reference to update
  3024. * @returns true if operation was successful
  3025. */
  3026. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3027. /**
  3028. * Gets specific row of the matrix
  3029. * @param index defines the number of the row to get
  3030. * @returns the index-th row of the current matrix as a new Vector4
  3031. */
  3032. getRow(index: number): Nullable<Vector4>;
  3033. /**
  3034. * Sets the index-th row of the current matrix to the vector4 values
  3035. * @param index defines the number of the row to set
  3036. * @param row defines the target vector4
  3037. * @returns the updated current matrix
  3038. */
  3039. setRow(index: number, row: Vector4): Matrix;
  3040. /**
  3041. * Compute the transpose of the matrix
  3042. * @returns the new transposed matrix
  3043. */
  3044. transpose(): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix and store it in a given matrix
  3047. * @param result defines the target matrix
  3048. * @returns the current matrix
  3049. */
  3050. transposeToRef(result: Matrix): Matrix;
  3051. /**
  3052. * Sets the index-th row of the current matrix with the given 4 x float values
  3053. * @param index defines the row index
  3054. * @param x defines the x component to set
  3055. * @param y defines the y component to set
  3056. * @param z defines the z component to set
  3057. * @param w defines the w component to set
  3058. * @returns the updated current matrix
  3059. */
  3060. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3061. /**
  3062. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3063. * @param scale defines the scale factor
  3064. * @returns a new matrix
  3065. */
  3066. scale(scale: number): Matrix;
  3067. /**
  3068. * Scale the current matrix values by a factor to a given result matrix
  3069. * @param scale defines the scale factor
  3070. * @param result defines the matrix to store the result
  3071. * @returns the current matrix
  3072. */
  3073. scaleToRef(scale: number, result: Matrix): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor and add the result to a given matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the Matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3083. * @param ref matrix to store the result
  3084. */
  3085. toNormalMatrix(ref: Matrix): void;
  3086. /**
  3087. * Gets only rotation part of the current matrix
  3088. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3089. */
  3090. getRotationMatrix(): Matrix;
  3091. /**
  3092. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3093. * @param result defines the target matrix to store data to
  3094. * @returns the current matrix
  3095. */
  3096. getRotationMatrixToRef(result: Matrix): Matrix;
  3097. /**
  3098. * Toggles model matrix from being right handed to left handed in place and vice versa
  3099. */
  3100. toggleModelMatrixHandInPlace(): void;
  3101. /**
  3102. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3103. */
  3104. toggleProjectionMatrixHandInPlace(): void;
  3105. /**
  3106. * Creates a matrix from an array
  3107. * @param array defines the source array
  3108. * @param offset defines an offset in the source array
  3109. * @returns a new Matrix set from the starting index of the given array
  3110. */
  3111. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3112. /**
  3113. * Copy the content of an array into a given matrix
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @param result defines the target matrix
  3117. */
  3118. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3119. /**
  3120. * Stores an array into a matrix after having multiplied each component by a given factor
  3121. * @param array defines the source array
  3122. * @param offset defines the offset in the source array
  3123. * @param scale defines the scaling factor
  3124. * @param result defines the target matrix
  3125. */
  3126. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3127. /**
  3128. * Gets an identity matrix that must not be updated
  3129. */
  3130. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3131. /**
  3132. * Stores a list of values (16) inside a given matrix
  3133. * @param initialM11 defines 1st value of 1st row
  3134. * @param initialM12 defines 2nd value of 1st row
  3135. * @param initialM13 defines 3rd value of 1st row
  3136. * @param initialM14 defines 4th value of 1st row
  3137. * @param initialM21 defines 1st value of 2nd row
  3138. * @param initialM22 defines 2nd value of 2nd row
  3139. * @param initialM23 defines 3rd value of 2nd row
  3140. * @param initialM24 defines 4th value of 2nd row
  3141. * @param initialM31 defines 1st value of 3rd row
  3142. * @param initialM32 defines 2nd value of 3rd row
  3143. * @param initialM33 defines 3rd value of 3rd row
  3144. * @param initialM34 defines 4th value of 3rd row
  3145. * @param initialM41 defines 1st value of 4th row
  3146. * @param initialM42 defines 2nd value of 4th row
  3147. * @param initialM43 defines 3rd value of 4th row
  3148. * @param initialM44 defines 4th value of 4th row
  3149. * @param result defines the target matrix
  3150. */
  3151. 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;
  3152. /**
  3153. * Creates new matrix from a list of values (16)
  3154. * @param initialM11 defines 1st value of 1st row
  3155. * @param initialM12 defines 2nd value of 1st row
  3156. * @param initialM13 defines 3rd value of 1st row
  3157. * @param initialM14 defines 4th value of 1st row
  3158. * @param initialM21 defines 1st value of 2nd row
  3159. * @param initialM22 defines 2nd value of 2nd row
  3160. * @param initialM23 defines 3rd value of 2nd row
  3161. * @param initialM24 defines 4th value of 2nd row
  3162. * @param initialM31 defines 1st value of 3rd row
  3163. * @param initialM32 defines 2nd value of 3rd row
  3164. * @param initialM33 defines 3rd value of 3rd row
  3165. * @param initialM34 defines 4th value of 3rd row
  3166. * @param initialM41 defines 1st value of 4th row
  3167. * @param initialM42 defines 2nd value of 4th row
  3168. * @param initialM43 defines 3rd value of 4th row
  3169. * @param initialM44 defines 4th value of 4th row
  3170. * @returns the new matrix
  3171. */
  3172. 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;
  3173. /**
  3174. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3175. * @param scale defines the scale vector3
  3176. * @param rotation defines the rotation quaternion
  3177. * @param translation defines the translation vector3
  3178. * @returns a new matrix
  3179. */
  3180. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3181. /**
  3182. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3183. * @param scale defines the scale vector3
  3184. * @param rotation defines the rotation quaternion
  3185. * @param translation defines the translation vector3
  3186. * @param result defines the target matrix
  3187. */
  3188. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3189. /**
  3190. * Creates a new identity matrix
  3191. * @returns a new identity matrix
  3192. */
  3193. static Identity(): Matrix;
  3194. /**
  3195. * Creates a new identity matrix and stores the result in a given matrix
  3196. * @param result defines the target matrix
  3197. */
  3198. static IdentityToRef(result: Matrix): void;
  3199. /**
  3200. * Creates a new zero matrix
  3201. * @returns a new zero matrix
  3202. */
  3203. static Zero(): Matrix;
  3204. /**
  3205. * Creates a new rotation matrix for "angle" radians around the X axis
  3206. * @param angle defines the angle (in radians) to use
  3207. * @return the new matrix
  3208. */
  3209. static RotationX(angle: number): Matrix;
  3210. /**
  3211. * Creates a new matrix as the invert of a given matrix
  3212. * @param source defines the source matrix
  3213. * @returns the new matrix
  3214. */
  3215. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3216. /**
  3217. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3218. * @param angle defines the angle (in radians) to use
  3219. * @param result defines the target matrix
  3220. */
  3221. static RotationXToRef(angle: number, result: Matrix): void;
  3222. /**
  3223. * Creates a new rotation matrix for "angle" radians around the Y axis
  3224. * @param angle defines the angle (in radians) to use
  3225. * @return the new matrix
  3226. */
  3227. static RotationY(angle: number): Matrix;
  3228. /**
  3229. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3230. * @param angle defines the angle (in radians) to use
  3231. * @param result defines the target matrix
  3232. */
  3233. static RotationYToRef(angle: number, result: Matrix): void;
  3234. /**
  3235. * Creates a new rotation matrix for "angle" radians around the Z axis
  3236. * @param angle defines the angle (in radians) to use
  3237. * @return the new matrix
  3238. */
  3239. static RotationZ(angle: number): Matrix;
  3240. /**
  3241. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3242. * @param angle defines the angle (in radians) to use
  3243. * @param result defines the target matrix
  3244. */
  3245. static RotationZToRef(angle: number, result: Matrix): void;
  3246. /**
  3247. * Creates a new rotation matrix for "angle" radians around the given axis
  3248. * @param axis defines the axis to use
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @param result defines the target matrix
  3258. */
  3259. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3260. /**
  3261. * Creates a rotation matrix
  3262. * @param yaw defines the yaw angle in radians (Y axis)
  3263. * @param pitch defines the pitch angle in radians (X axis)
  3264. * @param roll defines the roll angle in radians (X axis)
  3265. * @returns the new rotation matrix
  3266. */
  3267. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3268. /**
  3269. * Creates a rotation matrix and stores it in a given matrix
  3270. * @param yaw defines the yaw angle in radians (Y axis)
  3271. * @param pitch defines the pitch angle in radians (X axis)
  3272. * @param roll defines the roll angle in radians (X axis)
  3273. * @param result defines the target matrix
  3274. */
  3275. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3276. /**
  3277. * Creates a scaling matrix
  3278. * @param x defines the scale factor on X axis
  3279. * @param y defines the scale factor on Y axis
  3280. * @param z defines the scale factor on Z axis
  3281. * @returns the new matrix
  3282. */
  3283. static Scaling(x: number, y: number, z: number): Matrix;
  3284. /**
  3285. * Creates a scaling matrix and stores it in a given matrix
  3286. * @param x defines the scale factor on X axis
  3287. * @param y defines the scale factor on Y axis
  3288. * @param z defines the scale factor on Z axis
  3289. * @param result defines the target matrix
  3290. */
  3291. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3292. /**
  3293. * Creates a translation matrix
  3294. * @param x defines the translation on X axis
  3295. * @param y defines the translation on Y axis
  3296. * @param z defines the translationon Z axis
  3297. * @returns the new matrix
  3298. */
  3299. static Translation(x: number, y: number, z: number): Matrix;
  3300. /**
  3301. * Creates a translation matrix and stores it in a given matrix
  3302. * @param x defines the translation on X axis
  3303. * @param y defines the translation on Y axis
  3304. * @param z defines the translationon Z axis
  3305. * @param result defines the target matrix
  3306. */
  3307. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3308. /**
  3309. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3310. * @param startValue defines the start value
  3311. * @param endValue defines the end value
  3312. * @param gradient defines the gradient factor
  3313. * @returns the new matrix
  3314. */
  3315. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3316. /**
  3317. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3318. * @param startValue defines the start value
  3319. * @param endValue defines the end value
  3320. * @param gradient defines the gradient factor
  3321. * @param result defines the Matrix object where to store data
  3322. */
  3323. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3324. /**
  3325. * Builds a new matrix whose values are computed by:
  3326. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3327. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3328. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3329. * @param startValue defines the first matrix
  3330. * @param endValue defines the second matrix
  3331. * @param gradient defines the gradient between the two matrices
  3332. * @returns the new matrix
  3333. */
  3334. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3335. /**
  3336. * Update a matrix to values which are computed by:
  3337. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3338. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3339. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3340. * @param startValue defines the first matrix
  3341. * @param endValue defines the second matrix
  3342. * @param gradient defines the gradient between the two matrices
  3343. * @param result defines the target matrix
  3344. */
  3345. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3346. /**
  3347. * 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"
  3348. * This function works in left handed mode
  3349. * @param eye defines the final position of the entity
  3350. * @param target defines where the entity should look at
  3351. * @param up defines the up vector for the entity
  3352. * @returns the new matrix
  3353. */
  3354. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3355. /**
  3356. * 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".
  3357. * This function works in left handed mode
  3358. * @param eye defines the final position of the entity
  3359. * @param target defines where the entity should look at
  3360. * @param up defines the up vector for the entity
  3361. * @param result defines the target matrix
  3362. */
  3363. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3364. /**
  3365. * 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"
  3366. * This function works in right handed mode
  3367. * @param eye defines the final position of the entity
  3368. * @param target defines where the entity should look at
  3369. * @param up defines the up vector for the entity
  3370. * @returns the new matrix
  3371. */
  3372. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3373. /**
  3374. * 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".
  3375. * This function works in right handed mode
  3376. * @param eye defines the final position of the entity
  3377. * @param target defines where the entity should look at
  3378. * @param up defines the up vector for the entity
  3379. * @param result defines the target matrix
  3380. */
  3381. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3382. /**
  3383. * Create a left-handed orthographic projection matrix
  3384. * @param width defines the viewport width
  3385. * @param height defines the viewport height
  3386. * @param znear defines the near clip plane
  3387. * @param zfar defines the far clip plane
  3388. * @returns a new matrix as a left-handed orthographic projection matrix
  3389. */
  3390. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3391. /**
  3392. * Store a left-handed orthographic projection to a given matrix
  3393. * @param width defines the viewport width
  3394. * @param height defines the viewport height
  3395. * @param znear defines the near clip plane
  3396. * @param zfar defines the far clip plane
  3397. * @param result defines the target matrix
  3398. */
  3399. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3400. /**
  3401. * Create a left-handed orthographic projection matrix
  3402. * @param left defines the viewport left coordinate
  3403. * @param right defines the viewport right coordinate
  3404. * @param bottom defines the viewport bottom coordinate
  3405. * @param top defines the viewport top coordinate
  3406. * @param znear defines the near clip plane
  3407. * @param zfar defines the far clip plane
  3408. * @returns a new matrix as a left-handed orthographic projection matrix
  3409. */
  3410. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3411. /**
  3412. * Stores a left-handed orthographic projection into a given matrix
  3413. * @param left defines the viewport left coordinate
  3414. * @param right defines the viewport right coordinate
  3415. * @param bottom defines the viewport bottom coordinate
  3416. * @param top defines the viewport top coordinate
  3417. * @param znear defines the near clip plane
  3418. * @param zfar defines the far clip plane
  3419. * @param result defines the target matrix
  3420. */
  3421. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3422. /**
  3423. * Creates a right-handed orthographic projection matrix
  3424. * @param left defines the viewport left coordinate
  3425. * @param right defines the viewport right coordinate
  3426. * @param bottom defines the viewport bottom coordinate
  3427. * @param top defines the viewport top coordinate
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @returns a new matrix as a right-handed orthographic projection matrix
  3431. */
  3432. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3433. /**
  3434. * Stores a right-handed orthographic projection into a given matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. */
  3443. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3444. /**
  3445. * Creates a left-handed perspective projection matrix
  3446. * @param width defines the viewport width
  3447. * @param height defines the viewport height
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @returns a new matrix as a left-handed perspective projection matrix
  3451. */
  3452. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3453. /**
  3454. * Creates a left-handed perspective projection matrix
  3455. * @param fov defines the horizontal field of view
  3456. * @param aspect defines the aspect ratio
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @returns a new matrix as a left-handed perspective projection matrix
  3460. */
  3461. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3462. /**
  3463. * Stores a left-handed perspective projection into a given matrix
  3464. * @param fov defines the horizontal field of view
  3465. * @param aspect defines the aspect ratio
  3466. * @param znear defines the near clip plane
  3467. * @param zfar defines the far clip plane
  3468. * @param result defines the target matrix
  3469. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3470. */
  3471. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3472. /**
  3473. * Creates a right-handed perspective projection matrix
  3474. * @param fov defines the horizontal field of view
  3475. * @param aspect defines the aspect ratio
  3476. * @param znear defines the near clip plane
  3477. * @param zfar defines the far clip plane
  3478. * @returns a new matrix as a right-handed perspective projection matrix
  3479. */
  3480. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3481. /**
  3482. * Stores a right-handed perspective projection into a given matrix
  3483. * @param fov defines the horizontal field of view
  3484. * @param aspect defines the aspect ratio
  3485. * @param znear defines the near clip plane
  3486. * @param zfar defines the far clip plane
  3487. * @param result defines the target matrix
  3488. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3489. */
  3490. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3491. /**
  3492. * Stores a perspective projection for WebVR info a given matrix
  3493. * @param fov defines the field of view
  3494. * @param znear defines the near clip plane
  3495. * @param zfar defines the far clip plane
  3496. * @param result defines the target matrix
  3497. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3498. */
  3499. static PerspectiveFovWebVRToRef(fov: {
  3500. upDegrees: number;
  3501. downDegrees: number;
  3502. leftDegrees: number;
  3503. rightDegrees: number;
  3504. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3505. /**
  3506. * Computes a complete transformation matrix
  3507. * @param viewport defines the viewport to use
  3508. * @param world defines the world matrix
  3509. * @param view defines the view matrix
  3510. * @param projection defines the projection matrix
  3511. * @param zmin defines the near clip plane
  3512. * @param zmax defines the far clip plane
  3513. * @returns the transformation matrix
  3514. */
  3515. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3516. /**
  3517. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3518. * @param matrix defines the matrix to use
  3519. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3520. */
  3521. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3522. /**
  3523. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3524. * @param matrix defines the matrix to use
  3525. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3526. */
  3527. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3528. /**
  3529. * Compute the transpose of a given matrix
  3530. * @param matrix defines the matrix to transpose
  3531. * @returns the new matrix
  3532. */
  3533. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3534. /**
  3535. * Compute the transpose of a matrix and store it in a target matrix
  3536. * @param matrix defines the matrix to transpose
  3537. * @param result defines the target matrix
  3538. */
  3539. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3540. /**
  3541. * Computes a reflection matrix from a plane
  3542. * @param plane defines the reflection plane
  3543. * @returns a new matrix
  3544. */
  3545. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3546. /**
  3547. * Computes a reflection matrix from a plane
  3548. * @param plane defines the reflection plane
  3549. * @param result defines the target matrix
  3550. */
  3551. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3552. /**
  3553. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3554. * @param xaxis defines the value of the 1st axis
  3555. * @param yaxis defines the value of the 2nd axis
  3556. * @param zaxis defines the value of the 3rd axis
  3557. * @param result defines the target matrix
  3558. */
  3559. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3560. /**
  3561. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3562. * @param quat defines the quaternion to use
  3563. * @param result defines the target matrix
  3564. */
  3565. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3566. }
  3567. /**
  3568. * Represens a plane by the equation ax + by + cz + d = 0
  3569. */
  3570. export class Plane {
  3571. /**
  3572. * Normal of the plane (a,b,c)
  3573. */
  3574. normal: Vector3;
  3575. /**
  3576. * d component of the plane
  3577. */
  3578. d: number;
  3579. /**
  3580. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3581. * @param a a component of the plane
  3582. * @param b b component of the plane
  3583. * @param c c component of the plane
  3584. * @param d d component of the plane
  3585. */
  3586. constructor(a: number, b: number, c: number, d: number);
  3587. /**
  3588. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3589. */
  3590. asArray(): number[];
  3591. /**
  3592. * @returns a new plane copied from the current Plane.
  3593. */
  3594. clone(): Plane;
  3595. /**
  3596. * @returns the string "Plane".
  3597. */
  3598. getClassName(): string;
  3599. /**
  3600. * @returns the Plane hash code.
  3601. */
  3602. getHashCode(): number;
  3603. /**
  3604. * Normalize the current Plane in place.
  3605. * @returns the updated Plane.
  3606. */
  3607. normalize(): Plane;
  3608. /**
  3609. * Applies a transformation the plane and returns the result
  3610. * @param transformation the transformation matrix to be applied to the plane
  3611. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3612. */
  3613. transform(transformation: DeepImmutable<Matrix>): Plane;
  3614. /**
  3615. * Calcualtte the dot product between the point and the plane normal
  3616. * @param point point to calculate the dot product with
  3617. * @returns the dot product (float) of the point coordinates and the plane normal.
  3618. */
  3619. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3620. /**
  3621. * Updates the current Plane from the plane defined by the three given points.
  3622. * @param point1 one of the points used to contruct the plane
  3623. * @param point2 one of the points used to contruct the plane
  3624. * @param point3 one of the points used to contruct the plane
  3625. * @returns the updated Plane.
  3626. */
  3627. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3628. /**
  3629. * Checks if the plane is facing a given direction
  3630. * @param direction the direction to check if the plane is facing
  3631. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3632. * @returns True is the vector "direction" is the same side than the plane normal.
  3633. */
  3634. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3635. /**
  3636. * Calculates the distance to a point
  3637. * @param point point to calculate distance to
  3638. * @returns the signed distance (float) from the given point to the Plane.
  3639. */
  3640. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3641. /**
  3642. * Creates a plane from an array
  3643. * @param array the array to create a plane from
  3644. * @returns a new Plane from the given array.
  3645. */
  3646. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3647. /**
  3648. * Creates a plane from three points
  3649. * @param point1 point used to create the plane
  3650. * @param point2 point used to create the plane
  3651. * @param point3 point used to create the plane
  3652. * @returns a new Plane defined by the three given points.
  3653. */
  3654. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3655. /**
  3656. * Creates a plane from an origin point and a normal
  3657. * @param origin origin of the plane to be constructed
  3658. * @param normal normal of the plane to be constructed
  3659. * @returns a new Plane the normal vector to this plane at the given origin point.
  3660. * Note : the vector "normal" is updated because normalized.
  3661. */
  3662. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3663. /**
  3664. * Calculates the distance from a plane and a point
  3665. * @param origin origin of the plane to be constructed
  3666. * @param normal normal of the plane to be constructed
  3667. * @param point point to calculate distance to
  3668. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3669. */
  3670. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3671. }
  3672. /**
  3673. * Class used to represent a viewport on screen
  3674. */
  3675. export class Viewport {
  3676. /** viewport left coordinate */
  3677. x: number;
  3678. /** viewport top coordinate */
  3679. y: number;
  3680. /**viewport width */
  3681. width: number;
  3682. /** viewport height */
  3683. height: number;
  3684. /**
  3685. * Creates a Viewport object located at (x, y) and sized (width, height)
  3686. * @param x defines viewport left coordinate
  3687. * @param y defines viewport top coordinate
  3688. * @param width defines the viewport width
  3689. * @param height defines the viewport height
  3690. */
  3691. constructor(
  3692. /** viewport left coordinate */
  3693. x: number,
  3694. /** viewport top coordinate */
  3695. y: number,
  3696. /**viewport width */
  3697. width: number,
  3698. /** viewport height */
  3699. height: number);
  3700. /**
  3701. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3702. * @param renderWidth defines the rendering width
  3703. * @param renderHeight defines the rendering height
  3704. * @returns a new Viewport
  3705. */
  3706. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3707. /**
  3708. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3709. * @param renderWidth defines the rendering width
  3710. * @param renderHeight defines the rendering height
  3711. * @param ref defines the target viewport
  3712. * @returns the current viewport
  3713. */
  3714. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3715. /**
  3716. * Returns a new Viewport copied from the current one
  3717. * @returns a new Viewport
  3718. */
  3719. clone(): Viewport;
  3720. }
  3721. /**
  3722. * Reprasents a camera frustum
  3723. */
  3724. export class Frustum {
  3725. /**
  3726. * Gets the planes representing the frustum
  3727. * @param transform matrix to be applied to the returned planes
  3728. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3729. */
  3730. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3731. /**
  3732. * Gets the near frustum plane transformed by the transform matrix
  3733. * @param transform transformation matrix to be applied to the resulting frustum plane
  3734. * @param frustumPlane the resuling frustum plane
  3735. */
  3736. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3737. /**
  3738. * Gets the far frustum plane transformed by the transform matrix
  3739. * @param transform transformation matrix to be applied to the resulting frustum plane
  3740. * @param frustumPlane the resuling frustum plane
  3741. */
  3742. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3743. /**
  3744. * Gets the left frustum plane transformed by the transform matrix
  3745. * @param transform transformation matrix to be applied to the resulting frustum plane
  3746. * @param frustumPlane the resuling frustum plane
  3747. */
  3748. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3749. /**
  3750. * Gets the right frustum plane transformed by the transform matrix
  3751. * @param transform transformation matrix to be applied to the resulting frustum plane
  3752. * @param frustumPlane the resuling frustum plane
  3753. */
  3754. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3755. /**
  3756. * Gets the top frustum plane transformed by the transform matrix
  3757. * @param transform transformation matrix to be applied to the resulting frustum plane
  3758. * @param frustumPlane the resuling frustum plane
  3759. */
  3760. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3761. /**
  3762. * Gets the bottom frustum plane transformed by the transform matrix
  3763. * @param transform transformation matrix to be applied to the resulting frustum plane
  3764. * @param frustumPlane the resuling frustum plane
  3765. */
  3766. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3767. /**
  3768. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3769. * @param transform transformation matrix to be applied to the resulting frustum planes
  3770. * @param frustumPlanes the resuling frustum planes
  3771. */
  3772. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3773. }
  3774. /** Defines supported spaces */
  3775. export enum Space {
  3776. /** Local (object) space */
  3777. LOCAL = 0,
  3778. /** World space */
  3779. WORLD = 1,
  3780. /** Bone space */
  3781. BONE = 2
  3782. }
  3783. /** Defines the 3 main axes */
  3784. export class Axis {
  3785. /** X axis */
  3786. static X: Vector3;
  3787. /** Y axis */
  3788. static Y: Vector3;
  3789. /** Z axis */
  3790. static Z: Vector3;
  3791. }
  3792. /** Class used to represent a Bezier curve */
  3793. export class BezierCurve {
  3794. /**
  3795. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3796. * @param t defines the time
  3797. * @param x1 defines the left coordinate on X axis
  3798. * @param y1 defines the left coordinate on Y axis
  3799. * @param x2 defines the right coordinate on X axis
  3800. * @param y2 defines the right coordinate on Y axis
  3801. * @returns the interpolated value
  3802. */
  3803. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3804. }
  3805. /**
  3806. * Defines potential orientation for back face culling
  3807. */
  3808. export enum Orientation {
  3809. /**
  3810. * Clockwise
  3811. */
  3812. CW = 0,
  3813. /** Counter clockwise */
  3814. CCW = 1
  3815. }
  3816. /**
  3817. * Defines angle representation
  3818. */
  3819. export class Angle {
  3820. private _radians;
  3821. /**
  3822. * Creates an Angle object of "radians" radians (float).
  3823. * @param radians the angle in radians
  3824. */
  3825. constructor(radians: number);
  3826. /**
  3827. * Get value in degrees
  3828. * @returns the Angle value in degrees (float)
  3829. */
  3830. degrees(): number;
  3831. /**
  3832. * Get value in radians
  3833. * @returns the Angle value in radians (float)
  3834. */
  3835. radians(): number;
  3836. /**
  3837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3838. * @param a defines first vector
  3839. * @param b defines second vector
  3840. * @returns a new Angle
  3841. */
  3842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3843. /**
  3844. * Gets a new Angle object from the given float in radians
  3845. * @param radians defines the angle value in radians
  3846. * @returns a new Angle
  3847. */
  3848. static FromRadians(radians: number): Angle;
  3849. /**
  3850. * Gets a new Angle object from the given float in degrees
  3851. * @param degrees defines the angle value in degrees
  3852. * @returns a new Angle
  3853. */
  3854. static FromDegrees(degrees: number): Angle;
  3855. }
  3856. /**
  3857. * This represents an arc in a 2d space.
  3858. */
  3859. export class Arc2 {
  3860. /** Defines the start point of the arc */
  3861. startPoint: Vector2;
  3862. /** Defines the mid point of the arc */
  3863. midPoint: Vector2;
  3864. /** Defines the end point of the arc */
  3865. endPoint: Vector2;
  3866. /**
  3867. * Defines the center point of the arc.
  3868. */
  3869. centerPoint: Vector2;
  3870. /**
  3871. * Defines the radius of the arc.
  3872. */
  3873. radius: number;
  3874. /**
  3875. * Defines the angle of the arc (from mid point to end point).
  3876. */
  3877. angle: Angle;
  3878. /**
  3879. * Defines the start angle of the arc (from start point to middle point).
  3880. */
  3881. startAngle: Angle;
  3882. /**
  3883. * Defines the orientation of the arc (clock wise/counter clock wise).
  3884. */
  3885. orientation: Orientation;
  3886. /**
  3887. * Creates an Arc object from the three given points : start, middle and end.
  3888. * @param startPoint Defines the start point of the arc
  3889. * @param midPoint Defines the midlle point of the arc
  3890. * @param endPoint Defines the end point of the arc
  3891. */
  3892. constructor(
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2,
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2,
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2);
  3899. }
  3900. /**
  3901. * Represents a 2D path made up of multiple 2D points
  3902. */
  3903. export class Path2 {
  3904. private _points;
  3905. private _length;
  3906. /**
  3907. * If the path start and end point are the same
  3908. */
  3909. closed: boolean;
  3910. /**
  3911. * Creates a Path2 object from the starting 2D coordinates x and y.
  3912. * @param x the starting points x value
  3913. * @param y the starting points y value
  3914. */
  3915. constructor(x: number, y: number);
  3916. /**
  3917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3918. * @param x the added points x value
  3919. * @param y the added points y value
  3920. * @returns the updated Path2.
  3921. */
  3922. addLineTo(x: number, y: number): Path2;
  3923. /**
  3924. * 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.
  3925. * @param midX middle point x value
  3926. * @param midY middle point y value
  3927. * @param endX end point x value
  3928. * @param endY end point y value
  3929. * @param numberOfSegments (default: 36)
  3930. * @returns the updated Path2.
  3931. */
  3932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3933. /**
  3934. * Closes the Path2.
  3935. * @returns the Path2.
  3936. */
  3937. close(): Path2;
  3938. /**
  3939. * Gets the sum of the distance between each sequential point in the path
  3940. * @returns the Path2 total length (float).
  3941. */
  3942. length(): number;
  3943. /**
  3944. * Gets the points which construct the path
  3945. * @returns the Path2 internal array of points.
  3946. */
  3947. getPoints(): Vector2[];
  3948. /**
  3949. * Retreives the point at the distance aways from the starting point
  3950. * @param normalizedLengthPosition the length along the path to retreive the point from
  3951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3952. */
  3953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3954. /**
  3955. * Creates a new path starting from an x and y position
  3956. * @param x starting x value
  3957. * @param y starting y value
  3958. * @returns a new Path2 starting at the coordinates (x, y).
  3959. */
  3960. static StartingAt(x: number, y: number): Path2;
  3961. }
  3962. /**
  3963. * Represents a 3D path made up of multiple 3D points
  3964. */
  3965. export class Path3D {
  3966. /**
  3967. * an array of Vector3, the curve axis of the Path3D
  3968. */
  3969. path: Vector3[];
  3970. private _curve;
  3971. private _distances;
  3972. private _tangents;
  3973. private _normals;
  3974. private _binormals;
  3975. private _raw;
  3976. /**
  3977. * new Path3D(path, normal, raw)
  3978. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3979. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3980. * @param path an array of Vector3, the curve axis of the Path3D
  3981. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3982. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3983. */
  3984. constructor(
  3985. /**
  3986. * an array of Vector3, the curve axis of the Path3D
  3987. */
  3988. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3989. /**
  3990. * Returns the Path3D array of successive Vector3 designing its curve.
  3991. * @returns the Path3D array of successive Vector3 designing its curve.
  3992. */
  3993. getCurve(): Vector3[];
  3994. /**
  3995. * Returns an array populated with tangent vectors on each Path3D curve point.
  3996. * @returns an array populated with tangent vectors on each Path3D curve point.
  3997. */
  3998. getTangents(): Vector3[];
  3999. /**
  4000. * Returns an array populated with normal vectors on each Path3D curve point.
  4001. * @returns an array populated with normal vectors on each Path3D curve point.
  4002. */
  4003. getNormals(): Vector3[];
  4004. /**
  4005. * Returns an array populated with binormal vectors on each Path3D curve point.
  4006. * @returns an array populated with binormal vectors on each Path3D curve point.
  4007. */
  4008. getBinormals(): Vector3[];
  4009. /**
  4010. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4012. */
  4013. getDistances(): number[];
  4014. /**
  4015. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4016. * @param path path which all values are copied into the curves points
  4017. * @param firstNormal which should be projected onto the curve
  4018. * @returns the same object updated.
  4019. */
  4020. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4021. private _compute;
  4022. private _getFirstNonNullVector;
  4023. private _getLastNonNullVector;
  4024. private _normalVector;
  4025. }
  4026. /**
  4027. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4028. * A Curve3 is designed from a series of successive Vector3.
  4029. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4030. */
  4031. export class Curve3 {
  4032. private _points;
  4033. private _length;
  4034. /**
  4035. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4036. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4037. * @param v1 (Vector3) the control point
  4038. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4039. * @param nbPoints (integer) the wanted number of points in the curve
  4040. * @returns the created Curve3
  4041. */
  4042. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4043. /**
  4044. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4045. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4046. * @param v1 (Vector3) the first control point
  4047. * @param v2 (Vector3) the second control point
  4048. * @param v3 (Vector3) the end point of the Cubic Bezier
  4049. * @param nbPoints (integer) the wanted number of points in the curve
  4050. * @returns the created Curve3
  4051. */
  4052. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4053. /**
  4054. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4055. * @param p1 (Vector3) the origin point of the Hermite Spline
  4056. * @param t1 (Vector3) the tangent vector at the origin point
  4057. * @param p2 (Vector3) the end point of the Hermite Spline
  4058. * @param t2 (Vector3) the tangent vector at the end point
  4059. * @param nbPoints (integer) the wanted number of points in the curve
  4060. * @returns the created Curve3
  4061. */
  4062. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4063. /**
  4064. * Returns a Curve3 object along a CatmullRom Spline curve :
  4065. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4066. * @param nbPoints (integer) the wanted number of points between each curve control points
  4067. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4068. * @returns the created Curve3
  4069. */
  4070. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4071. /**
  4072. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4073. * A Curve3 is designed from a series of successive Vector3.
  4074. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4075. * @param points points which make up the curve
  4076. */
  4077. constructor(points: Vector3[]);
  4078. /**
  4079. * @returns the Curve3 stored array of successive Vector3
  4080. */
  4081. getPoints(): Vector3[];
  4082. /**
  4083. * @returns the computed length (float) of the curve.
  4084. */
  4085. length(): number;
  4086. /**
  4087. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4088. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4089. * curveA and curveB keep unchanged.
  4090. * @param curve the curve to continue from this curve
  4091. * @returns the newly constructed curve
  4092. */
  4093. continue(curve: DeepImmutable<Curve3>): Curve3;
  4094. private _computeLength;
  4095. }
  4096. /**
  4097. * Contains position and normal vectors for a vertex
  4098. */
  4099. export class PositionNormalVertex {
  4100. /** the position of the vertex (defaut: 0,0,0) */
  4101. position: Vector3;
  4102. /** the normal of the vertex (defaut: 0,1,0) */
  4103. normal: Vector3;
  4104. /**
  4105. * Creates a PositionNormalVertex
  4106. * @param position the position of the vertex (defaut: 0,0,0)
  4107. * @param normal the normal of the vertex (defaut: 0,1,0)
  4108. */
  4109. constructor(
  4110. /** the position of the vertex (defaut: 0,0,0) */
  4111. position?: Vector3,
  4112. /** the normal of the vertex (defaut: 0,1,0) */
  4113. normal?: Vector3);
  4114. /**
  4115. * Clones the PositionNormalVertex
  4116. * @returns the cloned PositionNormalVertex
  4117. */
  4118. clone(): PositionNormalVertex;
  4119. }
  4120. /**
  4121. * Contains position, normal and uv vectors for a vertex
  4122. */
  4123. export class PositionNormalTextureVertex {
  4124. /** the position of the vertex (defaut: 0,0,0) */
  4125. position: Vector3;
  4126. /** the normal of the vertex (defaut: 0,1,0) */
  4127. normal: Vector3;
  4128. /** the uv of the vertex (default: 0,0) */
  4129. uv: Vector2;
  4130. /**
  4131. * Creates a PositionNormalTextureVertex
  4132. * @param position the position of the vertex (defaut: 0,0,0)
  4133. * @param normal the normal of the vertex (defaut: 0,1,0)
  4134. * @param uv the uv of the vertex (default: 0,0)
  4135. */
  4136. constructor(
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position?: Vector3,
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal?: Vector3,
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv?: Vector2);
  4143. /**
  4144. * Clones the PositionNormalTextureVertex
  4145. * @returns the cloned PositionNormalTextureVertex
  4146. */
  4147. clone(): PositionNormalTextureVertex;
  4148. }
  4149. /**
  4150. * @hidden
  4151. */
  4152. export class Tmp {
  4153. static Color3: Color3[];
  4154. static Color4: Color4[];
  4155. static Vector2: Vector2[];
  4156. static Vector3: Vector3[];
  4157. static Vector4: Vector4[];
  4158. static Quaternion: Quaternion[];
  4159. static Matrix: Matrix[];
  4160. }
  4161. }
  4162. declare module "babylonjs/Offline/IOfflineProvider" {
  4163. /**
  4164. * Class used to enable access to offline support
  4165. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4166. */
  4167. export interface IOfflineProvider {
  4168. /**
  4169. * Gets a boolean indicating if scene must be saved in the database
  4170. */
  4171. enableSceneOffline: boolean;
  4172. /**
  4173. * Gets a boolean indicating if textures must be saved in the database
  4174. */
  4175. enableTexturesOffline: boolean;
  4176. /**
  4177. * Open the offline support and make it available
  4178. * @param successCallback defines the callback to call on success
  4179. * @param errorCallback defines the callback to call on error
  4180. */
  4181. open(successCallback: () => void, errorCallback: () => void): void;
  4182. /**
  4183. * Loads an image from the offline support
  4184. * @param url defines the url to load from
  4185. * @param image defines the target DOM image
  4186. */
  4187. loadImage(url: string, image: HTMLImageElement): void;
  4188. /**
  4189. * Loads a file from offline support
  4190. * @param url defines the URL to load from
  4191. * @param sceneLoaded defines a callback to call on success
  4192. * @param progressCallBack defines a callback to call when progress changed
  4193. * @param errorCallback defines a callback to call on error
  4194. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4195. */
  4196. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4197. }
  4198. }
  4199. declare module "babylonjs/Misc/observable" {
  4200. import { Nullable } from "babylonjs/types";
  4201. /**
  4202. * A class serves as a medium between the observable and its observers
  4203. */
  4204. export class EventState {
  4205. /**
  4206. * Create a new EventState
  4207. * @param mask defines the mask associated with this state
  4208. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4209. * @param target defines the original target of the state
  4210. * @param currentTarget defines the current target of the state
  4211. */
  4212. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4213. /**
  4214. * Initialize the current event state
  4215. * @param mask defines the mask associated with this state
  4216. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4217. * @param target defines the original target of the state
  4218. * @param currentTarget defines the current target of the state
  4219. * @returns the current event state
  4220. */
  4221. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4222. /**
  4223. * An Observer can set this property to true to prevent subsequent observers of being notified
  4224. */
  4225. skipNextObservers: boolean;
  4226. /**
  4227. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4228. */
  4229. mask: number;
  4230. /**
  4231. * The object that originally notified the event
  4232. */
  4233. target?: any;
  4234. /**
  4235. * The current object in the bubbling phase
  4236. */
  4237. currentTarget?: any;
  4238. /**
  4239. * This will be populated with the return value of the last function that was executed.
  4240. * If it is the first function in the callback chain it will be the event data.
  4241. */
  4242. lastReturnValue?: any;
  4243. }
  4244. /**
  4245. * Represent an Observer registered to a given Observable object.
  4246. */
  4247. export class Observer<T> {
  4248. /**
  4249. * Defines the callback to call when the observer is notified
  4250. */
  4251. callback: (eventData: T, eventState: EventState) => void;
  4252. /**
  4253. * Defines the mask of the observer (used to filter notifications)
  4254. */
  4255. mask: number;
  4256. /**
  4257. * Defines the current scope used to restore the JS context
  4258. */
  4259. scope: any;
  4260. /** @hidden */
  4261. _willBeUnregistered: boolean;
  4262. /**
  4263. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4264. */
  4265. unregisterOnNextCall: boolean;
  4266. /**
  4267. * Creates a new observer
  4268. * @param callback defines the callback to call when the observer is notified
  4269. * @param mask defines the mask of the observer (used to filter notifications)
  4270. * @param scope defines the current scope used to restore the JS context
  4271. */
  4272. constructor(
  4273. /**
  4274. * Defines the callback to call when the observer is notified
  4275. */
  4276. callback: (eventData: T, eventState: EventState) => void,
  4277. /**
  4278. * Defines the mask of the observer (used to filter notifications)
  4279. */
  4280. mask: number,
  4281. /**
  4282. * Defines the current scope used to restore the JS context
  4283. */
  4284. scope?: any);
  4285. }
  4286. /**
  4287. * Represent a list of observers registered to multiple Observables object.
  4288. */
  4289. export class MultiObserver<T> {
  4290. private _observers;
  4291. private _observables;
  4292. /**
  4293. * Release associated resources
  4294. */
  4295. dispose(): void;
  4296. /**
  4297. * Raise a callback when one of the observable will notify
  4298. * @param observables defines a list of observables to watch
  4299. * @param callback defines the callback to call on notification
  4300. * @param mask defines the mask used to filter notifications
  4301. * @param scope defines the current scope used to restore the JS context
  4302. * @returns the new MultiObserver
  4303. */
  4304. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4305. }
  4306. /**
  4307. * The Observable class is a simple implementation of the Observable pattern.
  4308. *
  4309. * 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.
  4310. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4311. * 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).
  4312. * 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.
  4313. */
  4314. export class Observable<T> {
  4315. private _observers;
  4316. private _eventState;
  4317. private _onObserverAdded;
  4318. /**
  4319. * Creates a new observable
  4320. * @param onObserverAdded defines a callback to call when a new observer is added
  4321. */
  4322. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4323. /**
  4324. * Create a new Observer with the specified callback
  4325. * @param callback the callback that will be executed for that Observer
  4326. * @param mask the mask used to filter observers
  4327. * @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.
  4328. * @param scope optional scope for the callback to be called from
  4329. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4330. * @returns the new observer created for the callback
  4331. */
  4332. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4333. /**
  4334. * Create a new Observer with the specified callback and unregisters after the next notification
  4335. * @param callback the callback that will be executed for that Observer
  4336. * @returns the new observer created for the callback
  4337. */
  4338. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4339. /**
  4340. * Remove an Observer from the Observable object
  4341. * @param observer the instance of the Observer to remove
  4342. * @returns false if it doesn't belong to this Observable
  4343. */
  4344. remove(observer: Nullable<Observer<T>>): boolean;
  4345. /**
  4346. * Remove a callback from the Observable object
  4347. * @param callback the callback to remove
  4348. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4349. * @returns false if it doesn't belong to this Observable
  4350. */
  4351. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4352. private _deferUnregister;
  4353. private _remove;
  4354. /**
  4355. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** 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 */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** 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 */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** 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 */
  4483. static readonly GEQUAL: number;
  4484. /** 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 */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * 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.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @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
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. 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);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** 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 */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Gets the URL used to load this texture
  6287. */
  6288. url: string;
  6289. /**
  6290. * Gets the sampling mode of the texture
  6291. */
  6292. samplingMode: number;
  6293. /**
  6294. * Gets a boolean indicating if the texture needs mipmaps generation
  6295. */
  6296. generateMipMaps: boolean;
  6297. /**
  6298. * Gets the number of samples used by the texture (WebGL2+ only)
  6299. */
  6300. samples: number;
  6301. /**
  6302. * Gets the type of the texture (int, float...)
  6303. */
  6304. type: number;
  6305. /**
  6306. * Gets the format of the texture (RGB, RGBA...)
  6307. */
  6308. format: number;
  6309. /**
  6310. * Observable called when the texture is loaded
  6311. */
  6312. onLoadedObservable: Observable<InternalTexture>;
  6313. /**
  6314. * Gets the width of the texture
  6315. */
  6316. width: number;
  6317. /**
  6318. * Gets the height of the texture
  6319. */
  6320. height: number;
  6321. /**
  6322. * Gets the depth of the texture
  6323. */
  6324. depth: number;
  6325. /**
  6326. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6327. */
  6328. baseWidth: number;
  6329. /**
  6330. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseHeight: number;
  6333. /**
  6334. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseDepth: number;
  6337. /**
  6338. * Gets a boolean indicating if the texture is inverted on Y axis
  6339. */
  6340. invertY: boolean;
  6341. /**
  6342. * Gets or set the previous tracker in the list
  6343. */
  6344. previous: Nullable<IInternalTextureTracker>;
  6345. /**
  6346. * Gets or set the next tracker in the list
  6347. */
  6348. next: Nullable<IInternalTextureTracker>;
  6349. /** @hidden */
  6350. _invertVScale: boolean;
  6351. /** @hidden */
  6352. _initialSlot: number;
  6353. /** @hidden */
  6354. _designatedSlot: number;
  6355. /** @hidden */
  6356. _dataSource: number;
  6357. /** @hidden */
  6358. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6359. /** @hidden */
  6360. _bufferView: Nullable<ArrayBufferView>;
  6361. /** @hidden */
  6362. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6363. /** @hidden */
  6364. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6365. /** @hidden */
  6366. _size: number;
  6367. /** @hidden */
  6368. _extension: string;
  6369. /** @hidden */
  6370. _files: Nullable<string[]>;
  6371. /** @hidden */
  6372. _workingCanvas: HTMLCanvasElement;
  6373. /** @hidden */
  6374. _workingContext: CanvasRenderingContext2D;
  6375. /** @hidden */
  6376. _framebuffer: Nullable<WebGLFramebuffer>;
  6377. /** @hidden */
  6378. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6379. /** @hidden */
  6380. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _attachments: Nullable<number[]>;
  6385. /** @hidden */
  6386. _cachedCoordinatesMode: Nullable<number>;
  6387. /** @hidden */
  6388. _cachedWrapU: Nullable<number>;
  6389. /** @hidden */
  6390. _cachedWrapV: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapR: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6395. /** @hidden */
  6396. _isDisabled: boolean;
  6397. /** @hidden */
  6398. _compression: Nullable<string>;
  6399. /** @hidden */
  6400. _generateStencilBuffer: boolean;
  6401. /** @hidden */
  6402. _generateDepthBuffer: boolean;
  6403. /** @hidden */
  6404. _comparisonFunction: number;
  6405. /** @hidden */
  6406. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6407. /** @hidden */
  6408. _lodGenerationScale: number;
  6409. /** @hidden */
  6410. _lodGenerationOffset: number;
  6411. /** @hidden */
  6412. _lodTextureHigh: BaseTexture;
  6413. /** @hidden */
  6414. _lodTextureMid: BaseTexture;
  6415. /** @hidden */
  6416. _lodTextureLow: BaseTexture;
  6417. /** @hidden */
  6418. _isRGBD: boolean;
  6419. /** @hidden */
  6420. _webGLTexture: Nullable<WebGLTexture>;
  6421. /** @hidden */
  6422. _references: number;
  6423. private _engine;
  6424. /**
  6425. * Gets the Engine the texture belongs to.
  6426. * @returns The babylon engine
  6427. */
  6428. getEngine(): Engine;
  6429. /**
  6430. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6431. */
  6432. readonly dataSource: number;
  6433. /**
  6434. * Creates a new InternalTexture
  6435. * @param engine defines the engine to use
  6436. * @param dataSource defines the type of data that will be used
  6437. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6438. */
  6439. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6440. /**
  6441. * Increments the number of references (ie. the number of Texture that point to it)
  6442. */
  6443. incrementReferences(): void;
  6444. /**
  6445. * Change the size of the texture (not the size of the content)
  6446. * @param width defines the new width
  6447. * @param height defines the new height
  6448. * @param depth defines the new depth (1 by default)
  6449. */
  6450. updateSize(width: int, height: int, depth?: int): void;
  6451. /** @hidden */
  6452. _rebuild(): void;
  6453. /** @hidden */
  6454. _swapAndDie(target: InternalTexture): void;
  6455. /**
  6456. * Dispose the current allocated resources
  6457. */
  6458. dispose(): void;
  6459. }
  6460. }
  6461. declare module "babylonjs/Animations/easing" {
  6462. /**
  6463. * This represents the main contract an easing function should follow.
  6464. * Easing functions are used throughout the animation system.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export interface IEasingFunction {
  6468. /**
  6469. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6470. * of the easing function.
  6471. * The link below provides some of the most common examples of easing functions.
  6472. * @see https://easings.net/
  6473. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6474. * @returns the corresponding value on the curve defined by the easing function
  6475. */
  6476. ease(gradient: number): number;
  6477. }
  6478. /**
  6479. * Base class used for every default easing function.
  6480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6481. */
  6482. export class EasingFunction implements IEasingFunction {
  6483. /**
  6484. * Interpolation follows the mathematical formula associated with the easing function.
  6485. */
  6486. static readonly EASINGMODE_EASEIN: number;
  6487. /**
  6488. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6489. */
  6490. static readonly EASINGMODE_EASEOUT: number;
  6491. /**
  6492. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6493. */
  6494. static readonly EASINGMODE_EASEINOUT: number;
  6495. private _easingMode;
  6496. /**
  6497. * Sets the easing mode of the current function.
  6498. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6499. */
  6500. setEasingMode(easingMode: number): void;
  6501. /**
  6502. * Gets the current easing mode.
  6503. * @returns the easing mode
  6504. */
  6505. getEasingMode(): number;
  6506. /**
  6507. * @hidden
  6508. */
  6509. easeInCore(gradient: number): number;
  6510. /**
  6511. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6512. * of the easing function.
  6513. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6514. * @returns the corresponding value on the curve defined by the easing function
  6515. */
  6516. ease(gradient: number): number;
  6517. }
  6518. /**
  6519. * Easing function with a circle shape (see link below).
  6520. * @see https://easings.net/#easeInCirc
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class CircleEase extends EasingFunction implements IEasingFunction {
  6524. /** @hidden */
  6525. easeInCore(gradient: number): number;
  6526. }
  6527. /**
  6528. * Easing function with a ease back shape (see link below).
  6529. * @see https://easings.net/#easeInBack
  6530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6531. */
  6532. export class BackEase extends EasingFunction implements IEasingFunction {
  6533. /** Defines the amplitude of the function */
  6534. amplitude: number;
  6535. /**
  6536. * Instantiates a back ease easing
  6537. * @see https://easings.net/#easeInBack
  6538. * @param amplitude Defines the amplitude of the function
  6539. */
  6540. constructor(
  6541. /** Defines the amplitude of the function */
  6542. amplitude?: number);
  6543. /** @hidden */
  6544. easeInCore(gradient: number): number;
  6545. }
  6546. /**
  6547. * Easing function with a bouncing shape (see link below).
  6548. * @see https://easings.net/#easeInBounce
  6549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6550. */
  6551. export class BounceEase extends EasingFunction implements IEasingFunction {
  6552. /** Defines the number of bounces */
  6553. bounces: number;
  6554. /** Defines the amplitude of the bounce */
  6555. bounciness: number;
  6556. /**
  6557. * Instantiates a bounce easing
  6558. * @see https://easings.net/#easeInBounce
  6559. * @param bounces Defines the number of bounces
  6560. * @param bounciness Defines the amplitude of the bounce
  6561. */
  6562. constructor(
  6563. /** Defines the number of bounces */
  6564. bounces?: number,
  6565. /** Defines the amplitude of the bounce */
  6566. bounciness?: number);
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a power of 3 shape (see link below).
  6572. * @see https://easings.net/#easeInCubic
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class CubicEase extends EasingFunction implements IEasingFunction {
  6576. /** @hidden */
  6577. easeInCore(gradient: number): number;
  6578. }
  6579. /**
  6580. * Easing function with an elastic shape (see link below).
  6581. * @see https://easings.net/#easeInElastic
  6582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6583. */
  6584. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6585. /** Defines the number of oscillations*/
  6586. oscillations: number;
  6587. /** Defines the amplitude of the oscillations*/
  6588. springiness: number;
  6589. /**
  6590. * Instantiates an elastic easing function
  6591. * @see https://easings.net/#easeInElastic
  6592. * @param oscillations Defines the number of oscillations
  6593. * @param springiness Defines the amplitude of the oscillations
  6594. */
  6595. constructor(
  6596. /** Defines the number of oscillations*/
  6597. oscillations?: number,
  6598. /** Defines the amplitude of the oscillations*/
  6599. springiness?: number);
  6600. /** @hidden */
  6601. easeInCore(gradient: number): number;
  6602. }
  6603. /**
  6604. * Easing function with an exponential shape (see link below).
  6605. * @see https://easings.net/#easeInExpo
  6606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6607. */
  6608. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6609. /** Defines the exponent of the function */
  6610. exponent: number;
  6611. /**
  6612. * Instantiates an exponential easing function
  6613. * @see https://easings.net/#easeInExpo
  6614. * @param exponent Defines the exponent of the function
  6615. */
  6616. constructor(
  6617. /** Defines the exponent of the function */
  6618. exponent?: number);
  6619. /** @hidden */
  6620. easeInCore(gradient: number): number;
  6621. }
  6622. /**
  6623. * Easing function with a power shape (see link below).
  6624. * @see https://easings.net/#easeInQuad
  6625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6626. */
  6627. export class PowerEase extends EasingFunction implements IEasingFunction {
  6628. /** Defines the power of the function */
  6629. power: number;
  6630. /**
  6631. * Instantiates an power base easing function
  6632. * @see https://easings.net/#easeInQuad
  6633. * @param power Defines the power of the function
  6634. */
  6635. constructor(
  6636. /** Defines the power of the function */
  6637. power?: number);
  6638. /** @hidden */
  6639. easeInCore(gradient: number): number;
  6640. }
  6641. /**
  6642. * Easing function with a power of 2 shape (see link below).
  6643. * @see https://easings.net/#easeInQuad
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. /**
  6651. * Easing function with a power of 4 shape (see link below).
  6652. * @see https://easings.net/#easeInQuart
  6653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6654. */
  6655. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6656. /** @hidden */
  6657. easeInCore(gradient: number): number;
  6658. }
  6659. /**
  6660. * Easing function with a power of 5 shape (see link below).
  6661. * @see https://easings.net/#easeInQuint
  6662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6663. */
  6664. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6665. /** @hidden */
  6666. easeInCore(gradient: number): number;
  6667. }
  6668. /**
  6669. * Easing function with a sin shape (see link below).
  6670. * @see https://easings.net/#easeInSine
  6671. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6672. */
  6673. export class SineEase extends EasingFunction implements IEasingFunction {
  6674. /** @hidden */
  6675. easeInCore(gradient: number): number;
  6676. }
  6677. /**
  6678. * Easing function with a bezier shape (see link below).
  6679. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6681. */
  6682. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6683. /** Defines the x component of the start tangent in the bezier curve */
  6684. x1: number;
  6685. /** Defines the y component of the start tangent in the bezier curve */
  6686. y1: number;
  6687. /** Defines the x component of the end tangent in the bezier curve */
  6688. x2: number;
  6689. /** Defines the y component of the end tangent in the bezier curve */
  6690. y2: number;
  6691. /**
  6692. * Instantiates a bezier function
  6693. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6694. * @param x1 Defines the x component of the start tangent in the bezier curve
  6695. * @param y1 Defines the y component of the start tangent in the bezier curve
  6696. * @param x2 Defines the x component of the end tangent in the bezier curve
  6697. * @param y2 Defines the y component of the end tangent in the bezier curve
  6698. */
  6699. constructor(
  6700. /** Defines the x component of the start tangent in the bezier curve */
  6701. x1?: number,
  6702. /** Defines the y component of the start tangent in the bezier curve */
  6703. y1?: number,
  6704. /** Defines the x component of the end tangent in the bezier curve */
  6705. x2?: number,
  6706. /** Defines the y component of the end tangent in the bezier curve */
  6707. y2?: number);
  6708. /** @hidden */
  6709. easeInCore(gradient: number): number;
  6710. }
  6711. }
  6712. declare module "babylonjs/Animations/animationKey" {
  6713. /**
  6714. * Defines an interface which represents an animation key frame
  6715. */
  6716. export interface IAnimationKey {
  6717. /**
  6718. * Frame of the key frame
  6719. */
  6720. frame: number;
  6721. /**
  6722. * Value at the specifies key frame
  6723. */
  6724. value: any;
  6725. /**
  6726. * The input tangent for the cubic hermite spline
  6727. */
  6728. inTangent?: any;
  6729. /**
  6730. * The output tangent for the cubic hermite spline
  6731. */
  6732. outTangent?: any;
  6733. /**
  6734. * The animation interpolation type
  6735. */
  6736. interpolation?: AnimationKeyInterpolation;
  6737. }
  6738. /**
  6739. * Enum for the animation key frame interpolation type
  6740. */
  6741. export enum AnimationKeyInterpolation {
  6742. /**
  6743. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6744. */
  6745. STEP = 1
  6746. }
  6747. }
  6748. declare module "babylonjs/Animations/animationRange" {
  6749. /**
  6750. * Represents the range of an animation
  6751. */
  6752. export class AnimationRange {
  6753. /**The name of the animation range**/
  6754. name: string;
  6755. /**The starting frame of the animation */
  6756. from: number;
  6757. /**The ending frame of the animation*/
  6758. to: number;
  6759. /**
  6760. * Initializes the range of an animation
  6761. * @param name The name of the animation range
  6762. * @param from The starting frame of the animation
  6763. * @param to The ending frame of the animation
  6764. */
  6765. constructor(
  6766. /**The name of the animation range**/
  6767. name: string,
  6768. /**The starting frame of the animation */
  6769. from: number,
  6770. /**The ending frame of the animation*/
  6771. to: number);
  6772. /**
  6773. * Makes a copy of the animation range
  6774. * @returns A copy of the animation range
  6775. */
  6776. clone(): AnimationRange;
  6777. }
  6778. }
  6779. declare module "babylonjs/Animations/animationEvent" {
  6780. /**
  6781. * Composed of a frame, and an action function
  6782. */
  6783. export class AnimationEvent {
  6784. /** The frame for which the event is triggered **/
  6785. frame: number;
  6786. /** The event to perform when triggered **/
  6787. action: (currentFrame: number) => void;
  6788. /** Specifies if the event should be triggered only once**/
  6789. onlyOnce?: boolean | undefined;
  6790. /**
  6791. * Specifies if the animation event is done
  6792. */
  6793. isDone: boolean;
  6794. /**
  6795. * Initializes the animation event
  6796. * @param frame The frame for which the event is triggered
  6797. * @param action The event to perform when triggered
  6798. * @param onlyOnce Specifies if the event should be triggered only once
  6799. */
  6800. constructor(
  6801. /** The frame for which the event is triggered **/
  6802. frame: number,
  6803. /** The event to perform when triggered **/
  6804. action: (currentFrame: number) => void,
  6805. /** Specifies if the event should be triggered only once**/
  6806. onlyOnce?: boolean | undefined);
  6807. /** @hidden */
  6808. _clone(): AnimationEvent;
  6809. }
  6810. }
  6811. declare module "babylonjs/Behaviors/behavior" {
  6812. import { Nullable } from "babylonjs/types";
  6813. /**
  6814. * Interface used to define a behavior
  6815. */
  6816. export interface Behavior<T> {
  6817. /** gets or sets behavior's name */
  6818. name: string;
  6819. /**
  6820. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6821. */
  6822. init(): void;
  6823. /**
  6824. * Called when the behavior is attached to a target
  6825. * @param target defines the target where the behavior is attached to
  6826. */
  6827. attach(target: T): void;
  6828. /**
  6829. * Called when the behavior is detached from its target
  6830. */
  6831. detach(): void;
  6832. }
  6833. /**
  6834. * Interface implemented by classes supporting behaviors
  6835. */
  6836. export interface IBehaviorAware<T> {
  6837. /**
  6838. * Attach a behavior
  6839. * @param behavior defines the behavior to attach
  6840. * @returns the current host
  6841. */
  6842. addBehavior(behavior: Behavior<T>): T;
  6843. /**
  6844. * Remove a behavior from the current object
  6845. * @param behavior defines the behavior to detach
  6846. * @returns the current host
  6847. */
  6848. removeBehavior(behavior: Behavior<T>): T;
  6849. /**
  6850. * Gets a behavior using its name to search
  6851. * @param name defines the name to search
  6852. * @returns the behavior or null if not found
  6853. */
  6854. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6855. }
  6856. }
  6857. declare module "babylonjs/Collisions/intersectionInfo" {
  6858. import { Nullable } from "babylonjs/types";
  6859. /**
  6860. * @hidden
  6861. */
  6862. export class IntersectionInfo {
  6863. bu: Nullable<number>;
  6864. bv: Nullable<number>;
  6865. distance: number;
  6866. faceId: number;
  6867. subMeshId: number;
  6868. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6869. }
  6870. }
  6871. declare module "babylonjs/Culling/boundingSphere" {
  6872. import { DeepImmutable } from "babylonjs/types";
  6873. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6874. /**
  6875. * Class used to store bounding sphere information
  6876. */
  6877. export class BoundingSphere {
  6878. /**
  6879. * Gets the center of the bounding sphere in local space
  6880. */
  6881. readonly center: Vector3;
  6882. /**
  6883. * Radius of the bounding sphere in local space
  6884. */
  6885. radius: number;
  6886. /**
  6887. * Gets the center of the bounding sphere in world space
  6888. */
  6889. readonly centerWorld: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in world space
  6892. */
  6893. radiusWorld: number;
  6894. /**
  6895. * Gets the minimum vector in local space
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * Gets the maximum vector in local space
  6900. */
  6901. readonly maximum: Vector3;
  6902. private _worldMatrix;
  6903. private static readonly TmpVector3;
  6904. /**
  6905. * Creates a new bounding sphere
  6906. * @param min defines the minimum vector (in local space)
  6907. * @param max defines the maximum vector (in local space)
  6908. * @param worldMatrix defines the new world matrix
  6909. */
  6910. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6911. /**
  6912. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6913. * @param min defines the new minimum vector (in local space)
  6914. * @param max defines the new maximum vector (in local space)
  6915. * @param worldMatrix defines the new world matrix
  6916. */
  6917. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6918. /**
  6919. * Scale the current bounding sphere by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding box
  6922. */
  6923. scale(factor: number): BoundingSphere;
  6924. /**
  6925. * Gets the world matrix of the bounding box
  6926. * @returns a matrix
  6927. */
  6928. getWorldMatrix(): DeepImmutable<Matrix>;
  6929. /** @hidden */
  6930. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Tests if the bounding sphere is intersecting the frustum planes
  6933. * @param frustumPlanes defines the frustum planes to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6937. /**
  6938. * Tests if the bounding sphere center is in between the frustum planes.
  6939. * Used for optimistic fast inclusion.
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if the sphere center is in between the frustum planes
  6942. */
  6943. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding sphere
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding sphere
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Checks if two sphere intersct
  6952. * @param sphere0 sphere 0
  6953. * @param sphere1 sphere 1
  6954. * @returns true if the speres intersect
  6955. */
  6956. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6957. }
  6958. }
  6959. declare module "babylonjs/Culling/boundingBox" {
  6960. import { DeepImmutable } from "babylonjs/types";
  6961. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6962. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6963. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6964. /**
  6965. * Class used to store bounding box information
  6966. */
  6967. export class BoundingBox implements ICullable {
  6968. /**
  6969. * Gets the 8 vectors representing the bounding box in local space
  6970. */
  6971. readonly vectors: Vector3[];
  6972. /**
  6973. * Gets the center of the bounding box in local space
  6974. */
  6975. readonly center: Vector3;
  6976. /**
  6977. * Gets the center of the bounding box in world space
  6978. */
  6979. readonly centerWorld: Vector3;
  6980. /**
  6981. * Gets the extend size in local space
  6982. */
  6983. readonly extendSize: Vector3;
  6984. /**
  6985. * Gets the extend size in world space
  6986. */
  6987. readonly extendSizeWorld: Vector3;
  6988. /**
  6989. * Gets the OBB (object bounding box) directions
  6990. */
  6991. readonly directions: Vector3[];
  6992. /**
  6993. * Gets the 8 vectors representing the bounding box in world space
  6994. */
  6995. readonly vectorsWorld: Vector3[];
  6996. /**
  6997. * Gets the minimum vector in world space
  6998. */
  6999. readonly minimumWorld: Vector3;
  7000. /**
  7001. * Gets the maximum vector in world space
  7002. */
  7003. readonly maximumWorld: Vector3;
  7004. /**
  7005. * Gets the minimum vector in local space
  7006. */
  7007. readonly minimum: Vector3;
  7008. /**
  7009. * Gets the maximum vector in local space
  7010. */
  7011. readonly maximum: Vector3;
  7012. private _worldMatrix;
  7013. private static readonly TmpVector3;
  7014. /**
  7015. * @hidden
  7016. */
  7017. _tag: number;
  7018. /**
  7019. * Creates a new bounding box
  7020. * @param min defines the minimum vector (in local space)
  7021. * @param max defines the maximum vector (in local space)
  7022. * @param worldMatrix defines the new world matrix
  7023. */
  7024. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7025. /**
  7026. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7027. * @param min defines the new minimum vector (in local space)
  7028. * @param max defines the new maximum vector (in local space)
  7029. * @param worldMatrix defines the new world matrix
  7030. */
  7031. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7032. /**
  7033. * Scale the current bounding box by applying a scale factor
  7034. * @param factor defines the scale factor to apply
  7035. * @returns the current bounding box
  7036. */
  7037. scale(factor: number): BoundingBox;
  7038. /**
  7039. * Gets the world matrix of the bounding box
  7040. * @returns a matrix
  7041. */
  7042. getWorldMatrix(): DeepImmutable<Matrix>;
  7043. /** @hidden */
  7044. _update(world: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * Tests if the bounding box is intersecting the frustum planes
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @returns true if there is an intersection
  7049. */
  7050. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. /**
  7052. * Tests if the bounding box is entirely inside the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an inclusion
  7055. */
  7056. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if a point is inside the bounding box
  7059. * @param point defines the point to test
  7060. * @returns true if the point is inside the bounding box
  7061. */
  7062. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7063. /**
  7064. * Tests if the bounding box intersects with a bounding sphere
  7065. * @param sphere defines the sphere to test
  7066. * @returns true if there is an intersection
  7067. */
  7068. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7071. * @param min defines the min vector to use
  7072. * @param max defines the max vector to use
  7073. * @returns true if there is an intersection
  7074. */
  7075. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7076. /**
  7077. * Tests if two bounding boxes are intersections
  7078. * @param box0 defines the first box to test
  7079. * @param box1 defines the second box to test
  7080. * @returns true if there is an intersection
  7081. */
  7082. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7083. /**
  7084. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7085. * @param minPoint defines the minimum vector of the bounding box
  7086. * @param maxPoint defines the maximum vector of the bounding box
  7087. * @param sphereCenter defines the sphere center
  7088. * @param sphereRadius defines the sphere radius
  7089. * @returns true if there is an intersection
  7090. */
  7091. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7092. /**
  7093. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7094. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @return true if there is an inclusion
  7097. */
  7098. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. /**
  7100. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7101. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @return true if there is an intersection
  7104. */
  7105. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. }
  7107. }
  7108. declare module "babylonjs/Collisions/collider" {
  7109. import { Nullable, IndicesArray } from "babylonjs/types";
  7110. import { Vector3, Plane } from "babylonjs/Maths/math";
  7111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7112. /** @hidden */
  7113. export class Collider {
  7114. /** Define if a collision was found */
  7115. collisionFound: boolean;
  7116. /**
  7117. * Define last intersection point in local space
  7118. */
  7119. intersectionPoint: Vector3;
  7120. /**
  7121. * Define last collided mesh
  7122. */
  7123. collidedMesh: Nullable<AbstractMesh>;
  7124. private _collisionPoint;
  7125. private _planeIntersectionPoint;
  7126. private _tempVector;
  7127. private _tempVector2;
  7128. private _tempVector3;
  7129. private _tempVector4;
  7130. private _edge;
  7131. private _baseToVertex;
  7132. private _destinationPoint;
  7133. private _slidePlaneNormal;
  7134. private _displacementVector;
  7135. /** @hidden */
  7136. _radius: Vector3;
  7137. /** @hidden */
  7138. _retry: number;
  7139. private _velocity;
  7140. private _basePoint;
  7141. private _epsilon;
  7142. /** @hidden */
  7143. _velocityWorldLength: number;
  7144. /** @hidden */
  7145. _basePointWorld: Vector3;
  7146. private _velocityWorld;
  7147. private _normalizedVelocity;
  7148. /** @hidden */
  7149. _initialVelocity: Vector3;
  7150. /** @hidden */
  7151. _initialPosition: Vector3;
  7152. private _nearestDistance;
  7153. private _collisionMask;
  7154. collisionMask: number;
  7155. /**
  7156. * Gets the plane normal used to compute the sliding response (in local space)
  7157. */
  7158. readonly slidePlaneNormal: Vector3;
  7159. /** @hidden */
  7160. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7161. /** @hidden */
  7162. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7163. /** @hidden */
  7164. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7165. /** @hidden */
  7166. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7167. /** @hidden */
  7168. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7169. /** @hidden */
  7170. _getResponse(pos: Vector3, vel: Vector3): void;
  7171. }
  7172. }
  7173. declare module "babylonjs/Culling/boundingInfo" {
  7174. import { DeepImmutable } from "babylonjs/types";
  7175. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7176. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7177. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Misc/smartArray" {
  7294. /**
  7295. * Defines an array and its length.
  7296. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7297. */
  7298. export interface ISmartArrayLike<T> {
  7299. /**
  7300. * The data of the array.
  7301. */
  7302. data: Array<T>;
  7303. /**
  7304. * The active length of the array.
  7305. */
  7306. length: number;
  7307. }
  7308. /**
  7309. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7310. */
  7311. export class SmartArray<T> implements ISmartArrayLike<T> {
  7312. /**
  7313. * The full set of data from the array.
  7314. */
  7315. data: Array<T>;
  7316. /**
  7317. * The active length of the array.
  7318. */
  7319. length: number;
  7320. protected _id: number;
  7321. /**
  7322. * Instantiates a Smart Array.
  7323. * @param capacity defines the default capacity of the array.
  7324. */
  7325. constructor(capacity: number);
  7326. /**
  7327. * Pushes a value at the end of the active data.
  7328. * @param value defines the object to push in the array.
  7329. */
  7330. push(value: T): void;
  7331. /**
  7332. * Iterates over the active data and apply the lambda to them.
  7333. * @param func defines the action to apply on each value.
  7334. */
  7335. forEach(func: (content: T) => void): void;
  7336. /**
  7337. * Sorts the full sets of data.
  7338. * @param compareFn defines the comparison function to apply.
  7339. */
  7340. sort(compareFn: (a: T, b: T) => number): void;
  7341. /**
  7342. * Resets the active data to an empty array.
  7343. */
  7344. reset(): void;
  7345. /**
  7346. * Releases all the data from the array as well as the array.
  7347. */
  7348. dispose(): void;
  7349. /**
  7350. * Concats the active data with a given array.
  7351. * @param array defines the data to concatenate with.
  7352. */
  7353. concat(array: any): void;
  7354. /**
  7355. * Returns the position of a value in the active data.
  7356. * @param value defines the value to find the index for
  7357. * @returns the index if found in the active data otherwise -1
  7358. */
  7359. indexOf(value: T): number;
  7360. /**
  7361. * Returns whether an element is part of the active data.
  7362. * @param value defines the value to look for
  7363. * @returns true if found in the active data otherwise false
  7364. */
  7365. contains(value: T): boolean;
  7366. private static _GlobalId;
  7367. }
  7368. /**
  7369. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7370. * The data in this array can only be present once
  7371. */
  7372. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7373. private _duplicateId;
  7374. /**
  7375. * Pushes a value at the end of the active data.
  7376. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7377. * @param value defines the object to push in the array.
  7378. */
  7379. push(value: T): void;
  7380. /**
  7381. * Pushes a value at the end of the active data.
  7382. * If the data is already present, it won t be added again
  7383. * @param value defines the object to push in the array.
  7384. * @returns true if added false if it was already present
  7385. */
  7386. pushNoDuplicate(value: T): boolean;
  7387. /**
  7388. * Resets the active data to an empty array.
  7389. */
  7390. reset(): void;
  7391. /**
  7392. * Concats the active data with a given array.
  7393. * This ensures no dupplicate will be present in the result.
  7394. * @param array defines the data to concatenate with.
  7395. */
  7396. concatWithNoDuplicate(array: any): void;
  7397. }
  7398. }
  7399. declare module "babylonjs/Materials/multiMaterial" {
  7400. import { Nullable } from "babylonjs/types";
  7401. import { Scene } from "babylonjs/scene";
  7402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7403. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7405. import { Material } from "babylonjs/Materials/material";
  7406. /**
  7407. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7408. * separate meshes. This can be use to improve performances.
  7409. * @see http://doc.babylonjs.com/how_to/multi_materials
  7410. */
  7411. export class MultiMaterial extends Material {
  7412. private _subMaterials;
  7413. /**
  7414. * Gets or Sets the list of Materials used within the multi material.
  7415. * They need to be ordered according to the submeshes order in the associated mesh
  7416. */
  7417. subMaterials: Nullable<Material>[];
  7418. /**
  7419. * Function used to align with Node.getChildren()
  7420. * @returns the list of Materials used within the multi material
  7421. */
  7422. getChildren(): Nullable<Material>[];
  7423. /**
  7424. * Instantiates a new Multi Material
  7425. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7426. * separate meshes. This can be use to improve performances.
  7427. * @see http://doc.babylonjs.com/how_to/multi_materials
  7428. * @param name Define the name in the scene
  7429. * @param scene Define the scene the material belongs to
  7430. */
  7431. constructor(name: string, scene: Scene);
  7432. private _hookArray;
  7433. /**
  7434. * Get one of the submaterial by its index in the submaterials array
  7435. * @param index The index to look the sub material at
  7436. * @returns The Material if the index has been defined
  7437. */
  7438. getSubMaterial(index: number): Nullable<Material>;
  7439. /**
  7440. * Get the list of active textures for the whole sub materials list.
  7441. * @returns All the textures that will be used during the rendering
  7442. */
  7443. getActiveTextures(): BaseTexture[];
  7444. /**
  7445. * Gets the current class name of the material e.g. "MultiMaterial"
  7446. * Mainly use in serialization.
  7447. * @returns the class name
  7448. */
  7449. getClassName(): string;
  7450. /**
  7451. * Checks if the material is ready to render the requested sub mesh
  7452. * @param mesh Define the mesh the submesh belongs to
  7453. * @param subMesh Define the sub mesh to look readyness for
  7454. * @param useInstances Define whether or not the material is used with instances
  7455. * @returns true if ready, otherwise false
  7456. */
  7457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7458. /**
  7459. * Clones the current material and its related sub materials
  7460. * @param name Define the name of the newly cloned material
  7461. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7462. * @returns the cloned material
  7463. */
  7464. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7465. /**
  7466. * Serializes the materials into a JSON representation.
  7467. * @returns the JSON representation
  7468. */
  7469. serialize(): any;
  7470. /**
  7471. * Dispose the material and release its associated resources
  7472. * @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)
  7473. * @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)
  7474. * @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)
  7475. */
  7476. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7477. /**
  7478. * Creates a MultiMaterial from parsed MultiMaterial data.
  7479. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7480. * @param scene defines the hosting scene
  7481. * @returns a new MultiMaterial
  7482. */
  7483. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7484. }
  7485. }
  7486. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7487. /**
  7488. * Class used to represent data loading progression
  7489. */
  7490. export class SceneLoaderFlags {
  7491. private static _ForceFullSceneLoadingForIncremental;
  7492. private static _ShowLoadingScreen;
  7493. private static _CleanBoneMatrixWeights;
  7494. private static _loggingLevel;
  7495. /**
  7496. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7497. */
  7498. static ForceFullSceneLoadingForIncremental: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7501. */
  7502. static ShowLoadingScreen: boolean;
  7503. /**
  7504. * Defines the current logging level (while loading the scene)
  7505. * @ignorenaming
  7506. */
  7507. static loggingLevel: number;
  7508. /**
  7509. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7510. */
  7511. static CleanBoneMatrixWeights: boolean;
  7512. }
  7513. }
  7514. declare module "babylonjs/Meshes/transformNode" {
  7515. import { DeepImmutable } from "babylonjs/types";
  7516. import { Observable } from "babylonjs/Misc/observable";
  7517. import { Nullable } from "babylonjs/types";
  7518. import { Camera } from "babylonjs/Cameras/camera";
  7519. import { Scene } from "babylonjs/scene";
  7520. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7521. import { Node } from "babylonjs/node";
  7522. import { Bone } from "babylonjs/Bones/bone";
  7523. /**
  7524. * 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.
  7525. * @see https://doc.babylonjs.com/how_to/transformnode
  7526. */
  7527. export class TransformNode extends Node {
  7528. /**
  7529. * Object will not rotate to face the camera
  7530. */
  7531. static BILLBOARDMODE_NONE: number;
  7532. /**
  7533. * Object will rotate to face the camera but only on the x axis
  7534. */
  7535. static BILLBOARDMODE_X: number;
  7536. /**
  7537. * Object will rotate to face the camera but only on the y axis
  7538. */
  7539. static BILLBOARDMODE_Y: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the z axis
  7542. */
  7543. static BILLBOARDMODE_Z: number;
  7544. /**
  7545. * Object will rotate to face the camera
  7546. */
  7547. static BILLBOARDMODE_ALL: number;
  7548. private _forward;
  7549. private _forwardInverted;
  7550. private _up;
  7551. private _right;
  7552. private _rightInverted;
  7553. private _position;
  7554. private _rotation;
  7555. private _rotationQuaternion;
  7556. protected _scaling: Vector3;
  7557. protected _isDirty: boolean;
  7558. private _transformToBoneReferal;
  7559. /**
  7560. * Set the billboard mode. Default is 0.
  7561. *
  7562. * | Value | Type | Description |
  7563. * | --- | --- | --- |
  7564. * | 0 | BILLBOARDMODE_NONE | |
  7565. * | 1 | BILLBOARDMODE_X | |
  7566. * | 2 | BILLBOARDMODE_Y | |
  7567. * | 4 | BILLBOARDMODE_Z | |
  7568. * | 7 | BILLBOARDMODE_ALL | |
  7569. *
  7570. */
  7571. billboardMode: number;
  7572. /**
  7573. * 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
  7574. */
  7575. scalingDeterminant: number;
  7576. /**
  7577. * Sets the distance of the object to max, often used by skybox
  7578. */
  7579. infiniteDistance: boolean;
  7580. /**
  7581. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7582. * By default the system will update normals to compensate
  7583. */
  7584. ignoreNonUniformScaling: boolean;
  7585. /** @hidden */
  7586. _poseMatrix: Matrix;
  7587. /** @hidden */
  7588. _localMatrix: Matrix;
  7589. private _absolutePosition;
  7590. private _pivotMatrix;
  7591. private _pivotMatrixInverse;
  7592. protected _postMultiplyPivotMatrix: boolean;
  7593. private _tempMatrix;
  7594. private _tempMatrix2;
  7595. protected _isWorldMatrixFrozen: boolean;
  7596. /** @hidden */
  7597. _indexInSceneTransformNodesArray: number;
  7598. /**
  7599. * An event triggered after the world matrix is updated
  7600. */
  7601. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7602. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7603. /**
  7604. * Gets a string identifying the name of the class
  7605. * @returns "TransformNode" string
  7606. */
  7607. getClassName(): string;
  7608. /**
  7609. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7610. */
  7611. position: Vector3;
  7612. /**
  7613. * 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)).
  7614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7615. */
  7616. rotation: Vector3;
  7617. /**
  7618. * 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)).
  7619. */
  7620. scaling: Vector3;
  7621. /**
  7622. * 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).
  7623. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7624. */
  7625. rotationQuaternion: Nullable<Quaternion>;
  7626. /**
  7627. * The forward direction of that transform in world space.
  7628. */
  7629. readonly forward: Vector3;
  7630. /**
  7631. * The up direction of that transform in world space.
  7632. */
  7633. readonly up: Vector3;
  7634. /**
  7635. * The right direction of that transform in world space.
  7636. */
  7637. readonly right: Vector3;
  7638. /**
  7639. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7640. * @param matrix the matrix to copy the pose from
  7641. * @returns this TransformNode.
  7642. */
  7643. updatePoseMatrix(matrix: Matrix): TransformNode;
  7644. /**
  7645. * Returns the mesh Pose matrix.
  7646. * @returns the pose matrix
  7647. */
  7648. getPoseMatrix(): Matrix;
  7649. /** @hidden */
  7650. _isSynchronized(): boolean;
  7651. /** @hidden */
  7652. _initCache(): void;
  7653. /**
  7654. * Flag the transform node as dirty (Forcing it to update everything)
  7655. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7656. * @returns this transform node
  7657. */
  7658. markAsDirty(property: string): TransformNode;
  7659. /**
  7660. * Returns the current mesh absolute position.
  7661. * Returns a Vector3.
  7662. */
  7663. readonly absolutePosition: Vector3;
  7664. /**
  7665. * Sets a new matrix to apply before all other transformation
  7666. * @param matrix defines the transform matrix
  7667. * @returns the current TransformNode
  7668. */
  7669. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7670. /**
  7671. * Sets a new pivot matrix to the current node
  7672. * @param matrix defines the new pivot matrix to use
  7673. * @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
  7674. * @returns the current TransformNode
  7675. */
  7676. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7677. /**
  7678. * Returns the mesh pivot matrix.
  7679. * Default : Identity.
  7680. * @returns the matrix
  7681. */
  7682. getPivotMatrix(): Matrix;
  7683. /**
  7684. * Prevents the World matrix to be computed any longer.
  7685. * @returns the TransformNode.
  7686. */
  7687. freezeWorldMatrix(): TransformNode;
  7688. /**
  7689. * Allows back the World matrix computation.
  7690. * @returns the TransformNode.
  7691. */
  7692. unfreezeWorldMatrix(): this;
  7693. /**
  7694. * True if the World matrix has been frozen.
  7695. */
  7696. readonly isWorldMatrixFrozen: boolean;
  7697. /**
  7698. * Retuns the mesh absolute position in the World.
  7699. * @returns a Vector3.
  7700. */
  7701. getAbsolutePosition(): Vector3;
  7702. /**
  7703. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7704. * @param absolutePosition the absolute position to set
  7705. * @returns the TransformNode.
  7706. */
  7707. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7708. /**
  7709. * Sets the mesh position in its local space.
  7710. * @param vector3 the position to set in localspace
  7711. * @returns the TransformNode.
  7712. */
  7713. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7714. /**
  7715. * Returns the mesh position in the local space from the current World matrix values.
  7716. * @returns a new Vector3.
  7717. */
  7718. getPositionExpressedInLocalSpace(): Vector3;
  7719. /**
  7720. * Translates the mesh along the passed Vector3 in its local space.
  7721. * @param vector3 the distance to translate in localspace
  7722. * @returns the TransformNode.
  7723. */
  7724. locallyTranslate(vector3: Vector3): TransformNode;
  7725. private static _lookAtVectorCache;
  7726. /**
  7727. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7728. * @param targetPoint the position (must be in same space as current mesh) to look at
  7729. * @param yawCor optional yaw (y-axis) correction in radians
  7730. * @param pitchCor optional pitch (x-axis) correction in radians
  7731. * @param rollCor optional roll (z-axis) correction in radians
  7732. * @param space the choosen space of the target
  7733. * @returns the TransformNode.
  7734. */
  7735. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7736. /**
  7737. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7738. * This Vector3 is expressed in the World space.
  7739. * @param localAxis axis to rotate
  7740. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7741. */
  7742. getDirection(localAxis: Vector3): Vector3;
  7743. /**
  7744. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7745. * localAxis is expressed in the mesh local space.
  7746. * result is computed in the Wordl space from the mesh World matrix.
  7747. * @param localAxis axis to rotate
  7748. * @param result the resulting transformnode
  7749. * @returns this TransformNode.
  7750. */
  7751. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7752. /**
  7753. * Sets this transform node rotation to the given local axis.
  7754. * @param localAxis the axis in local space
  7755. * @param yawCor optional yaw (y-axis) correction in radians
  7756. * @param pitchCor optional pitch (x-axis) correction in radians
  7757. * @param rollCor optional roll (z-axis) correction in radians
  7758. * @returns this TransformNode
  7759. */
  7760. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7761. /**
  7762. * Sets a new pivot point to the current node
  7763. * @param point defines the new pivot point to use
  7764. * @param space defines if the point is in world or local space (local by default)
  7765. * @returns the current TransformNode
  7766. */
  7767. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7768. /**
  7769. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7770. * @returns the pivot point
  7771. */
  7772. getPivotPoint(): Vector3;
  7773. /**
  7774. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7775. * @param result the vector3 to store the result
  7776. * @returns this TransformNode.
  7777. */
  7778. getPivotPointToRef(result: Vector3): TransformNode;
  7779. /**
  7780. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7781. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7782. */
  7783. getAbsolutePivotPoint(): Vector3;
  7784. /**
  7785. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7786. * @param result vector3 to store the result
  7787. * @returns this TransformNode.
  7788. */
  7789. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7790. /**
  7791. * Defines the passed node as the parent of the current node.
  7792. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7793. * @see https://doc.babylonjs.com/how_to/parenting
  7794. * @param node the node ot set as the parent
  7795. * @returns this TransformNode.
  7796. */
  7797. setParent(node: Nullable<Node>): TransformNode;
  7798. private _nonUniformScaling;
  7799. /**
  7800. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7801. */
  7802. readonly nonUniformScaling: boolean;
  7803. /** @hidden */
  7804. _updateNonUniformScalingState(value: boolean): boolean;
  7805. /**
  7806. * Attach the current TransformNode to another TransformNode associated with a bone
  7807. * @param bone Bone affecting the TransformNode
  7808. * @param affectedTransformNode TransformNode associated with the bone
  7809. * @returns this object
  7810. */
  7811. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7812. /**
  7813. * Detach the transform node if its associated with a bone
  7814. * @returns this object
  7815. */
  7816. detachFromBone(): TransformNode;
  7817. private static _rotationAxisCache;
  7818. /**
  7819. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7820. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7821. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7822. * The passed axis is also normalized.
  7823. * @param axis the axis to rotate around
  7824. * @param amount the amount to rotate in radians
  7825. * @param space Space to rotate in (Default: local)
  7826. * @returns the TransformNode.
  7827. */
  7828. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7829. /**
  7830. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7831. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7832. * The passed axis is also normalized. .
  7833. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7834. * @param point the point to rotate around
  7835. * @param axis the axis to rotate around
  7836. * @param amount the amount to rotate in radians
  7837. * @returns the TransformNode
  7838. */
  7839. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7840. /**
  7841. * Translates the mesh along the axis vector for the passed distance in the given space.
  7842. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7843. * @param axis the axis to translate in
  7844. * @param distance the distance to translate
  7845. * @param space Space to rotate in (Default: local)
  7846. * @returns the TransformNode.
  7847. */
  7848. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7849. /**
  7850. * Adds a rotation step to the mesh current rotation.
  7851. * x, y, z are Euler angles expressed in radians.
  7852. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7853. * This means this rotation is made in the mesh local space only.
  7854. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7855. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7856. * ```javascript
  7857. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7858. * ```
  7859. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7860. * 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.
  7861. * @param x Rotation to add
  7862. * @param y Rotation to add
  7863. * @param z Rotation to add
  7864. * @returns the TransformNode.
  7865. */
  7866. addRotation(x: number, y: number, z: number): TransformNode;
  7867. /**
  7868. * Computes the world matrix of the node
  7869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7870. * @returns the world matrix
  7871. */
  7872. computeWorldMatrix(force?: boolean): Matrix;
  7873. protected _afterComputeWorldMatrix(): void;
  7874. /**
  7875. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7876. * @param func callback function to add
  7877. *
  7878. * @returns the TransformNode.
  7879. */
  7880. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7881. /**
  7882. * Removes a registered callback function.
  7883. * @param func callback function to remove
  7884. * @returns the TransformNode.
  7885. */
  7886. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7887. /**
  7888. * Gets the position of the current mesh in camera space
  7889. * @param camera defines the camera to use
  7890. * @returns a position
  7891. */
  7892. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7893. /**
  7894. * Returns the distance from the mesh to the active camera
  7895. * @param camera defines the camera to use
  7896. * @returns the distance
  7897. */
  7898. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7899. /**
  7900. * Clone the current transform node
  7901. * @param name Name of the new clone
  7902. * @param newParent New parent for the clone
  7903. * @param doNotCloneChildren Do not clone children hierarchy
  7904. * @returns the new transform node
  7905. */
  7906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7907. /**
  7908. * Serializes the objects information.
  7909. * @param currentSerializationObject defines the object to serialize in
  7910. * @returns the serialized object
  7911. */
  7912. serialize(currentSerializationObject?: any): any;
  7913. /**
  7914. * Returns a new TransformNode object parsed from the source provided.
  7915. * @param parsedTransformNode is the source.
  7916. * @param scene the scne the object belongs to
  7917. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7918. * @returns a new TransformNode object parsed from the source provided.
  7919. */
  7920. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7921. /**
  7922. * Get all child-transformNodes of this node
  7923. * @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
  7924. * @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
  7925. * @returns an array of TransformNode
  7926. */
  7927. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7928. /**
  7929. * Releases resources associated with this transform node.
  7930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7932. */
  7933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7934. }
  7935. }
  7936. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7937. /**
  7938. * Class used to override all child animations of a given target
  7939. */
  7940. export class AnimationPropertiesOverride {
  7941. /**
  7942. * Gets or sets a value indicating if animation blending must be used
  7943. */
  7944. enableBlending: boolean;
  7945. /**
  7946. * Gets or sets the blending speed to use when enableBlending is true
  7947. */
  7948. blendingSpeed: number;
  7949. /**
  7950. * Gets or sets the default loop mode to use
  7951. */
  7952. loopMode: number;
  7953. }
  7954. }
  7955. declare module "babylonjs/Bones/bone" {
  7956. import { Skeleton } from "babylonjs/Bones/skeleton";
  7957. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7958. import { Nullable } from "babylonjs/types";
  7959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7960. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7961. import { Node } from "babylonjs/node";
  7962. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7963. /**
  7964. * Class used to store bone information
  7965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7966. */
  7967. export class Bone extends Node {
  7968. /**
  7969. * defines the bone name
  7970. */
  7971. name: string;
  7972. private static _tmpVecs;
  7973. private static _tmpQuat;
  7974. private static _tmpMats;
  7975. /**
  7976. * Gets the list of child bones
  7977. */
  7978. children: Bone[];
  7979. /** Gets the animations associated with this bone */
  7980. animations: import("babylonjs/Animations/animation").Animation[];
  7981. /**
  7982. * Gets or sets bone length
  7983. */
  7984. length: number;
  7985. /**
  7986. * @hidden Internal only
  7987. * Set this value to map this bone to a different index in the transform matrices
  7988. * Set this value to -1 to exclude the bone from the transform matrices
  7989. */
  7990. _index: Nullable<number>;
  7991. private _skeleton;
  7992. private _localMatrix;
  7993. private _restPose;
  7994. private _baseMatrix;
  7995. private _absoluteTransform;
  7996. private _invertedAbsoluteTransform;
  7997. private _parent;
  7998. private _scalingDeterminant;
  7999. private _worldTransform;
  8000. private _localScaling;
  8001. private _localRotation;
  8002. private _localPosition;
  8003. private _needToDecompose;
  8004. private _needToCompose;
  8005. /** @hidden */
  8006. _linkedTransformNode: Nullable<TransformNode>;
  8007. /** @hidden */
  8008. /** @hidden */
  8009. _matrix: Matrix;
  8010. /**
  8011. * Create a new bone
  8012. * @param name defines the bone name
  8013. * @param skeleton defines the parent skeleton
  8014. * @param parentBone defines the parent (can be null if the bone is the root)
  8015. * @param localMatrix defines the local matrix
  8016. * @param restPose defines the rest pose matrix
  8017. * @param baseMatrix defines the base matrix
  8018. * @param index defines index of the bone in the hiearchy
  8019. */
  8020. constructor(
  8021. /**
  8022. * defines the bone name
  8023. */
  8024. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8025. /**
  8026. * Gets the current object class name.
  8027. * @return the class name
  8028. */
  8029. getClassName(): string;
  8030. /**
  8031. * Gets the parent skeleton
  8032. * @returns a skeleton
  8033. */
  8034. getSkeleton(): Skeleton;
  8035. /**
  8036. * Gets parent bone
  8037. * @returns a bone or null if the bone is the root of the bone hierarchy
  8038. */
  8039. getParent(): Nullable<Bone>;
  8040. /**
  8041. * Returns an array containing the root bones
  8042. * @returns an array containing the root bones
  8043. */
  8044. getChildren(): Array<Bone>;
  8045. /**
  8046. * Sets the parent bone
  8047. * @param parent defines the parent (can be null if the bone is the root)
  8048. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8049. */
  8050. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8051. /**
  8052. * Gets the local matrix
  8053. * @returns a matrix
  8054. */
  8055. getLocalMatrix(): Matrix;
  8056. /**
  8057. * Gets the base matrix (initial matrix which remains unchanged)
  8058. * @returns a matrix
  8059. */
  8060. getBaseMatrix(): Matrix;
  8061. /**
  8062. * Gets the rest pose matrix
  8063. * @returns a matrix
  8064. */
  8065. getRestPose(): Matrix;
  8066. /**
  8067. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8068. */
  8069. getWorldMatrix(): Matrix;
  8070. /**
  8071. * Sets the local matrix to rest pose matrix
  8072. */
  8073. returnToRest(): void;
  8074. /**
  8075. * Gets the inverse of the absolute transform matrix.
  8076. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8077. * @returns a matrix
  8078. */
  8079. getInvertedAbsoluteTransform(): Matrix;
  8080. /**
  8081. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8082. * @returns a matrix
  8083. */
  8084. getAbsoluteTransform(): Matrix;
  8085. /**
  8086. * Links with the given transform node.
  8087. * The local matrix of this bone is copied from the transform node every frame.
  8088. * @param transformNode defines the transform node to link to
  8089. */
  8090. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8091. /** Gets or sets current position (in local space) */
  8092. position: Vector3;
  8093. /** Gets or sets current rotation (in local space) */
  8094. rotation: Vector3;
  8095. /** Gets or sets current rotation quaternion (in local space) */
  8096. rotationQuaternion: Quaternion;
  8097. /** Gets or sets current scaling (in local space) */
  8098. scaling: Vector3;
  8099. /**
  8100. * Gets the animation properties override
  8101. */
  8102. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8103. private _decompose;
  8104. private _compose;
  8105. /**
  8106. * Update the base and local matrices
  8107. * @param matrix defines the new base or local matrix
  8108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8109. * @param updateLocalMatrix defines if the local matrix should be updated
  8110. */
  8111. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8112. /** @hidden */
  8113. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8114. /**
  8115. * Flag the bone as dirty (Forcing it to update everything)
  8116. */
  8117. markAsDirty(): void;
  8118. private _markAsDirtyAndCompose;
  8119. private _markAsDirtyAndDecompose;
  8120. /**
  8121. * Translate the bone in local or world space
  8122. * @param vec The amount to translate the bone
  8123. * @param space The space that the translation is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8127. /**
  8128. * Set the postion of the bone in local or world space
  8129. * @param position The position to set the bone
  8130. * @param space The space that the position is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. */
  8133. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8134. /**
  8135. * Set the absolute position of the bone (world space)
  8136. * @param position The position to set the bone
  8137. * @param mesh The mesh that this bone is attached to
  8138. */
  8139. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Scale the bone on the x, y and z axes (in local space)
  8142. * @param x The amount to scale the bone on the x axis
  8143. * @param y The amount to scale the bone on the y axis
  8144. * @param z The amount to scale the bone on the z axis
  8145. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8146. */
  8147. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8148. /**
  8149. * Set the bone scaling in local space
  8150. * @param scale defines the scaling vector
  8151. */
  8152. setScale(scale: Vector3): void;
  8153. /**
  8154. * Gets the current scaling in local space
  8155. * @returns the current scaling vector
  8156. */
  8157. getScale(): Vector3;
  8158. /**
  8159. * Gets the current scaling in local space and stores it in a target vector
  8160. * @param result defines the target vector
  8161. */
  8162. getScaleToRef(result: Vector3): void;
  8163. /**
  8164. * Set the yaw, pitch, and roll of the bone in local or world space
  8165. * @param yaw The rotation of the bone on the y axis
  8166. * @param pitch The rotation of the bone on the x axis
  8167. * @param roll The rotation of the bone on the z axis
  8168. * @param space The space that the axes of rotation are in
  8169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8170. */
  8171. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8172. /**
  8173. * Add a rotation to the bone on an axis in local or world space
  8174. * @param axis The axis to rotate the bone on
  8175. * @param amount The amount to rotate the bone
  8176. * @param space The space that the axis is in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Set the rotation of the bone to a particular axis angle in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param angle The angle that the bone should be rotated to
  8184. * @param space The space that the axis is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the euler rotation of the bone in local of world space
  8190. * @param rotation The euler rotation that the bone should be set to
  8191. * @param space The space that the rotation is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the quaternion rotation of the bone in local of world space
  8197. * @param quat The quaternion rotation that the bone should be set to
  8198. * @param space The space that the rotation is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8202. /**
  8203. * Set the rotation matrix of the bone in local of world space
  8204. * @param rotMat The rotation matrix that the bone should be set to
  8205. * @param space The space that the rotation is in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. */
  8208. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8209. private _rotateWithMatrix;
  8210. private _getNegativeRotationToRef;
  8211. /**
  8212. * Get the position of the bone in local or world space
  8213. * @param space The space that the returned position is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. * @returns The position of the bone
  8216. */
  8217. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8218. /**
  8219. * Copy the position of the bone to a vector3 in local or world space
  8220. * @param space The space that the returned position is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. * @param result The vector3 to copy the position to
  8223. */
  8224. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8225. /**
  8226. * Get the absolute position of the bone (world space)
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @returns The absolute position of the bone
  8229. */
  8230. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8231. /**
  8232. * Copy the absolute position of the bone (world space) to the result param
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @param result The vector3 to copy the absolute position to
  8235. */
  8236. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8237. /**
  8238. * Compute the absolute transforms of this bone and its children
  8239. */
  8240. computeAbsoluteTransforms(): void;
  8241. /**
  8242. * Get the world direction from an axis that is in the local space of the bone
  8243. * @param localAxis The local direction that is used to compute the world direction
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @returns The world direction
  8246. */
  8247. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8248. /**
  8249. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8250. * @param localAxis The local direction that is used to compute the world direction
  8251. * @param mesh The mesh that this bone is attached to
  8252. * @param result The vector3 that the world direction will be copied to
  8253. */
  8254. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8255. /**
  8256. * Get the euler rotation of the bone in local or world space
  8257. * @param space The space that the rotation should be in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @returns The euler rotation
  8260. */
  8261. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8262. /**
  8263. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8264. * @param space The space that the rotation should be in
  8265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8266. * @param result The vector3 that the rotation should be copied to
  8267. */
  8268. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8269. /**
  8270. * Get the quaternion rotation of the bone in either local or world space
  8271. * @param space The space that the rotation should be in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @returns The quaternion rotation
  8274. */
  8275. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8276. /**
  8277. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8278. * @param space The space that the rotation should be in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @param result The quaternion that the rotation should be copied to
  8281. */
  8282. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8283. /**
  8284. * Get the rotation matrix of the bone in local or world space
  8285. * @param space The space that the rotation should be in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. * @returns The rotation matrix
  8288. */
  8289. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8290. /**
  8291. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8292. * @param space The space that the rotation should be in
  8293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8294. * @param result The quaternion that the rotation should be copied to
  8295. */
  8296. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8297. /**
  8298. * Get the world position of a point that is in the local space of the bone
  8299. * @param position The local position
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world position
  8302. */
  8303. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8306. * @param position The local position
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world position should be copied to
  8309. */
  8310. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the local position of a point that is in world space
  8313. * @param position The world position
  8314. * @param mesh The mesh that this bone is attached to
  8315. * @returns The local position
  8316. */
  8317. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Get the local position of a point that is in world space and copy it to the result param
  8320. * @param position The world position
  8321. * @param mesh The mesh that this bone is attached to
  8322. * @param result The vector3 that the local position should be copied to
  8323. */
  8324. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. }
  8326. }
  8327. declare module "babylonjs/Misc/iInspectable" {
  8328. /**
  8329. * Enum that determines the text-wrapping mode to use.
  8330. */
  8331. export enum InspectableType {
  8332. /**
  8333. * Checkbox for booleans
  8334. */
  8335. Checkbox = 0,
  8336. /**
  8337. * Sliders for numbers
  8338. */
  8339. Slider = 1,
  8340. /**
  8341. * Vector3
  8342. */
  8343. Vector3 = 2,
  8344. /**
  8345. * Quaternions
  8346. */
  8347. Quaternion = 3,
  8348. /**
  8349. * Color3
  8350. */
  8351. Color3 = 4
  8352. }
  8353. /**
  8354. * Interface used to define custom inspectable properties.
  8355. * This interface is used by the inspector to display custom property grids
  8356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8357. */
  8358. export interface IInspectable {
  8359. /**
  8360. * Gets the label to display
  8361. */
  8362. label: string;
  8363. /**
  8364. * Gets the name of the property to edit
  8365. */
  8366. propertyName: string;
  8367. /**
  8368. * Gets the type of the editor to use
  8369. */
  8370. type: InspectableType;
  8371. /**
  8372. * Gets the minimum value of the property when using in "slider" mode
  8373. */
  8374. min?: number;
  8375. /**
  8376. * Gets the maximum value of the property when using in "slider" mode
  8377. */
  8378. max?: number;
  8379. /**
  8380. * Gets the setp to use when using in "slider" mode
  8381. */
  8382. step?: number;
  8383. }
  8384. }
  8385. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8386. import { Nullable } from "babylonjs/types";
  8387. import { Scene } from "babylonjs/scene";
  8388. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. /**
  8391. * Class for creating a cube texture
  8392. */
  8393. export class CubeTexture extends BaseTexture {
  8394. private _delayedOnLoad;
  8395. /**
  8396. * The url of the texture
  8397. */
  8398. url: string;
  8399. /**
  8400. * Gets or sets the center of the bounding box associated with the cube texture.
  8401. * It must define where the camera used to render the texture was set
  8402. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8403. */
  8404. boundingBoxPosition: Vector3;
  8405. private _boundingBoxSize;
  8406. /**
  8407. * Gets or sets the size of the bounding box associated with the cube texture
  8408. * When defined, the cubemap will switch to local mode
  8409. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8410. * @example https://www.babylonjs-playground.com/#RNASML
  8411. */
  8412. /**
  8413. * Returns the bounding box size
  8414. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8415. */
  8416. boundingBoxSize: Vector3;
  8417. protected _rotationY: number;
  8418. /**
  8419. * Sets texture matrix rotation angle around Y axis in radians.
  8420. */
  8421. /**
  8422. * Gets texture matrix rotation angle around Y axis radians.
  8423. */
  8424. rotationY: number;
  8425. /**
  8426. * Are mip maps generated for this texture or not.
  8427. */
  8428. readonly noMipmap: boolean;
  8429. private _noMipmap;
  8430. private _files;
  8431. private _extensions;
  8432. private _textureMatrix;
  8433. private _format;
  8434. private _createPolynomials;
  8435. /** @hidden */
  8436. _prefiltered: boolean;
  8437. /**
  8438. * Creates a cube texture from an array of image urls
  8439. * @param files defines an array of image urls
  8440. * @param scene defines the hosting scene
  8441. * @param noMipmap specifies if mip maps are not used
  8442. * @returns a cube texture
  8443. */
  8444. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8445. /**
  8446. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8447. * @param url defines the url of the prefiltered texture
  8448. * @param scene defines the scene the texture is attached to
  8449. * @param forcedExtension defines the extension of the file if different from the url
  8450. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8451. * @return the prefiltered texture
  8452. */
  8453. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8454. /**
  8455. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8456. * as prefiltered data.
  8457. * @param rootUrl defines the url of the texture or the root name of the six images
  8458. * @param scene defines the scene the texture is attached to
  8459. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8460. * @param noMipmap defines if mipmaps should be created or not
  8461. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8462. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8463. * @param onError defines a callback triggered in case of error during load
  8464. * @param format defines the internal format to use for the texture once loaded
  8465. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8466. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8467. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8470. * @return the cube texture
  8471. */
  8472. 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);
  8473. /**
  8474. * Get the current class name of the texture useful for serialization or dynamic coding.
  8475. * @returns "CubeTexture"
  8476. */
  8477. getClassName(): string;
  8478. /**
  8479. * Update the url (and optional buffer) of this texture if url was null during construction.
  8480. * @param url the url of the texture
  8481. * @param forcedExtension defines the extension to use
  8482. * @param onLoad callback called when the texture is loaded (defaults to null)
  8483. */
  8484. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8485. /**
  8486. * Delays loading of the cube texture
  8487. * @param forcedExtension defines the extension to use
  8488. */
  8489. delayLoad(forcedExtension?: string): void;
  8490. /**
  8491. * Returns the reflection texture matrix
  8492. * @returns the reflection texture matrix
  8493. */
  8494. getReflectionTextureMatrix(): Matrix;
  8495. /**
  8496. * Sets the reflection texture matrix
  8497. * @param value Reflection texture matrix
  8498. */
  8499. setReflectionTextureMatrix(value: Matrix): void;
  8500. /**
  8501. * Parses text to create a cube texture
  8502. * @param parsedTexture define the serialized text to read from
  8503. * @param scene defines the hosting scene
  8504. * @param rootUrl defines the root url of the cube texture
  8505. * @returns a cube texture
  8506. */
  8507. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8508. /**
  8509. * Makes a clone, or deep copy, of the cube texture
  8510. * @returns a new cube texture
  8511. */
  8512. clone(): CubeTexture;
  8513. }
  8514. }
  8515. declare module "babylonjs/Shaders/postprocess.vertex" {
  8516. /** @hidden */
  8517. export var postprocessVertexShader: {
  8518. name: string;
  8519. shader: string;
  8520. };
  8521. }
  8522. declare module "babylonjs/Cameras/targetCamera" {
  8523. import { Nullable } from "babylonjs/types";
  8524. import { Camera } from "babylonjs/Cameras/camera";
  8525. import { Scene } from "babylonjs/scene";
  8526. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8527. /**
  8528. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. */
  8532. export class TargetCamera extends Camera {
  8533. private static _RigCamTransformMatrix;
  8534. private static _TargetTransformMatrix;
  8535. private static _TargetFocalPoint;
  8536. /**
  8537. * Define the current direction the camera is moving to
  8538. */
  8539. cameraDirection: Vector3;
  8540. /**
  8541. * Define the current rotation the camera is rotating to
  8542. */
  8543. cameraRotation: Vector2;
  8544. /**
  8545. * When set, the up vector of the camera will be updated by the rotation of the camera
  8546. */
  8547. updateUpVectorFromRotation: boolean;
  8548. private _tmpQuaternion;
  8549. /**
  8550. * Define the current rotation of the camera
  8551. */
  8552. rotation: Vector3;
  8553. /**
  8554. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8555. */
  8556. rotationQuaternion: Quaternion;
  8557. /**
  8558. * Define the current speed of the camera
  8559. */
  8560. speed: number;
  8561. /**
  8562. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8563. * around all axis.
  8564. */
  8565. noRotationConstraint: boolean;
  8566. /**
  8567. * Define the current target of the camera as an object or a position.
  8568. */
  8569. lockedTarget: any;
  8570. /** @hidden */
  8571. _currentTarget: Vector3;
  8572. /** @hidden */
  8573. _initialFocalDistance: number;
  8574. /** @hidden */
  8575. _viewMatrix: Matrix;
  8576. /** @hidden */
  8577. _camMatrix: Matrix;
  8578. /** @hidden */
  8579. _cameraTransformMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraRotationMatrix: Matrix;
  8582. /** @hidden */
  8583. _referencePoint: Vector3;
  8584. /** @hidden */
  8585. _transformedReferencePoint: Vector3;
  8586. protected _globalCurrentTarget: Vector3;
  8587. protected _globalCurrentUpVector: Vector3;
  8588. /** @hidden */
  8589. _reset: () => void;
  8590. private _defaultUp;
  8591. /**
  8592. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8593. * This is the base of the follow, arc rotate cameras and Free camera
  8594. * @see http://doc.babylonjs.com/features/cameras
  8595. * @param name Defines the name of the camera in the scene
  8596. * @param position Defines the start position of the camera in the scene
  8597. * @param scene Defines the scene the camera belongs to
  8598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8599. */
  8600. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8601. /**
  8602. * Gets the position in front of the camera at a given distance.
  8603. * @param distance The distance from the camera we want the position to be
  8604. * @returns the position
  8605. */
  8606. getFrontPosition(distance: number): Vector3;
  8607. /** @hidden */
  8608. _getLockedTargetPosition(): Nullable<Vector3>;
  8609. private _storedPosition;
  8610. private _storedRotation;
  8611. private _storedRotationQuaternion;
  8612. /**
  8613. * Store current camera state of the camera (fov, position, rotation, etc..)
  8614. * @returns the camera
  8615. */
  8616. storeState(): Camera;
  8617. /**
  8618. * Restored camera state. You must call storeState() first
  8619. * @returns whether it was successful or not
  8620. * @hidden
  8621. */
  8622. _restoreStateValues(): boolean;
  8623. /** @hidden */
  8624. _initCache(): void;
  8625. /** @hidden */
  8626. _updateCache(ignoreParentClass?: boolean): void;
  8627. /** @hidden */
  8628. _isSynchronizedViewMatrix(): boolean;
  8629. /** @hidden */
  8630. _computeLocalCameraSpeed(): number;
  8631. /**
  8632. * Defines the target the camera should look at.
  8633. * This will automatically adapt alpha beta and radius to fit within the new target.
  8634. * @param target Defines the new target as a Vector or a mesh
  8635. */
  8636. setTarget(target: Vector3): void;
  8637. /**
  8638. * Return the current target position of the camera. This value is expressed in local space.
  8639. * @returns the target position
  8640. */
  8641. getTarget(): Vector3;
  8642. /** @hidden */
  8643. _decideIfNeedsToMove(): boolean;
  8644. /** @hidden */
  8645. _updatePosition(): void;
  8646. /** @hidden */
  8647. _checkInputs(): void;
  8648. protected _updateCameraRotationMatrix(): void;
  8649. /**
  8650. * 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)
  8651. * @returns the current camera
  8652. */
  8653. private _rotateUpVectorWithCameraRotationMatrix;
  8654. private _cachedRotationZ;
  8655. private _cachedQuaternionRotationZ;
  8656. /** @hidden */
  8657. _getViewMatrix(): Matrix;
  8658. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8659. /**
  8660. * @hidden
  8661. */
  8662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8663. /**
  8664. * @hidden
  8665. */
  8666. _updateRigCameras(): void;
  8667. private _getRigCamPositionAndTarget;
  8668. /**
  8669. * Gets the current object class name.
  8670. * @return the class name
  8671. */
  8672. getClassName(): string;
  8673. }
  8674. }
  8675. declare module "babylonjs/Cameras/cameraInputsManager" {
  8676. import { Nullable } from "babylonjs/types";
  8677. import { Camera } from "babylonjs/Cameras/camera";
  8678. /**
  8679. * @ignore
  8680. * This is a list of all the different input types that are available in the application.
  8681. * Fo instance: ArcRotateCameraGamepadInput...
  8682. */
  8683. export var CameraInputTypes: {};
  8684. /**
  8685. * This is the contract to implement in order to create a new input class.
  8686. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8687. */
  8688. export interface ICameraInput<TCamera extends Camera> {
  8689. /**
  8690. * Defines the camera the input is attached to.
  8691. */
  8692. camera: Nullable<TCamera>;
  8693. /**
  8694. * Gets the class name of the current intput.
  8695. * @returns the class name
  8696. */
  8697. getClassName(): string;
  8698. /**
  8699. * Get the friendly name associated with the input class.
  8700. * @returns the input friendly name
  8701. */
  8702. getSimpleName(): string;
  8703. /**
  8704. * Attach the input controls to a specific dom element to get the input from.
  8705. * @param element Defines the element the controls should be listened from
  8706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8707. */
  8708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8709. /**
  8710. * Detach the current controls from the specified dom element.
  8711. * @param element Defines the element to stop listening the inputs from
  8712. */
  8713. detachControl(element: Nullable<HTMLElement>): void;
  8714. /**
  8715. * Update the current camera state depending on the inputs that have been used this frame.
  8716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8717. */
  8718. checkInputs?: () => void;
  8719. }
  8720. /**
  8721. * Represents a map of input types to input instance or input index to input instance.
  8722. */
  8723. export interface CameraInputsMap<TCamera extends Camera> {
  8724. /**
  8725. * Accessor to the input by input type.
  8726. */
  8727. [name: string]: ICameraInput<TCamera>;
  8728. /**
  8729. * Accessor to the input by input index.
  8730. */
  8731. [idx: number]: ICameraInput<TCamera>;
  8732. }
  8733. /**
  8734. * This represents the input manager used within a camera.
  8735. * It helps dealing with all the different kind of input attached to a camera.
  8736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8737. */
  8738. export class CameraInputsManager<TCamera extends Camera> {
  8739. /**
  8740. * Defines the list of inputs attahed to the camera.
  8741. */
  8742. attached: CameraInputsMap<TCamera>;
  8743. /**
  8744. * Defines the dom element the camera is collecting inputs from.
  8745. * This is null if the controls have not been attached.
  8746. */
  8747. attachedElement: Nullable<HTMLElement>;
  8748. /**
  8749. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8750. */
  8751. noPreventDefault: boolean;
  8752. /**
  8753. * Defined the camera the input manager belongs to.
  8754. */
  8755. camera: TCamera;
  8756. /**
  8757. * Update the current camera state depending on the inputs that have been used this frame.
  8758. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8759. */
  8760. checkInputs: () => void;
  8761. /**
  8762. * Instantiate a new Camera Input Manager.
  8763. * @param camera Defines the camera the input manager blongs to
  8764. */
  8765. constructor(camera: TCamera);
  8766. /**
  8767. * Add an input method to a camera
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. * @param input camera input method
  8770. */
  8771. add(input: ICameraInput<TCamera>): void;
  8772. /**
  8773. * Remove a specific input method from a camera
  8774. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8775. * @param inputToRemove camera input method
  8776. */
  8777. remove(inputToRemove: ICameraInput<TCamera>): void;
  8778. /**
  8779. * Remove a specific input type from a camera
  8780. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8781. * @param inputType the type of the input to remove
  8782. */
  8783. removeByType(inputType: string): void;
  8784. private _addCheckInputs;
  8785. /**
  8786. * Attach the input controls to the currently attached dom element to listen the events from.
  8787. * @param input Defines the input to attach
  8788. */
  8789. attachInput(input: ICameraInput<TCamera>): void;
  8790. /**
  8791. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8792. * @param element Defines the dom element to collect the events from
  8793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8794. */
  8795. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8796. /**
  8797. * Detach the current manager inputs controls from a specific dom element.
  8798. * @param element Defines the dom element to collect the events from
  8799. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8800. */
  8801. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8802. /**
  8803. * Rebuild the dynamic inputCheck function from the current list of
  8804. * defined inputs in the manager.
  8805. */
  8806. rebuildInputCheck(): void;
  8807. /**
  8808. * Remove all attached input methods from a camera
  8809. */
  8810. clear(): void;
  8811. /**
  8812. * Serialize the current input manager attached to a camera.
  8813. * This ensures than once parsed,
  8814. * the input associated to the camera will be identical to the current ones
  8815. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8816. */
  8817. serialize(serializedCamera: any): void;
  8818. /**
  8819. * Parses an input manager serialized JSON to restore the previous list of inputs
  8820. * and states associated to a camera.
  8821. * @param parsedCamera Defines the JSON to parse
  8822. */
  8823. parse(parsedCamera: any): void;
  8824. }
  8825. }
  8826. declare module "babylonjs/Events/keyboardEvents" {
  8827. /**
  8828. * Gather the list of keyboard event types as constants.
  8829. */
  8830. export class KeyboardEventTypes {
  8831. /**
  8832. * The keydown event is fired when a key becomes active (pressed).
  8833. */
  8834. static readonly KEYDOWN: number;
  8835. /**
  8836. * The keyup event is fired when a key has been released.
  8837. */
  8838. static readonly KEYUP: number;
  8839. }
  8840. /**
  8841. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8842. */
  8843. export class KeyboardInfo {
  8844. /**
  8845. * Defines the type of event (KeyboardEventTypes)
  8846. */
  8847. type: number;
  8848. /**
  8849. * Defines the related dom event
  8850. */
  8851. event: KeyboardEvent;
  8852. /**
  8853. * Instantiates a new keyboard info.
  8854. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8855. * @param type Defines the type of event (KeyboardEventTypes)
  8856. * @param event Defines the related dom event
  8857. */
  8858. constructor(
  8859. /**
  8860. * Defines the type of event (KeyboardEventTypes)
  8861. */
  8862. type: number,
  8863. /**
  8864. * Defines the related dom event
  8865. */
  8866. event: KeyboardEvent);
  8867. }
  8868. /**
  8869. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8870. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8871. */
  8872. export class KeyboardInfoPre extends KeyboardInfo {
  8873. /**
  8874. * Defines the type of event (KeyboardEventTypes)
  8875. */
  8876. type: number;
  8877. /**
  8878. * Defines the related dom event
  8879. */
  8880. event: KeyboardEvent;
  8881. /**
  8882. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8883. */
  8884. skipOnPointerObservable: boolean;
  8885. /**
  8886. * Instantiates a new keyboard pre info.
  8887. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8888. * @param type Defines the type of event (KeyboardEventTypes)
  8889. * @param event Defines the related dom event
  8890. */
  8891. constructor(
  8892. /**
  8893. * Defines the type of event (KeyboardEventTypes)
  8894. */
  8895. type: number,
  8896. /**
  8897. * Defines the related dom event
  8898. */
  8899. event: KeyboardEvent);
  8900. }
  8901. }
  8902. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8903. import { Nullable } from "babylonjs/types";
  8904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8905. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8906. /**
  8907. * Manage the keyboard inputs to control the movement of a free camera.
  8908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8909. */
  8910. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8911. /**
  8912. * Defines the camera the input is attached to.
  8913. */
  8914. camera: FreeCamera;
  8915. /**
  8916. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8917. */
  8918. keysUp: number[];
  8919. /**
  8920. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8921. */
  8922. keysDown: number[];
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8925. */
  8926. keysLeft: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8929. */
  8930. keysRight: number[];
  8931. private _keys;
  8932. private _onCanvasBlurObserver;
  8933. private _onKeyboardObserver;
  8934. private _engine;
  8935. private _scene;
  8936. /**
  8937. * Attach the input controls to a specific dom element to get the input from.
  8938. * @param element Defines the element the controls should be listened from
  8939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8940. */
  8941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8942. /**
  8943. * Detach the current controls from the specified dom element.
  8944. * @param element Defines the element to stop listening the inputs from
  8945. */
  8946. detachControl(element: Nullable<HTMLElement>): void;
  8947. /**
  8948. * Update the current camera state depending on the inputs that have been used this frame.
  8949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8950. */
  8951. checkInputs(): void;
  8952. /**
  8953. * Gets the class name of the current intput.
  8954. * @returns the class name
  8955. */
  8956. getClassName(): string;
  8957. /** @hidden */
  8958. _onLostFocus(): void;
  8959. /**
  8960. * Get the friendly name associated with the input class.
  8961. * @returns the input friendly name
  8962. */
  8963. getSimpleName(): string;
  8964. }
  8965. }
  8966. declare module "babylonjs/Lights/shadowLight" {
  8967. import { Camera } from "babylonjs/Cameras/camera";
  8968. import { Scene } from "babylonjs/scene";
  8969. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8971. import { Light } from "babylonjs/Lights/light";
  8972. /**
  8973. * Interface describing all the common properties and methods a shadow light needs to implement.
  8974. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8975. * as well as binding the different shadow properties to the effects.
  8976. */
  8977. export interface IShadowLight extends Light {
  8978. /**
  8979. * The light id in the scene (used in scene.findLighById for instance)
  8980. */
  8981. id: string;
  8982. /**
  8983. * The position the shdow will be casted from.
  8984. */
  8985. position: Vector3;
  8986. /**
  8987. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8988. */
  8989. direction: Vector3;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. /**
  8999. * The friendly name of the light in the scene.
  9000. */
  9001. name: string;
  9002. /**
  9003. * Defines the shadow projection clipping minimum z value.
  9004. */
  9005. shadowMinZ: number;
  9006. /**
  9007. * Defines the shadow projection clipping maximum z value.
  9008. */
  9009. shadowMaxZ: number;
  9010. /**
  9011. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9012. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9013. */
  9014. computeTransformedInformation(): boolean;
  9015. /**
  9016. * Gets the scene the light belongs to.
  9017. * @returns The scene
  9018. */
  9019. getScene(): Scene;
  9020. /**
  9021. * Callback defining a custom Projection Matrix Builder.
  9022. * This can be used to override the default projection matrix computation.
  9023. */
  9024. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9025. /**
  9026. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9027. * @param matrix The materix to updated with the projection information
  9028. * @param viewMatrix The transform matrix of the light
  9029. * @param renderList The list of mesh to render in the map
  9030. * @returns The current light
  9031. */
  9032. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9033. /**
  9034. * Gets the current depth scale used in ESM.
  9035. * @returns The scale
  9036. */
  9037. getDepthScale(): number;
  9038. /**
  9039. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9040. * @returns true if a cube texture needs to be use
  9041. */
  9042. needCube(): boolean;
  9043. /**
  9044. * Detects if the projection matrix requires to be recomputed this frame.
  9045. * @returns true if it requires to be recomputed otherwise, false.
  9046. */
  9047. needProjectionMatrixCompute(): boolean;
  9048. /**
  9049. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9050. */
  9051. forceProjectionMatrixCompute(): void;
  9052. /**
  9053. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9054. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9055. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9056. */
  9057. getShadowDirection(faceIndex?: number): Vector3;
  9058. /**
  9059. * Gets the minZ used for shadow according to both the scene and the light.
  9060. * @param activeCamera The camera we are returning the min for
  9061. * @returns the depth min z
  9062. */
  9063. getDepthMinZ(activeCamera: Camera): number;
  9064. /**
  9065. * Gets the maxZ used for shadow according to both the scene and the light.
  9066. * @param activeCamera The camera we are returning the max for
  9067. * @returns the depth max z
  9068. */
  9069. getDepthMaxZ(activeCamera: Camera): number;
  9070. }
  9071. /**
  9072. * Base implementation IShadowLight
  9073. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9074. */
  9075. export abstract class ShadowLight extends Light implements IShadowLight {
  9076. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9077. protected _position: Vector3;
  9078. protected _setPosition(value: Vector3): void;
  9079. /**
  9080. * Sets the position the shadow will be casted from. Also use as the light position for both
  9081. * point and spot lights.
  9082. */
  9083. /**
  9084. * Sets the position the shadow will be casted from. Also use as the light position for both
  9085. * point and spot lights.
  9086. */
  9087. position: Vector3;
  9088. protected _direction: Vector3;
  9089. protected _setDirection(value: Vector3): void;
  9090. /**
  9091. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9092. * Also use as the light direction on spot and directional lights.
  9093. */
  9094. /**
  9095. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9096. * Also use as the light direction on spot and directional lights.
  9097. */
  9098. direction: Vector3;
  9099. private _shadowMinZ;
  9100. /**
  9101. * Gets the shadow projection clipping minimum z value.
  9102. */
  9103. /**
  9104. * Sets the shadow projection clipping minimum z value.
  9105. */
  9106. shadowMinZ: number;
  9107. private _shadowMaxZ;
  9108. /**
  9109. * Sets the shadow projection clipping maximum z value.
  9110. */
  9111. /**
  9112. * Gets the shadow projection clipping maximum z value.
  9113. */
  9114. shadowMaxZ: number;
  9115. /**
  9116. * Callback defining a custom Projection Matrix Builder.
  9117. * This can be used to override the default projection matrix computation.
  9118. */
  9119. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9120. /**
  9121. * The transformed position. Position of the light in world space taking parenting in account.
  9122. */
  9123. transformedPosition: Vector3;
  9124. /**
  9125. * The transformed direction. Direction of the light in world space taking parenting in account.
  9126. */
  9127. transformedDirection: Vector3;
  9128. private _needProjectionMatrixCompute;
  9129. /**
  9130. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9131. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9132. */
  9133. computeTransformedInformation(): boolean;
  9134. /**
  9135. * Return the depth scale used for the shadow map.
  9136. * @returns the depth scale.
  9137. */
  9138. getDepthScale(): number;
  9139. /**
  9140. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9141. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9142. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9143. */
  9144. getShadowDirection(faceIndex?: number): Vector3;
  9145. /**
  9146. * Returns the ShadowLight absolute position in the World.
  9147. * @returns the position vector in world space
  9148. */
  9149. getAbsolutePosition(): Vector3;
  9150. /**
  9151. * Sets the ShadowLight direction toward the passed target.
  9152. * @param target The point to target in local space
  9153. * @returns the updated ShadowLight direction
  9154. */
  9155. setDirectionToTarget(target: Vector3): Vector3;
  9156. /**
  9157. * Returns the light rotation in euler definition.
  9158. * @returns the x y z rotation in local space.
  9159. */
  9160. getRotation(): Vector3;
  9161. /**
  9162. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9163. * @returns true if a cube texture needs to be use
  9164. */
  9165. needCube(): boolean;
  9166. /**
  9167. * Detects if the projection matrix requires to be recomputed this frame.
  9168. * @returns true if it requires to be recomputed otherwise, false.
  9169. */
  9170. needProjectionMatrixCompute(): boolean;
  9171. /**
  9172. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9173. */
  9174. forceProjectionMatrixCompute(): void;
  9175. /** @hidden */
  9176. _initCache(): void;
  9177. /** @hidden */
  9178. _isSynchronized(): boolean;
  9179. /**
  9180. * Computes the world matrix of the node
  9181. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9182. * @returns the world matrix
  9183. */
  9184. computeWorldMatrix(force?: boolean): Matrix;
  9185. /**
  9186. * Gets the minZ used for shadow according to both the scene and the light.
  9187. * @param activeCamera The camera we are returning the min for
  9188. * @returns the depth min z
  9189. */
  9190. getDepthMinZ(activeCamera: Camera): number;
  9191. /**
  9192. * Gets the maxZ used for shadow according to both the scene and the light.
  9193. * @param activeCamera The camera we are returning the max for
  9194. * @returns the depth max z
  9195. */
  9196. getDepthMaxZ(activeCamera: Camera): number;
  9197. /**
  9198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9199. * @param matrix The materix to updated with the projection information
  9200. * @param viewMatrix The transform matrix of the light
  9201. * @param renderList The list of mesh to render in the map
  9202. * @returns The current light
  9203. */
  9204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9205. }
  9206. }
  9207. declare module "babylonjs/Materials/materialHelper" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Engine } from "babylonjs/Engines/engine";
  9211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9212. import { Light } from "babylonjs/Lights/light";
  9213. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9214. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9216. /**
  9217. * "Static Class" containing the most commonly used helper while dealing with material for
  9218. * rendering purpose.
  9219. *
  9220. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9221. *
  9222. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9223. */
  9224. export class MaterialHelper {
  9225. /**
  9226. * Bind the current view position to an effect.
  9227. * @param effect The effect to be bound
  9228. * @param scene The scene the eyes position is used from
  9229. */
  9230. static BindEyePosition(effect: Effect, scene: Scene): void;
  9231. /**
  9232. * Helps preparing the defines values about the UVs in used in the effect.
  9233. * UVs are shared as much as we can accross channels in the shaders.
  9234. * @param texture The texture we are preparing the UVs for
  9235. * @param defines The defines to update
  9236. * @param key The channel key "diffuse", "specular"... used in the shader
  9237. */
  9238. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9239. /**
  9240. * Binds a texture matrix value to its corrsponding uniform
  9241. * @param texture The texture to bind the matrix for
  9242. * @param uniformBuffer The uniform buffer receivin the data
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9246. /**
  9247. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9248. * @param mesh defines the current mesh
  9249. * @param scene defines the current scene
  9250. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9251. * @param pointsCloud defines if point cloud rendering has to be turned on
  9252. * @param fogEnabled defines if fog has to be turned on
  9253. * @param alphaTest defines if alpha testing has to be turned on
  9254. * @param defines defines the current list of defines
  9255. */
  9256. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9257. /**
  9258. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9259. * @param scene defines the current scene
  9260. * @param engine defines the current engine
  9261. * @param defines specifies the list of active defines
  9262. * @param useInstances defines if instances have to be turned on
  9263. * @param useClipPlane defines if clip plane have to be turned on
  9264. */
  9265. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9266. /**
  9267. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9268. * @param mesh The mesh containing the geometry data we will draw
  9269. * @param defines The defines to update
  9270. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9271. * @param useBones Precise whether bones should be used or not (override mesh info)
  9272. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9273. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9274. * @returns false if defines are considered not dirty and have not been checked
  9275. */
  9276. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9277. /**
  9278. * Prepares the defines related to the light information passed in parameter
  9279. * @param scene The scene we are intending to draw
  9280. * @param mesh The mesh the effect is compiling for
  9281. * @param defines The defines to update
  9282. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9283. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9284. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9285. * @returns true if normals will be required for the rest of the effect
  9286. */
  9287. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9288. /**
  9289. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9290. * that won t be acctive due to defines being turned off.
  9291. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9292. * @param samplersList The samplers list
  9293. * @param defines The defines helping in the list generation
  9294. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9295. */
  9296. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9297. /**
  9298. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9299. * @param defines The defines to update while falling back
  9300. * @param fallbacks The authorized effect fallbacks
  9301. * @param maxSimultaneousLights The maximum number of lights allowed
  9302. * @param rank the current rank of the Effect
  9303. * @returns The newly affected rank
  9304. */
  9305. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9306. /**
  9307. * Prepares the list of attributes required for morph targets according to the effect defines.
  9308. * @param attribs The current list of supported attribs
  9309. * @param mesh The mesh to prepare the morph targets attributes for
  9310. * @param defines The current Defines of the effect
  9311. */
  9312. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9313. /**
  9314. * Prepares the list of attributes required for bones according to the effect defines.
  9315. * @param attribs The current list of supported attribs
  9316. * @param mesh The mesh to prepare the bones attributes for
  9317. * @param defines The current Defines of the effect
  9318. * @param fallbacks The current efffect fallback strategy
  9319. */
  9320. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9321. /**
  9322. * Prepares the list of attributes required for instances according to the effect defines.
  9323. * @param attribs The current list of supported attribs
  9324. * @param defines The current Defines of the effect
  9325. */
  9326. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9327. /**
  9328. * Binds the light shadow information to the effect for the given mesh.
  9329. * @param light The light containing the generator
  9330. * @param scene The scene the lights belongs to
  9331. * @param mesh The mesh we are binding the information to render
  9332. * @param lightIndex The light index in the effect used to render the mesh
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9336. /**
  9337. * Binds the light information to the effect.
  9338. * @param light The light containing the generator
  9339. * @param effect The effect we are binding the data to
  9340. * @param lightIndex The light index in the effect used to render
  9341. */
  9342. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9343. /**
  9344. * Binds the lights information from the scene to the effect for the given mesh.
  9345. * @param scene The scene the lights belongs to
  9346. * @param mesh The mesh we are binding the information to render
  9347. * @param effect The effect we are binding the data to
  9348. * @param defines The generated defines for the effect
  9349. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9350. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9351. */
  9352. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9353. private static _tempFogColor;
  9354. /**
  9355. * Binds the fog information from the scene to the effect for the given mesh.
  9356. * @param scene The scene the lights belongs to
  9357. * @param mesh The mesh we are binding the information to render
  9358. * @param effect The effect we are binding the data to
  9359. * @param linearSpace Defines if the fog effect is applied in linear space
  9360. */
  9361. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9362. /**
  9363. * Binds the bones information from the mesh to the effect.
  9364. * @param mesh The mesh we are binding the information to render
  9365. * @param effect The effect we are binding the data to
  9366. */
  9367. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9368. /**
  9369. * Binds the morph targets information from the mesh to the effect.
  9370. * @param abstractMesh The mesh we are binding the information to render
  9371. * @param effect The effect we are binding the data to
  9372. */
  9373. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9374. /**
  9375. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9376. * @param defines The generated defines used in the effect
  9377. * @param effect The effect we are binding the data to
  9378. * @param scene The scene we are willing to render with logarithmic scale for
  9379. */
  9380. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9381. /**
  9382. * Binds the clip plane information from the scene to the effect.
  9383. * @param scene The scene the clip plane information are extracted from
  9384. * @param effect The effect we are binding the data to
  9385. */
  9386. static BindClipPlane(effect: Effect, scene: Scene): void;
  9387. }
  9388. }
  9389. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9390. /** @hidden */
  9391. export var kernelBlurVaryingDeclaration: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9397. /** @hidden */
  9398. export var kernelBlurFragment: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9404. /** @hidden */
  9405. export var kernelBlurFragment2: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9411. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9412. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9413. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9414. /** @hidden */
  9415. export var kernelBlurPixelShader: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9421. /** @hidden */
  9422. export var kernelBlurVertex: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9428. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9429. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9430. /** @hidden */
  9431. export var kernelBlurVertexShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9437. import { Vector2 } from "babylonjs/Maths/math";
  9438. import { Nullable } from "babylonjs/types";
  9439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9440. import { Camera } from "babylonjs/Cameras/camera";
  9441. import { Effect } from "babylonjs/Materials/effect";
  9442. import { Engine } from "babylonjs/Engines/engine";
  9443. import "babylonjs/Shaders/kernelBlur.fragment";
  9444. import "babylonjs/Shaders/kernelBlur.vertex";
  9445. /**
  9446. * The Blur Post Process which blurs an image based on a kernel and direction.
  9447. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9448. */
  9449. export class BlurPostProcess extends PostProcess {
  9450. /** The direction in which to blur the image. */
  9451. direction: Vector2;
  9452. private blockCompilation;
  9453. protected _kernel: number;
  9454. protected _idealKernel: number;
  9455. protected _packedFloat: boolean;
  9456. private _staticDefines;
  9457. /**
  9458. * Sets the length in pixels of the blur sample region
  9459. */
  9460. /**
  9461. * Gets the length in pixels of the blur sample region
  9462. */
  9463. kernel: number;
  9464. /**
  9465. * Sets wether or not the blur needs to unpack/repack floats
  9466. */
  9467. /**
  9468. * Gets wether or not the blur is unpacking/repacking floats
  9469. */
  9470. packedFloat: boolean;
  9471. /**
  9472. * Creates a new instance BlurPostProcess
  9473. * @param name The name of the effect.
  9474. * @param direction The direction in which to blur the image.
  9475. * @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.
  9476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9477. * @param camera The camera to apply the render pass to.
  9478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9479. * @param engine The engine which the post process will be applied. (default: current engine)
  9480. * @param reusable If the post process can be reused on the same frame. (default: false)
  9481. * @param textureType Type of textures used when performing the post process. (default: 0)
  9482. * @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)
  9483. */
  9484. constructor(name: string,
  9485. /** The direction in which to blur the image. */
  9486. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9487. /**
  9488. * Updates the effect with the current post process compile time values and recompiles the shader.
  9489. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9490. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9491. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9492. * @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
  9493. * @param onCompiled Called when the shader has been compiled.
  9494. * @param onError Called if there is an error when compiling a shader.
  9495. */
  9496. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9497. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9498. /**
  9499. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9500. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9501. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9502. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9503. * The gaps between physical kernels are compensated for in the weighting of the samples
  9504. * @param idealKernel Ideal blur kernel.
  9505. * @return Nearest best kernel.
  9506. */
  9507. protected _nearestBestKernel(idealKernel: number): number;
  9508. /**
  9509. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9510. * @param x The point on the Gaussian distribution to sample.
  9511. * @return the value of the Gaussian function at x.
  9512. */
  9513. protected _gaussianWeight(x: number): number;
  9514. /**
  9515. * Generates a string that can be used as a floating point number in GLSL.
  9516. * @param x Value to print.
  9517. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9518. * @return GLSL float string.
  9519. */
  9520. protected _glslFloat(x: number, decimalFigures?: number): string;
  9521. }
  9522. }
  9523. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9524. /** @hidden */
  9525. export var shadowMapPixelShader: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9531. /** @hidden */
  9532. export var bonesDeclaration: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9538. /** @hidden */
  9539. export var morphTargetsVertexGlobalDeclaration: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9545. /** @hidden */
  9546. export var morphTargetsVertexDeclaration: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9552. /** @hidden */
  9553. export var instancesDeclaration: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9559. /** @hidden */
  9560. export var helperFunctions: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9566. /** @hidden */
  9567. export var morphTargetsVertex: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9573. /** @hidden */
  9574. export var instancesVertex: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9580. /** @hidden */
  9581. export var bonesVertex: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9587. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9590. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9592. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9593. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9594. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9595. /** @hidden */
  9596. export var shadowMapVertexShader: {
  9597. name: string;
  9598. shader: string;
  9599. };
  9600. }
  9601. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9602. /** @hidden */
  9603. export var depthBoxBlurPixelShader: {
  9604. name: string;
  9605. shader: string;
  9606. };
  9607. }
  9608. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9609. import { Nullable } from "babylonjs/types";
  9610. import { Scene } from "babylonjs/scene";
  9611. import { Matrix } from "babylonjs/Maths/math";
  9612. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9614. import { Mesh } from "babylonjs/Meshes/mesh";
  9615. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9616. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9617. import { Effect } from "babylonjs/Materials/effect";
  9618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9619. import "babylonjs/Shaders/shadowMap.fragment";
  9620. import "babylonjs/Shaders/shadowMap.vertex";
  9621. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9622. import { Observable } from "babylonjs/Misc/observable";
  9623. /**
  9624. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9625. */
  9626. export interface ICustomShaderOptions {
  9627. /**
  9628. * Gets or sets the custom shader name to use
  9629. */
  9630. shaderName: string;
  9631. /**
  9632. * The list of attribute names used in the shader
  9633. */
  9634. attributes?: string[];
  9635. /**
  9636. * The list of unifrom names used in the shader
  9637. */
  9638. uniforms?: string[];
  9639. /**
  9640. * The list of sampler names used in the shader
  9641. */
  9642. samplers?: string[];
  9643. /**
  9644. * The list of defines used in the shader
  9645. */
  9646. defines?: string[];
  9647. }
  9648. /**
  9649. * Interface to implement to create a shadow generator compatible with BJS.
  9650. */
  9651. export interface IShadowGenerator {
  9652. /**
  9653. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9654. * @returns The render target texture if present otherwise, null
  9655. */
  9656. getShadowMap(): Nullable<RenderTargetTexture>;
  9657. /**
  9658. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9659. * @returns The render target texture if the shadow map is present otherwise, null
  9660. */
  9661. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9662. /**
  9663. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9664. * @param subMesh The submesh we want to render in the shadow map
  9665. * @param useInstances Defines wether will draw in the map using instances
  9666. * @returns true if ready otherwise, false
  9667. */
  9668. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9669. /**
  9670. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9671. * @param defines Defines of the material we want to update
  9672. * @param lightIndex Index of the light in the enabled light list of the material
  9673. */
  9674. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9675. /**
  9676. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9677. * defined in the generator but impacting the effect).
  9678. * It implies the unifroms available on the materials are the standard BJS ones.
  9679. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9680. * @param effect The effect we are binfing the information for
  9681. */
  9682. bindShadowLight(lightIndex: string, effect: Effect): void;
  9683. /**
  9684. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9685. * (eq to shadow prjection matrix * light transform matrix)
  9686. * @returns The transform matrix used to create the shadow map
  9687. */
  9688. getTransformMatrix(): Matrix;
  9689. /**
  9690. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9691. * Cube and 2D textures for instance.
  9692. */
  9693. recreateShadowMap(): void;
  9694. /**
  9695. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9696. * @param onCompiled Callback triggered at the and of the effects compilation
  9697. * @param options Sets of optional options forcing the compilation with different modes
  9698. */
  9699. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9700. useInstances: boolean;
  9701. }>): void;
  9702. /**
  9703. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9704. * @param options Sets of optional options forcing the compilation with different modes
  9705. * @returns A promise that resolves when the compilation completes
  9706. */
  9707. forceCompilationAsync(options?: Partial<{
  9708. useInstances: boolean;
  9709. }>): Promise<void>;
  9710. /**
  9711. * Serializes the shadow generator setup to a json object.
  9712. * @returns The serialized JSON object
  9713. */
  9714. serialize(): any;
  9715. /**
  9716. * Disposes the Shadow map and related Textures and effects.
  9717. */
  9718. dispose(): void;
  9719. }
  9720. /**
  9721. * Default implementation IShadowGenerator.
  9722. * This is the main object responsible of generating shadows in the framework.
  9723. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9724. */
  9725. export class ShadowGenerator implements IShadowGenerator {
  9726. /**
  9727. * Shadow generator mode None: no filtering applied.
  9728. */
  9729. static readonly FILTER_NONE: number;
  9730. /**
  9731. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9733. */
  9734. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9735. /**
  9736. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9737. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9738. */
  9739. static readonly FILTER_POISSONSAMPLING: number;
  9740. /**
  9741. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9742. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9743. */
  9744. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9745. /**
  9746. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9747. * edge artifacts on steep falloff.
  9748. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9749. */
  9750. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9751. /**
  9752. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9753. * edge artifacts on steep falloff.
  9754. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9755. */
  9756. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9757. /**
  9758. * Shadow generator mode PCF: Percentage Closer Filtering
  9759. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9760. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9761. */
  9762. static readonly FILTER_PCF: number;
  9763. /**
  9764. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9765. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9766. * Contact Hardening
  9767. */
  9768. static readonly FILTER_PCSS: number;
  9769. /**
  9770. * Reserved for PCF and PCSS
  9771. * Highest Quality.
  9772. *
  9773. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9774. *
  9775. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9776. */
  9777. static readonly QUALITY_HIGH: number;
  9778. /**
  9779. * Reserved for PCF and PCSS
  9780. * Good tradeoff for quality/perf cross devices
  9781. *
  9782. * Execute PCF on a 3*3 kernel.
  9783. *
  9784. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9785. */
  9786. static readonly QUALITY_MEDIUM: number;
  9787. /**
  9788. * Reserved for PCF and PCSS
  9789. * The lowest quality but the fastest.
  9790. *
  9791. * Execute PCF on a 1*1 kernel.
  9792. *
  9793. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9794. */
  9795. static readonly QUALITY_LOW: number;
  9796. /** Gets or sets the custom shader name to use */
  9797. customShaderOptions: ICustomShaderOptions;
  9798. /**
  9799. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9800. */
  9801. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9802. /**
  9803. * Observable triggered before a mesh is rendered in the shadow map.
  9804. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9805. */
  9806. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9807. private _bias;
  9808. /**
  9809. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9810. */
  9811. /**
  9812. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9813. */
  9814. bias: number;
  9815. private _normalBias;
  9816. /**
  9817. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9818. */
  9819. /**
  9820. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9821. */
  9822. normalBias: number;
  9823. private _blurBoxOffset;
  9824. /**
  9825. * Gets the blur box offset: offset applied during the blur pass.
  9826. * Only useful if useKernelBlur = false
  9827. */
  9828. /**
  9829. * Sets the blur box offset: offset applied during the blur pass.
  9830. * Only useful if useKernelBlur = false
  9831. */
  9832. blurBoxOffset: number;
  9833. private _blurScale;
  9834. /**
  9835. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9836. * 2 means half of the size.
  9837. */
  9838. /**
  9839. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9840. * 2 means half of the size.
  9841. */
  9842. blurScale: number;
  9843. private _blurKernel;
  9844. /**
  9845. * Gets the blur kernel: kernel size of the blur pass.
  9846. * Only useful if useKernelBlur = true
  9847. */
  9848. /**
  9849. * Sets the blur kernel: kernel size of the blur pass.
  9850. * Only useful if useKernelBlur = true
  9851. */
  9852. blurKernel: number;
  9853. private _useKernelBlur;
  9854. /**
  9855. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9856. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9857. */
  9858. /**
  9859. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9860. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9861. */
  9862. useKernelBlur: boolean;
  9863. private _depthScale;
  9864. /**
  9865. * Gets the depth scale used in ESM mode.
  9866. */
  9867. /**
  9868. * Sets the depth scale used in ESM mode.
  9869. * This can override the scale stored on the light.
  9870. */
  9871. depthScale: number;
  9872. private _filter;
  9873. /**
  9874. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9875. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9876. */
  9877. /**
  9878. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9879. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9880. */
  9881. filter: number;
  9882. /**
  9883. * Gets if the current filter is set to Poisson Sampling.
  9884. */
  9885. /**
  9886. * Sets the current filter to Poisson Sampling.
  9887. */
  9888. usePoissonSampling: boolean;
  9889. /**
  9890. * Gets if the current filter is set to ESM.
  9891. */
  9892. /**
  9893. * Sets the current filter is to ESM.
  9894. */
  9895. useExponentialShadowMap: boolean;
  9896. /**
  9897. * Gets if the current filter is set to filtered ESM.
  9898. */
  9899. /**
  9900. * Gets if the current filter is set to filtered ESM.
  9901. */
  9902. useBlurExponentialShadowMap: boolean;
  9903. /**
  9904. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9905. * exponential to prevent steep falloff artifacts).
  9906. */
  9907. /**
  9908. * Sets the current filter to "close ESM" (using the inverse of the
  9909. * exponential to prevent steep falloff artifacts).
  9910. */
  9911. useCloseExponentialShadowMap: boolean;
  9912. /**
  9913. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9914. * exponential to prevent steep falloff artifacts).
  9915. */
  9916. /**
  9917. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9918. * exponential to prevent steep falloff artifacts).
  9919. */
  9920. useBlurCloseExponentialShadowMap: boolean;
  9921. /**
  9922. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9923. */
  9924. /**
  9925. * Sets the current filter to "PCF" (percentage closer filtering).
  9926. */
  9927. usePercentageCloserFiltering: boolean;
  9928. private _filteringQuality;
  9929. /**
  9930. * Gets the PCF or PCSS Quality.
  9931. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9932. */
  9933. /**
  9934. * Sets the PCF or PCSS Quality.
  9935. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9936. */
  9937. filteringQuality: number;
  9938. /**
  9939. * Gets if the current filter is set to "PCSS" (contact hardening).
  9940. */
  9941. /**
  9942. * Sets the current filter to "PCSS" (contact hardening).
  9943. */
  9944. useContactHardeningShadow: boolean;
  9945. private _contactHardeningLightSizeUVRatio;
  9946. /**
  9947. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9948. * Using a ratio helps keeping shape stability independently of the map size.
  9949. *
  9950. * It does not account for the light projection as it was having too much
  9951. * instability during the light setup or during light position changes.
  9952. *
  9953. * Only valid if useContactHardeningShadow is true.
  9954. */
  9955. /**
  9956. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9957. * Using a ratio helps keeping shape stability independently of the map size.
  9958. *
  9959. * It does not account for the light projection as it was having too much
  9960. * instability during the light setup or during light position changes.
  9961. *
  9962. * Only valid if useContactHardeningShadow is true.
  9963. */
  9964. contactHardeningLightSizeUVRatio: number;
  9965. private _darkness;
  9966. /**
  9967. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9968. * 0 means strongest and 1 would means no shadow.
  9969. * @returns the darkness.
  9970. */
  9971. getDarkness(): number;
  9972. /**
  9973. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9974. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9975. * @returns the shadow generator allowing fluent coding.
  9976. */
  9977. setDarkness(darkness: number): ShadowGenerator;
  9978. private _transparencyShadow;
  9979. /**
  9980. * Sets the ability to have transparent shadow (boolean).
  9981. * @param transparent True if transparent else False
  9982. * @returns the shadow generator allowing fluent coding
  9983. */
  9984. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9985. private _shadowMap;
  9986. private _shadowMap2;
  9987. /**
  9988. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9989. * @returns The render target texture if present otherwise, null
  9990. */
  9991. getShadowMap(): Nullable<RenderTargetTexture>;
  9992. /**
  9993. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9994. * @returns The render target texture if the shadow map is present otherwise, null
  9995. */
  9996. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9997. /**
  9998. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9999. * @param mesh Mesh to add
  10000. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10001. * @returns the Shadow Generator itself
  10002. */
  10003. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10004. /**
  10005. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10006. * @param mesh Mesh to remove
  10007. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10008. * @returns the Shadow Generator itself
  10009. */
  10010. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10011. /**
  10012. * Controls the extent to which the shadows fade out at the edge of the frustum
  10013. * Used only by directionals and spots
  10014. */
  10015. frustumEdgeFalloff: number;
  10016. private _light;
  10017. /**
  10018. * Returns the associated light object.
  10019. * @returns the light generating the shadow
  10020. */
  10021. getLight(): IShadowLight;
  10022. /**
  10023. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10024. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10025. * It might on the other hand introduce peter panning.
  10026. */
  10027. forceBackFacesOnly: boolean;
  10028. private _scene;
  10029. private _lightDirection;
  10030. private _effect;
  10031. private _viewMatrix;
  10032. private _projectionMatrix;
  10033. private _transformMatrix;
  10034. private _cachedPosition;
  10035. private _cachedDirection;
  10036. private _cachedDefines;
  10037. private _currentRenderID;
  10038. private _boxBlurPostprocess;
  10039. private _kernelBlurXPostprocess;
  10040. private _kernelBlurYPostprocess;
  10041. private _blurPostProcesses;
  10042. private _mapSize;
  10043. private _currentFaceIndex;
  10044. private _currentFaceIndexCache;
  10045. private _textureType;
  10046. private _defaultTextureMatrix;
  10047. /** @hidden */
  10048. static _SceneComponentInitialization: (scene: Scene) => void;
  10049. /**
  10050. * Creates a ShadowGenerator object.
  10051. * A ShadowGenerator is the required tool to use the shadows.
  10052. * Each light casting shadows needs to use its own ShadowGenerator.
  10053. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10054. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10055. * @param light The light object generating the shadows.
  10056. * @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.
  10057. */
  10058. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10059. private _initializeGenerator;
  10060. private _initializeShadowMap;
  10061. private _initializeBlurRTTAndPostProcesses;
  10062. private _renderForShadowMap;
  10063. private _renderSubMeshForShadowMap;
  10064. private _applyFilterValues;
  10065. /**
  10066. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10067. * @param onCompiled Callback triggered at the and of the effects compilation
  10068. * @param options Sets of optional options forcing the compilation with different modes
  10069. */
  10070. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10071. useInstances: boolean;
  10072. }>): void;
  10073. /**
  10074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10075. * @param options Sets of optional options forcing the compilation with different modes
  10076. * @returns A promise that resolves when the compilation completes
  10077. */
  10078. forceCompilationAsync(options?: Partial<{
  10079. useInstances: boolean;
  10080. }>): Promise<void>;
  10081. /**
  10082. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10083. * @param subMesh The submesh we want to render in the shadow map
  10084. * @param useInstances Defines wether will draw in the map using instances
  10085. * @returns true if ready otherwise, false
  10086. */
  10087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10088. /**
  10089. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10090. * @param defines Defines of the material we want to update
  10091. * @param lightIndex Index of the light in the enabled light list of the material
  10092. */
  10093. prepareDefines(defines: any, lightIndex: number): void;
  10094. /**
  10095. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10096. * defined in the generator but impacting the effect).
  10097. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10098. * @param effect The effect we are binfing the information for
  10099. */
  10100. bindShadowLight(lightIndex: string, effect: Effect): void;
  10101. /**
  10102. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10103. * (eq to shadow prjection matrix * light transform matrix)
  10104. * @returns The transform matrix used to create the shadow map
  10105. */
  10106. getTransformMatrix(): Matrix;
  10107. /**
  10108. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10109. * Cube and 2D textures for instance.
  10110. */
  10111. recreateShadowMap(): void;
  10112. private _disposeBlurPostProcesses;
  10113. private _disposeRTTandPostProcesses;
  10114. /**
  10115. * Disposes the ShadowGenerator.
  10116. * Returns nothing.
  10117. */
  10118. dispose(): void;
  10119. /**
  10120. * Serializes the shadow generator setup to a json object.
  10121. * @returns The serialized JSON object
  10122. */
  10123. serialize(): any;
  10124. /**
  10125. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10126. * @param parsedShadowGenerator The JSON object to parse
  10127. * @param scene The scene to create the shadow map for
  10128. * @returns The parsed shadow generator
  10129. */
  10130. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10131. }
  10132. }
  10133. declare module "babylonjs/Lights/light" {
  10134. import { Nullable } from "babylonjs/types";
  10135. import { Scene } from "babylonjs/scene";
  10136. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10137. import { Node } from "babylonjs/node";
  10138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10139. import { Effect } from "babylonjs/Materials/effect";
  10140. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10141. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10142. /**
  10143. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10144. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10145. * 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.
  10146. */
  10147. export abstract class Light extends Node {
  10148. /**
  10149. * Falloff Default: light is falling off following the material specification:
  10150. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10151. */
  10152. static readonly FALLOFF_DEFAULT: number;
  10153. /**
  10154. * Falloff Physical: light is falling off following the inverse squared distance law.
  10155. */
  10156. static readonly FALLOFF_PHYSICAL: number;
  10157. /**
  10158. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10159. * to enhance interoperability with other engines.
  10160. */
  10161. static readonly FALLOFF_GLTF: number;
  10162. /**
  10163. * Falloff Standard: light is falling off like in the standard material
  10164. * to enhance interoperability with other materials.
  10165. */
  10166. static readonly FALLOFF_STANDARD: number;
  10167. /**
  10168. * If every light affecting the material is in this lightmapMode,
  10169. * material.lightmapTexture adds or multiplies
  10170. * (depends on material.useLightmapAsShadowmap)
  10171. * after every other light calculations.
  10172. */
  10173. static readonly LIGHTMAP_DEFAULT: number;
  10174. /**
  10175. * material.lightmapTexture as only diffuse lighting from this light
  10176. * adds only specular lighting from this light
  10177. * adds dynamic shadows
  10178. */
  10179. static readonly LIGHTMAP_SPECULAR: number;
  10180. /**
  10181. * material.lightmapTexture as only lighting
  10182. * no light calculation from this light
  10183. * only adds dynamic shadows from this light
  10184. */
  10185. static readonly LIGHTMAP_SHADOWSONLY: number;
  10186. /**
  10187. * Each light type uses the default quantity according to its type:
  10188. * point/spot lights use luminous intensity
  10189. * directional lights use illuminance
  10190. */
  10191. static readonly INTENSITYMODE_AUTOMATIC: number;
  10192. /**
  10193. * lumen (lm)
  10194. */
  10195. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10196. /**
  10197. * candela (lm/sr)
  10198. */
  10199. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10200. /**
  10201. * lux (lm/m^2)
  10202. */
  10203. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10204. /**
  10205. * nit (cd/m^2)
  10206. */
  10207. static readonly INTENSITYMODE_LUMINANCE: number;
  10208. /**
  10209. * Light type const id of the point light.
  10210. */
  10211. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10212. /**
  10213. * Light type const id of the directional light.
  10214. */
  10215. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10216. /**
  10217. * Light type const id of the spot light.
  10218. */
  10219. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10220. /**
  10221. * Light type const id of the hemispheric light.
  10222. */
  10223. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10224. /**
  10225. * Diffuse gives the basic color to an object.
  10226. */
  10227. diffuse: Color3;
  10228. /**
  10229. * Specular produces a highlight color on an object.
  10230. * Note: This is note affecting PBR materials.
  10231. */
  10232. specular: Color3;
  10233. /**
  10234. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10235. * falling off base on range or angle.
  10236. * This can be set to any values in Light.FALLOFF_x.
  10237. *
  10238. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10239. * other types of materials.
  10240. */
  10241. falloffType: number;
  10242. /**
  10243. * Strength of the light.
  10244. * Note: By default it is define in the framework own unit.
  10245. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10246. */
  10247. intensity: number;
  10248. private _range;
  10249. protected _inverseSquaredRange: number;
  10250. /**
  10251. * Defines how far from the source the light is impacting in scene units.
  10252. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10253. */
  10254. /**
  10255. * Defines how far from the source the light is impacting in scene units.
  10256. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10257. */
  10258. range: number;
  10259. /**
  10260. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10261. * of light.
  10262. */
  10263. private _photometricScale;
  10264. private _intensityMode;
  10265. /**
  10266. * Gets the photometric scale used to interpret the intensity.
  10267. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10268. */
  10269. /**
  10270. * Sets the photometric scale used to interpret the intensity.
  10271. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10272. */
  10273. intensityMode: number;
  10274. private _radius;
  10275. /**
  10276. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10277. */
  10278. /**
  10279. * sets the light radius used by PBR Materials to simulate soft area lights.
  10280. */
  10281. radius: number;
  10282. private _renderPriority;
  10283. /**
  10284. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10285. * exceeding the number allowed of the materials.
  10286. */
  10287. renderPriority: number;
  10288. private _shadowEnabled;
  10289. /**
  10290. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10291. * the current shadow generator.
  10292. */
  10293. /**
  10294. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10295. * the current shadow generator.
  10296. */
  10297. shadowEnabled: boolean;
  10298. private _includedOnlyMeshes;
  10299. /**
  10300. * Gets the only meshes impacted by this light.
  10301. */
  10302. /**
  10303. * Sets the only meshes impacted by this light.
  10304. */
  10305. includedOnlyMeshes: AbstractMesh[];
  10306. private _excludedMeshes;
  10307. /**
  10308. * Gets the meshes not impacted by this light.
  10309. */
  10310. /**
  10311. * Sets the meshes not impacted by this light.
  10312. */
  10313. excludedMeshes: AbstractMesh[];
  10314. private _excludeWithLayerMask;
  10315. /**
  10316. * Gets the layer id use to find what meshes are not impacted by the light.
  10317. * Inactive if 0
  10318. */
  10319. /**
  10320. * Sets the layer id use to find what meshes are not impacted by the light.
  10321. * Inactive if 0
  10322. */
  10323. excludeWithLayerMask: number;
  10324. private _includeOnlyWithLayerMask;
  10325. /**
  10326. * Gets the layer id use to find what meshes are impacted by the light.
  10327. * Inactive if 0
  10328. */
  10329. /**
  10330. * Sets the layer id use to find what meshes are impacted by the light.
  10331. * Inactive if 0
  10332. */
  10333. includeOnlyWithLayerMask: number;
  10334. private _lightmapMode;
  10335. /**
  10336. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10337. */
  10338. /**
  10339. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10340. */
  10341. lightmapMode: number;
  10342. /**
  10343. * Shadow generator associted to the light.
  10344. * @hidden Internal use only.
  10345. */
  10346. _shadowGenerator: Nullable<IShadowGenerator>;
  10347. /**
  10348. * @hidden Internal use only.
  10349. */
  10350. _excludedMeshesIds: string[];
  10351. /**
  10352. * @hidden Internal use only.
  10353. */
  10354. _includedOnlyMeshesIds: string[];
  10355. /**
  10356. * The current light unifom buffer.
  10357. * @hidden Internal use only.
  10358. */
  10359. _uniformBuffer: UniformBuffer;
  10360. /**
  10361. * Creates a Light object in the scene.
  10362. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10363. * @param name The firendly name of the light
  10364. * @param scene The scene the light belongs too
  10365. */
  10366. constructor(name: string, scene: Scene);
  10367. protected abstract _buildUniformLayout(): void;
  10368. /**
  10369. * Sets the passed Effect "effect" with the Light information.
  10370. * @param effect The effect to update
  10371. * @param lightIndex The index of the light in the effect to update
  10372. * @returns The light
  10373. */
  10374. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10375. /**
  10376. * Returns the string "Light".
  10377. * @returns the class name
  10378. */
  10379. getClassName(): string;
  10380. /** @hidden */
  10381. readonly _isLight: boolean;
  10382. /**
  10383. * Converts the light information to a readable string for debug purpose.
  10384. * @param fullDetails Supports for multiple levels of logging within scene loading
  10385. * @returns the human readable light info
  10386. */
  10387. toString(fullDetails?: boolean): string;
  10388. /** @hidden */
  10389. protected _syncParentEnabledState(): void;
  10390. /**
  10391. * Set the enabled state of this node.
  10392. * @param value - the new enabled state
  10393. */
  10394. setEnabled(value: boolean): void;
  10395. /**
  10396. * Returns the Light associated shadow generator if any.
  10397. * @return the associated shadow generator.
  10398. */
  10399. getShadowGenerator(): Nullable<IShadowGenerator>;
  10400. /**
  10401. * Returns a Vector3, the absolute light position in the World.
  10402. * @returns the world space position of the light
  10403. */
  10404. getAbsolutePosition(): Vector3;
  10405. /**
  10406. * Specifies if the light will affect the passed mesh.
  10407. * @param mesh The mesh to test against the light
  10408. * @return true the mesh is affected otherwise, false.
  10409. */
  10410. canAffectMesh(mesh: AbstractMesh): boolean;
  10411. /**
  10412. * Sort function to order lights for rendering.
  10413. * @param a First Light object to compare to second.
  10414. * @param b Second Light object to compare first.
  10415. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10416. */
  10417. static CompareLightsPriority(a: Light, b: Light): number;
  10418. /**
  10419. * Releases resources associated with this node.
  10420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10422. */
  10423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10424. /**
  10425. * Returns the light type ID (integer).
  10426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10427. */
  10428. getTypeID(): number;
  10429. /**
  10430. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10431. * @returns the scaled intensity in intensity mode unit
  10432. */
  10433. getScaledIntensity(): number;
  10434. /**
  10435. * Returns a new Light object, named "name", from the current one.
  10436. * @param name The name of the cloned light
  10437. * @returns the new created light
  10438. */
  10439. clone(name: string): Nullable<Light>;
  10440. /**
  10441. * Serializes the current light into a Serialization object.
  10442. * @returns the serialized object.
  10443. */
  10444. serialize(): any;
  10445. /**
  10446. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10447. * This new light is named "name" and added to the passed scene.
  10448. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10449. * @param name The friendly name of the light
  10450. * @param scene The scene the new light will belong to
  10451. * @returns the constructor function
  10452. */
  10453. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10454. /**
  10455. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10456. * @param parsedLight The JSON representation of the light
  10457. * @param scene The scene to create the parsed light in
  10458. * @returns the created light after parsing
  10459. */
  10460. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10461. private _hookArrayForExcluded;
  10462. private _hookArrayForIncludedOnly;
  10463. private _resyncMeshes;
  10464. /**
  10465. * Forces the meshes to update their light related information in their rendering used effects
  10466. * @hidden Internal Use Only
  10467. */
  10468. _markMeshesAsLightDirty(): void;
  10469. /**
  10470. * Recomputes the cached photometric scale if needed.
  10471. */
  10472. private _computePhotometricScale;
  10473. /**
  10474. * Returns the Photometric Scale according to the light type and intensity mode.
  10475. */
  10476. private _getPhotometricScale;
  10477. /**
  10478. * Reorder the light in the scene according to their defined priority.
  10479. * @hidden Internal Use Only
  10480. */
  10481. _reorderLightsInScene(): void;
  10482. /**
  10483. * Prepares the list of defines specific to the light type.
  10484. * @param defines the list of defines
  10485. * @param lightIndex defines the index of the light for the effect
  10486. */
  10487. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10488. }
  10489. }
  10490. declare module "babylonjs/Actions/action" {
  10491. import { Observable } from "babylonjs/Misc/observable";
  10492. import { Condition } from "babylonjs/Actions/condition";
  10493. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10494. import { ActionManager } from "babylonjs/Actions/actionManager";
  10495. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10496. /**
  10497. * Interface used to define Action
  10498. */
  10499. export interface IAction {
  10500. /**
  10501. * Trigger for the action
  10502. */
  10503. trigger: number;
  10504. /** Options of the trigger */
  10505. triggerOptions: any;
  10506. /**
  10507. * Gets the trigger parameters
  10508. * @returns the trigger parameters
  10509. */
  10510. getTriggerParameter(): any;
  10511. /**
  10512. * Internal only - executes current action event
  10513. * @hidden
  10514. */
  10515. _executeCurrent(evt?: ActionEvent): void;
  10516. /**
  10517. * Serialize placeholder for child classes
  10518. * @param parent of child
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. _prepare(): void;
  10527. /**
  10528. * Internal only - manager for action
  10529. * @hidden
  10530. */
  10531. _actionManager: AbstractActionManager;
  10532. }
  10533. /**
  10534. * The action to be carried out following a trigger
  10535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10536. */
  10537. export class Action implements IAction {
  10538. /** the trigger, with or without parameters, for the action */
  10539. triggerOptions: any;
  10540. /**
  10541. * Trigger for the action
  10542. */
  10543. trigger: number;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. private _nextActiveAction;
  10550. private _child;
  10551. private _condition?;
  10552. private _triggerParameter;
  10553. /**
  10554. * An event triggered prior to action being executed.
  10555. */
  10556. onBeforeExecuteObservable: Observable<Action>;
  10557. /**
  10558. * Creates a new Action
  10559. * @param triggerOptions the trigger, with or without parameters, for the action
  10560. * @param condition an optional determinant of action
  10561. */
  10562. constructor(
  10563. /** the trigger, with or without parameters, for the action */
  10564. triggerOptions: any, condition?: Condition);
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. _prepare(): void;
  10570. /**
  10571. * Gets the trigger parameters
  10572. * @returns the trigger parameters
  10573. */
  10574. getTriggerParameter(): any;
  10575. /**
  10576. * Internal only - executes current action event
  10577. * @hidden
  10578. */
  10579. _executeCurrent(evt?: ActionEvent): void;
  10580. /**
  10581. * Execute placeholder for child classes
  10582. * @param evt optional action event
  10583. */
  10584. execute(evt?: ActionEvent): void;
  10585. /**
  10586. * Skips to next active action
  10587. */
  10588. skipToNextActiveAction(): void;
  10589. /**
  10590. * Adds action to chain of actions, may be a DoNothingAction
  10591. * @param action defines the next action to execute
  10592. * @returns The action passed in
  10593. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10594. */
  10595. then(action: Action): Action;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. _getProperty(propertyPath: string): string;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */
  10605. _getEffectiveTarget(target: any, propertyPath: string): any;
  10606. /**
  10607. * Serialize placeholder for child classes
  10608. * @param parent of child
  10609. * @returns the serialized object
  10610. */
  10611. serialize(parent: any): any;
  10612. /**
  10613. * Internal only called by serialize
  10614. * @hidden
  10615. */
  10616. protected _serialize(serializedAction: any, parent?: any): any;
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. static _SerializeValueAsString: (value: any) => string;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10627. name: string;
  10628. targetType: string;
  10629. value: string;
  10630. };
  10631. }
  10632. }
  10633. declare module "babylonjs/Actions/condition" {
  10634. import { ActionManager } from "babylonjs/Actions/actionManager";
  10635. /**
  10636. * A Condition applied to an Action
  10637. */
  10638. export class Condition {
  10639. /**
  10640. * Internal only - manager for action
  10641. * @hidden
  10642. */
  10643. _actionManager: ActionManager;
  10644. /**
  10645. * Internal only
  10646. * @hidden
  10647. */
  10648. _evaluationId: number;
  10649. /**
  10650. * Internal only
  10651. * @hidden
  10652. */
  10653. _currentResult: boolean;
  10654. /**
  10655. * Creates a new Condition
  10656. * @param actionManager the manager of the action the condition is applied to
  10657. */
  10658. constructor(actionManager: ActionManager);
  10659. /**
  10660. * Check if the current condition is valid
  10661. * @returns a boolean
  10662. */
  10663. isValid(): boolean;
  10664. /**
  10665. * Internal only
  10666. * @hidden
  10667. */
  10668. _getProperty(propertyPath: string): string;
  10669. /**
  10670. * Internal only
  10671. * @hidden
  10672. */
  10673. _getEffectiveTarget(target: any, propertyPath: string): any;
  10674. /**
  10675. * Serialize placeholder for child classes
  10676. * @returns the serialized object
  10677. */
  10678. serialize(): any;
  10679. /**
  10680. * Internal only
  10681. * @hidden
  10682. */
  10683. protected _serialize(serializedCondition: any): any;
  10684. }
  10685. /**
  10686. * Defines specific conditional operators as extensions of Condition
  10687. */
  10688. export class ValueCondition extends Condition {
  10689. /** path to specify the property of the target the conditional operator uses */
  10690. propertyPath: string;
  10691. /** the value compared by the conditional operator against the current value of the property */
  10692. value: any;
  10693. /** the conditional operator, default ValueCondition.IsEqual */
  10694. operator: number;
  10695. /**
  10696. * Internal only
  10697. * @hidden
  10698. */
  10699. private static _IsEqual;
  10700. /**
  10701. * Internal only
  10702. * @hidden
  10703. */
  10704. private static _IsDifferent;
  10705. /**
  10706. * Internal only
  10707. * @hidden
  10708. */
  10709. private static _IsGreater;
  10710. /**
  10711. * Internal only
  10712. * @hidden
  10713. */
  10714. private static _IsLesser;
  10715. /**
  10716. * returns the number for IsEqual
  10717. */
  10718. static readonly IsEqual: number;
  10719. /**
  10720. * Returns the number for IsDifferent
  10721. */
  10722. static readonly IsDifferent: number;
  10723. /**
  10724. * Returns the number for IsGreater
  10725. */
  10726. static readonly IsGreater: number;
  10727. /**
  10728. * Returns the number for IsLesser
  10729. */
  10730. static readonly IsLesser: number;
  10731. /**
  10732. * Internal only The action manager for the condition
  10733. * @hidden
  10734. */
  10735. _actionManager: ActionManager;
  10736. /**
  10737. * Internal only
  10738. * @hidden
  10739. */
  10740. private _target;
  10741. /**
  10742. * Internal only
  10743. * @hidden
  10744. */
  10745. private _effectiveTarget;
  10746. /**
  10747. * Internal only
  10748. * @hidden
  10749. */
  10750. private _property;
  10751. /**
  10752. * Creates a new ValueCondition
  10753. * @param actionManager manager for the action the condition applies to
  10754. * @param target for the action
  10755. * @param propertyPath path to specify the property of the target the conditional operator uses
  10756. * @param value the value compared by the conditional operator against the current value of the property
  10757. * @param operator the conditional operator, default ValueCondition.IsEqual
  10758. */
  10759. constructor(actionManager: ActionManager, target: any,
  10760. /** path to specify the property of the target the conditional operator uses */
  10761. propertyPath: string,
  10762. /** the value compared by the conditional operator against the current value of the property */
  10763. value: any,
  10764. /** the conditional operator, default ValueCondition.IsEqual */
  10765. operator?: number);
  10766. /**
  10767. * Compares the given value with the property value for the specified conditional operator
  10768. * @returns the result of the comparison
  10769. */
  10770. isValid(): boolean;
  10771. /**
  10772. * Serialize the ValueCondition into a JSON compatible object
  10773. * @returns serialization object
  10774. */
  10775. serialize(): any;
  10776. /**
  10777. * Gets the name of the conditional operator for the ValueCondition
  10778. * @param operator the conditional operator
  10779. * @returns the name
  10780. */
  10781. static GetOperatorName(operator: number): string;
  10782. }
  10783. /**
  10784. * Defines a predicate condition as an extension of Condition
  10785. */
  10786. export class PredicateCondition extends Condition {
  10787. /** defines the predicate function used to validate the condition */
  10788. predicate: () => boolean;
  10789. /**
  10790. * Internal only - manager for action
  10791. * @hidden
  10792. */
  10793. _actionManager: ActionManager;
  10794. /**
  10795. * Creates a new PredicateCondition
  10796. * @param actionManager manager for the action the condition applies to
  10797. * @param predicate defines the predicate function used to validate the condition
  10798. */
  10799. constructor(actionManager: ActionManager,
  10800. /** defines the predicate function used to validate the condition */
  10801. predicate: () => boolean);
  10802. /**
  10803. * @returns the validity of the predicate condition
  10804. */
  10805. isValid(): boolean;
  10806. }
  10807. /**
  10808. * Defines a state condition as an extension of Condition
  10809. */
  10810. export class StateCondition extends Condition {
  10811. /** Value to compare with target state */
  10812. value: string;
  10813. /**
  10814. * Internal only - manager for action
  10815. * @hidden
  10816. */
  10817. _actionManager: ActionManager;
  10818. /**
  10819. * Internal only
  10820. * @hidden
  10821. */
  10822. private _target;
  10823. /**
  10824. * Creates a new StateCondition
  10825. * @param actionManager manager for the action the condition applies to
  10826. * @param target of the condition
  10827. * @param value to compare with target state
  10828. */
  10829. constructor(actionManager: ActionManager, target: any,
  10830. /** Value to compare with target state */
  10831. value: string);
  10832. /**
  10833. * Gets a boolean indicating if the current condition is met
  10834. * @returns the validity of the state
  10835. */
  10836. isValid(): boolean;
  10837. /**
  10838. * Serialize the StateCondition into a JSON compatible object
  10839. * @returns serialization object
  10840. */
  10841. serialize(): any;
  10842. }
  10843. }
  10844. declare module "babylonjs/Actions/directActions" {
  10845. import { Action } from "babylonjs/Actions/action";
  10846. import { Condition } from "babylonjs/Actions/condition";
  10847. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10848. /**
  10849. * This defines an action responsible to toggle a boolean once triggered.
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10851. */
  10852. export class SwitchBooleanAction extends Action {
  10853. /**
  10854. * The path to the boolean property in the target object
  10855. */
  10856. propertyPath: string;
  10857. private _target;
  10858. private _effectiveTarget;
  10859. private _property;
  10860. /**
  10861. * Instantiate the action
  10862. * @param triggerOptions defines the trigger options
  10863. * @param target defines the object containing the boolean
  10864. * @param propertyPath defines the path to the boolean property in the target object
  10865. * @param condition defines the trigger related conditions
  10866. */
  10867. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10868. /** @hidden */
  10869. _prepare(): void;
  10870. /**
  10871. * Execute the action toggle the boolean value.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to set a the state field of the target
  10883. * to a desired value once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class SetStateAction extends Action {
  10887. /**
  10888. * The value to store in the state field.
  10889. */
  10890. value: string;
  10891. private _target;
  10892. /**
  10893. * Instantiate the action
  10894. * @param triggerOptions defines the trigger options
  10895. * @param target defines the object containing the state property
  10896. * @param value defines the value to store in the state field
  10897. * @param condition defines the trigger related conditions
  10898. */
  10899. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10900. /**
  10901. * Execute the action and store the value on the target state property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. /**
  10912. * This defines an action responsible to set a property of the target
  10913. * to a desired value once triggered.
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10915. */
  10916. export class SetValueAction extends Action {
  10917. /**
  10918. * The path of the property to set in the target.
  10919. */
  10920. propertyPath: string;
  10921. /**
  10922. * The value to set in the property
  10923. */
  10924. value: any;
  10925. private _target;
  10926. private _effectiveTarget;
  10927. private _property;
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param target defines the object containing the property
  10932. * @param propertyPath defines the path of the property to set in the target
  10933. * @param value defines the value to set in the property
  10934. * @param condition defines the trigger related conditions
  10935. */
  10936. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10937. /** @hidden */
  10938. _prepare(): void;
  10939. /**
  10940. * Execute the action and set the targetted property to the desired value.
  10941. */
  10942. execute(): void;
  10943. /**
  10944. * Serializes the actions and its related information.
  10945. * @param parent defines the object to serialize in
  10946. * @returns the serialized object
  10947. */
  10948. serialize(parent: any): any;
  10949. }
  10950. /**
  10951. * This defines an action responsible to increment the target value
  10952. * to a desired value once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class IncrementValueAction extends Action {
  10956. /**
  10957. * The path of the property to increment in the target.
  10958. */
  10959. propertyPath: string;
  10960. /**
  10961. * The value we should increment the property by.
  10962. */
  10963. value: any;
  10964. private _target;
  10965. private _effectiveTarget;
  10966. private _property;
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param target defines the object containing the property
  10971. * @param propertyPath defines the path of the property to increment in the target
  10972. * @param value defines the value value we should increment the property by
  10973. * @param condition defines the trigger related conditions
  10974. */
  10975. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10976. /** @hidden */
  10977. _prepare(): void;
  10978. /**
  10979. * Execute the action and increment the target of the value amount.
  10980. */
  10981. execute(): void;
  10982. /**
  10983. * Serializes the actions and its related information.
  10984. * @param parent defines the object to serialize in
  10985. * @returns the serialized object
  10986. */
  10987. serialize(parent: any): any;
  10988. }
  10989. /**
  10990. * This defines an action responsible to start an animation once triggered.
  10991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10992. */
  10993. export class PlayAnimationAction extends Action {
  10994. /**
  10995. * Where the animation should start (animation frame)
  10996. */
  10997. from: number;
  10998. /**
  10999. * Where the animation should stop (animation frame)
  11000. */
  11001. to: number;
  11002. /**
  11003. * Define if the animation should loop or stop after the first play.
  11004. */
  11005. loop?: boolean;
  11006. private _target;
  11007. /**
  11008. * Instantiate the action
  11009. * @param triggerOptions defines the trigger options
  11010. * @param target defines the target animation or animation name
  11011. * @param from defines from where the animation should start (animation frame)
  11012. * @param end defines where the animation should stop (animation frame)
  11013. * @param loop defines if the animation should loop or stop after the first play
  11014. * @param condition defines the trigger related conditions
  11015. */
  11016. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11017. /** @hidden */
  11018. _prepare(): void;
  11019. /**
  11020. * Execute the action and play the animation.
  11021. */
  11022. execute(): void;
  11023. /**
  11024. * Serializes the actions and its related information.
  11025. * @param parent defines the object to serialize in
  11026. * @returns the serialized object
  11027. */
  11028. serialize(parent: any): any;
  11029. }
  11030. /**
  11031. * This defines an action responsible to stop an animation once triggered.
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11033. */
  11034. export class StopAnimationAction extends Action {
  11035. private _target;
  11036. /**
  11037. * Instantiate the action
  11038. * @param triggerOptions defines the trigger options
  11039. * @param target defines the target animation or animation name
  11040. * @param condition defines the trigger related conditions
  11041. */
  11042. constructor(triggerOptions: any, target: any, condition?: Condition);
  11043. /** @hidden */
  11044. _prepare(): void;
  11045. /**
  11046. * Execute the action and stop the animation.
  11047. */
  11048. execute(): void;
  11049. /**
  11050. * Serializes the actions and its related information.
  11051. * @param parent defines the object to serialize in
  11052. * @returns the serialized object
  11053. */
  11054. serialize(parent: any): any;
  11055. }
  11056. /**
  11057. * This defines an action responsible that does nothing once triggered.
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11059. */
  11060. export class DoNothingAction extends Action {
  11061. /**
  11062. * Instantiate the action
  11063. * @param triggerOptions defines the trigger options
  11064. * @param condition defines the trigger related conditions
  11065. */
  11066. constructor(triggerOptions?: any, condition?: Condition);
  11067. /**
  11068. * Execute the action and do nothing.
  11069. */
  11070. execute(): void;
  11071. /**
  11072. * Serializes the actions and its related information.
  11073. * @param parent defines the object to serialize in
  11074. * @returns the serialized object
  11075. */
  11076. serialize(parent: any): any;
  11077. }
  11078. /**
  11079. * This defines an action responsible to trigger several actions once triggered.
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11081. */
  11082. export class CombineAction extends Action {
  11083. /**
  11084. * The list of aggregated animations to run.
  11085. */
  11086. children: Action[];
  11087. /**
  11088. * Instantiate the action
  11089. * @param triggerOptions defines the trigger options
  11090. * @param children defines the list of aggregated animations to run
  11091. * @param condition defines the trigger related conditions
  11092. */
  11093. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11094. /** @hidden */
  11095. _prepare(): void;
  11096. /**
  11097. * Execute the action and executes all the aggregated actions.
  11098. */
  11099. execute(evt: ActionEvent): void;
  11100. /**
  11101. * Serializes the actions and its related information.
  11102. * @param parent defines the object to serialize in
  11103. * @returns the serialized object
  11104. */
  11105. serialize(parent: any): any;
  11106. }
  11107. /**
  11108. * This defines an action responsible to run code (external event) once triggered.
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11110. */
  11111. export class ExecuteCodeAction extends Action {
  11112. /**
  11113. * The callback function to run.
  11114. */
  11115. func: (evt: ActionEvent) => void;
  11116. /**
  11117. * Instantiate the action
  11118. * @param triggerOptions defines the trigger options
  11119. * @param func defines the callback function to run
  11120. * @param condition defines the trigger related conditions
  11121. */
  11122. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11123. /**
  11124. * Execute the action and run the attached code.
  11125. */
  11126. execute(evt: ActionEvent): void;
  11127. }
  11128. /**
  11129. * This defines an action responsible to set the parent property of the target once triggered.
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11131. */
  11132. export class SetParentAction extends Action {
  11133. private _parent;
  11134. private _target;
  11135. /**
  11136. * Instantiate the action
  11137. * @param triggerOptions defines the trigger options
  11138. * @param target defines the target containing the parent property
  11139. * @param parent defines from where the animation should start (animation frame)
  11140. * @param condition defines the trigger related conditions
  11141. */
  11142. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11143. /** @hidden */
  11144. _prepare(): void;
  11145. /**
  11146. * Execute the action and set the parent property.
  11147. */
  11148. execute(): void;
  11149. /**
  11150. * Serializes the actions and its related information.
  11151. * @param parent defines the object to serialize in
  11152. * @returns the serialized object
  11153. */
  11154. serialize(parent: any): any;
  11155. }
  11156. }
  11157. declare module "babylonjs/Actions/actionManager" {
  11158. import { Nullable } from "babylonjs/types";
  11159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11160. import { Scene } from "babylonjs/scene";
  11161. import { IAction } from "babylonjs/Actions/action";
  11162. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11163. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11164. /**
  11165. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11166. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11168. */
  11169. export class ActionManager extends AbstractActionManager {
  11170. /**
  11171. * Nothing
  11172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11173. */
  11174. static readonly NothingTrigger: number;
  11175. /**
  11176. * On pick
  11177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11178. */
  11179. static readonly OnPickTrigger: number;
  11180. /**
  11181. * On left pick
  11182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11183. */
  11184. static readonly OnLeftPickTrigger: number;
  11185. /**
  11186. * On right pick
  11187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11188. */
  11189. static readonly OnRightPickTrigger: number;
  11190. /**
  11191. * On center pick
  11192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11193. */
  11194. static readonly OnCenterPickTrigger: number;
  11195. /**
  11196. * On pick down
  11197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11198. */
  11199. static readonly OnPickDownTrigger: number;
  11200. /**
  11201. * On double pick
  11202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11203. */
  11204. static readonly OnDoublePickTrigger: number;
  11205. /**
  11206. * On pick up
  11207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11208. */
  11209. static readonly OnPickUpTrigger: number;
  11210. /**
  11211. * On pick out.
  11212. * This trigger will only be raised if you also declared a OnPickDown
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly OnPickOutTrigger: number;
  11216. /**
  11217. * On long press
  11218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11219. */
  11220. static readonly OnLongPressTrigger: number;
  11221. /**
  11222. * On pointer over
  11223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11224. */
  11225. static readonly OnPointerOverTrigger: number;
  11226. /**
  11227. * On pointer out
  11228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11229. */
  11230. static readonly OnPointerOutTrigger: number;
  11231. /**
  11232. * On every frame
  11233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11234. */
  11235. static readonly OnEveryFrameTrigger: number;
  11236. /**
  11237. * On intersection enter
  11238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11239. */
  11240. static readonly OnIntersectionEnterTrigger: number;
  11241. /**
  11242. * On intersection exit
  11243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11244. */
  11245. static readonly OnIntersectionExitTrigger: number;
  11246. /**
  11247. * On key down
  11248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11249. */
  11250. static readonly OnKeyDownTrigger: number;
  11251. /**
  11252. * On key up
  11253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11254. */
  11255. static readonly OnKeyUpTrigger: number;
  11256. private _scene;
  11257. /**
  11258. * Creates a new action manager
  11259. * @param scene defines the hosting scene
  11260. */
  11261. constructor(scene: Scene);
  11262. /**
  11263. * Releases all associated resources
  11264. */
  11265. dispose(): void;
  11266. /**
  11267. * Gets hosting scene
  11268. * @returns the hosting scene
  11269. */
  11270. getScene(): Scene;
  11271. /**
  11272. * Does this action manager handles actions of any of the given triggers
  11273. * @param triggers defines the triggers to be tested
  11274. * @return a boolean indicating whether one (or more) of the triggers is handled
  11275. */
  11276. hasSpecificTriggers(triggers: number[]): boolean;
  11277. /**
  11278. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11279. * speed.
  11280. * @param triggerA defines the trigger to be tested
  11281. * @param triggerB defines the trigger to be tested
  11282. * @return a boolean indicating whether one (or more) of the triggers is handled
  11283. */
  11284. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11285. /**
  11286. * Does this action manager handles actions of a given trigger
  11287. * @param trigger defines the trigger to be tested
  11288. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11289. * @return whether the trigger is handled
  11290. */
  11291. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11292. /**
  11293. * Does this action manager has pointer triggers
  11294. */
  11295. readonly hasPointerTriggers: boolean;
  11296. /**
  11297. * Does this action manager has pick triggers
  11298. */
  11299. readonly hasPickTriggers: boolean;
  11300. /**
  11301. * Registers an action to this action manager
  11302. * @param action defines the action to be registered
  11303. * @return the action amended (prepared) after registration
  11304. */
  11305. registerAction(action: IAction): Nullable<IAction>;
  11306. /**
  11307. * Unregisters an action to this action manager
  11308. * @param action defines the action to be unregistered
  11309. * @return a boolean indicating whether the action has been unregistered
  11310. */
  11311. unregisterAction(action: IAction): Boolean;
  11312. /**
  11313. * Process a specific trigger
  11314. * @param trigger defines the trigger to process
  11315. * @param evt defines the event details to be processed
  11316. */
  11317. processTrigger(trigger: number, evt?: IActionEvent): void;
  11318. /** @hidden */
  11319. _getEffectiveTarget(target: any, propertyPath: string): any;
  11320. /** @hidden */
  11321. _getProperty(propertyPath: string): string;
  11322. /**
  11323. * Serialize this manager to a JSON object
  11324. * @param name defines the property name to store this manager
  11325. * @returns a JSON representation of this manager
  11326. */
  11327. serialize(name: string): any;
  11328. /**
  11329. * Creates a new ActionManager from a JSON data
  11330. * @param parsedActions defines the JSON data to read from
  11331. * @param object defines the hosting mesh
  11332. * @param scene defines the hosting scene
  11333. */
  11334. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11335. /**
  11336. * Get a trigger name by index
  11337. * @param trigger defines the trigger index
  11338. * @returns a trigger name
  11339. */
  11340. static GetTriggerName(trigger: number): string;
  11341. }
  11342. }
  11343. declare module "babylonjs/Culling/ray" {
  11344. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11345. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11347. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11348. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11349. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11350. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11351. /**
  11352. * Class representing a ray with position and direction
  11353. */
  11354. export class Ray {
  11355. /** origin point */
  11356. origin: Vector3;
  11357. /** direction */
  11358. direction: Vector3;
  11359. /** length of the ray */
  11360. length: number;
  11361. private static readonly TmpVector3;
  11362. private _tmpRay;
  11363. /**
  11364. * Creates a new ray
  11365. * @param origin origin point
  11366. * @param direction direction
  11367. * @param length length of the ray
  11368. */
  11369. constructor(
  11370. /** origin point */
  11371. origin: Vector3,
  11372. /** direction */
  11373. direction: Vector3,
  11374. /** length of the ray */
  11375. length?: number);
  11376. /**
  11377. * Checks if the ray intersects a box
  11378. * @param minimum bound of the box
  11379. * @param maximum bound of the box
  11380. * @param intersectionTreshold extra extend to be added to the box in all direction
  11381. * @returns if the box was hit
  11382. */
  11383. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11384. /**
  11385. * Checks if the ray intersects a box
  11386. * @param box the bounding box to check
  11387. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11388. * @returns if the box was hit
  11389. */
  11390. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11391. /**
  11392. * If the ray hits a sphere
  11393. * @param sphere the bounding sphere to check
  11394. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11395. * @returns true if it hits the sphere
  11396. */
  11397. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11398. /**
  11399. * If the ray hits a triange
  11400. * @param vertex0 triangle vertex
  11401. * @param vertex1 triangle vertex
  11402. * @param vertex2 triangle vertex
  11403. * @returns intersection information if hit
  11404. */
  11405. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11406. /**
  11407. * Checks if ray intersects a plane
  11408. * @param plane the plane to check
  11409. * @returns the distance away it was hit
  11410. */
  11411. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11412. /**
  11413. * Checks if ray intersects a mesh
  11414. * @param mesh the mesh to check
  11415. * @param fastCheck if only the bounding box should checked
  11416. * @returns picking info of the intersecton
  11417. */
  11418. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11419. /**
  11420. * Checks if ray intersects a mesh
  11421. * @param meshes the meshes to check
  11422. * @param fastCheck if only the bounding box should checked
  11423. * @param results array to store result in
  11424. * @returns Array of picking infos
  11425. */
  11426. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11427. private _comparePickingInfo;
  11428. private static smallnum;
  11429. private static rayl;
  11430. /**
  11431. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11432. * @param sega the first point of the segment to test the intersection against
  11433. * @param segb the second point of the segment to test the intersection against
  11434. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11435. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11436. */
  11437. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11438. /**
  11439. * Update the ray from viewport position
  11440. * @param x position
  11441. * @param y y position
  11442. * @param viewportWidth viewport width
  11443. * @param viewportHeight viewport height
  11444. * @param world world matrix
  11445. * @param view view matrix
  11446. * @param projection projection matrix
  11447. * @returns this ray updated
  11448. */
  11449. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11450. /**
  11451. * Creates a ray with origin and direction of 0,0,0
  11452. * @returns the new ray
  11453. */
  11454. static Zero(): Ray;
  11455. /**
  11456. * Creates a new ray from screen space and viewport
  11457. * @param x position
  11458. * @param y y position
  11459. * @param viewportWidth viewport width
  11460. * @param viewportHeight viewport height
  11461. * @param world world matrix
  11462. * @param view view matrix
  11463. * @param projection projection matrix
  11464. * @returns new ray
  11465. */
  11466. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11467. /**
  11468. * 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
  11469. * transformed to the given world matrix.
  11470. * @param origin The origin point
  11471. * @param end The end point
  11472. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11473. * @returns the new ray
  11474. */
  11475. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11476. /**
  11477. * Transforms a ray by a matrix
  11478. * @param ray ray to transform
  11479. * @param matrix matrix to apply
  11480. * @returns the resulting new ray
  11481. */
  11482. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11483. /**
  11484. * Transforms a ray by a matrix
  11485. * @param ray ray to transform
  11486. * @param matrix matrix to apply
  11487. * @param result ray to store result in
  11488. */
  11489. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11490. /**
  11491. * Unproject a ray from screen space to object space
  11492. * @param sourceX defines the screen space x coordinate to use
  11493. * @param sourceY defines the screen space y coordinate to use
  11494. * @param viewportWidth defines the current width of the viewport
  11495. * @param viewportHeight defines the current height of the viewport
  11496. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11497. * @param view defines the view matrix to use
  11498. * @param projection defines the projection matrix to use
  11499. */
  11500. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11501. }
  11502. /**
  11503. * Type used to define predicate used to select faces when a mesh intersection is detected
  11504. */
  11505. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11506. module "babylonjs/scene" {
  11507. interface Scene {
  11508. /** @hidden */
  11509. _tempPickingRay: Nullable<Ray>;
  11510. /** @hidden */
  11511. _cachedRayForTransform: Ray;
  11512. /** @hidden */
  11513. _pickWithRayInverseMatrix: Matrix;
  11514. /** @hidden */
  11515. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11516. /** @hidden */
  11517. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11518. }
  11519. }
  11520. }
  11521. declare module "babylonjs/sceneComponent" {
  11522. import { Scene } from "babylonjs/scene";
  11523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11525. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11526. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11527. import { Nullable } from "babylonjs/types";
  11528. import { Camera } from "babylonjs/Cameras/camera";
  11529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11530. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11531. import { AbstractScene } from "babylonjs/abstractScene";
  11532. /**
  11533. * Groups all the scene component constants in one place to ease maintenance.
  11534. * @hidden
  11535. */
  11536. export class SceneComponentConstants {
  11537. static readonly NAME_EFFECTLAYER: string;
  11538. static readonly NAME_LAYER: string;
  11539. static readonly NAME_LENSFLARESYSTEM: string;
  11540. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11541. static readonly NAME_PARTICLESYSTEM: string;
  11542. static readonly NAME_GAMEPAD: string;
  11543. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11544. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11545. static readonly NAME_DEPTHRENDERER: string;
  11546. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11547. static readonly NAME_SPRITE: string;
  11548. static readonly NAME_OUTLINERENDERER: string;
  11549. static readonly NAME_PROCEDURALTEXTURE: string;
  11550. static readonly NAME_SHADOWGENERATOR: string;
  11551. static readonly NAME_OCTREE: string;
  11552. static readonly NAME_PHYSICSENGINE: string;
  11553. static readonly NAME_AUDIO: string;
  11554. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11555. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11556. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11558. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11559. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11560. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11561. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11562. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11563. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11564. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11565. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11566. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11567. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11568. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11569. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11570. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11571. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11572. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11573. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11574. static readonly STEP_AFTERRENDER_AUDIO: number;
  11575. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11576. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11577. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11578. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11579. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11580. static readonly STEP_POINTERMOVE_SPRITE: number;
  11581. static readonly STEP_POINTERDOWN_SPRITE: number;
  11582. static readonly STEP_POINTERUP_SPRITE: number;
  11583. }
  11584. /**
  11585. * This represents a scene component.
  11586. *
  11587. * This is used to decouple the dependency the scene is having on the different workloads like
  11588. * layers, post processes...
  11589. */
  11590. export interface ISceneComponent {
  11591. /**
  11592. * The name of the component. Each component must have a unique name.
  11593. */
  11594. name: string;
  11595. /**
  11596. * The scene the component belongs to.
  11597. */
  11598. scene: Scene;
  11599. /**
  11600. * Register the component to one instance of a scene.
  11601. */
  11602. register(): void;
  11603. /**
  11604. * Rebuilds the elements related to this component in case of
  11605. * context lost for instance.
  11606. */
  11607. rebuild(): void;
  11608. /**
  11609. * Disposes the component and the associated ressources.
  11610. */
  11611. dispose(): void;
  11612. }
  11613. /**
  11614. * This represents a SERIALIZABLE scene component.
  11615. *
  11616. * This extends Scene Component to add Serialization methods on top.
  11617. */
  11618. export interface ISceneSerializableComponent extends ISceneComponent {
  11619. /**
  11620. * Adds all the element from the container to the scene
  11621. * @param container the container holding the elements
  11622. */
  11623. addFromContainer(container: AbstractScene): void;
  11624. /**
  11625. * Removes all the elements in the container from the scene
  11626. * @param container contains the elements to remove
  11627. */
  11628. removeFromContainer(container: AbstractScene): void;
  11629. /**
  11630. * Serializes the component data to the specified json object
  11631. * @param serializationObject The object to serialize to
  11632. */
  11633. serialize(serializationObject: any): void;
  11634. }
  11635. /**
  11636. * Strong typing of a Mesh related stage step action
  11637. */
  11638. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11639. /**
  11640. * Strong typing of a Evaluate Sub Mesh related stage step action
  11641. */
  11642. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11643. /**
  11644. * Strong typing of a Active Mesh related stage step action
  11645. */
  11646. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11647. /**
  11648. * Strong typing of a Camera related stage step action
  11649. */
  11650. export type CameraStageAction = (camera: Camera) => void;
  11651. /**
  11652. * Strong typing of a Render Target related stage step action
  11653. */
  11654. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11655. /**
  11656. * Strong typing of a RenderingGroup related stage step action
  11657. */
  11658. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11659. /**
  11660. * Strong typing of a Mesh Render related stage step action
  11661. */
  11662. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11663. /**
  11664. * Strong typing of a simple stage step action
  11665. */
  11666. export type SimpleStageAction = () => void;
  11667. /**
  11668. * Strong typing of a render target action.
  11669. */
  11670. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11671. /**
  11672. * Strong typing of a pointer move action.
  11673. */
  11674. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11675. /**
  11676. * Strong typing of a pointer up/down action.
  11677. */
  11678. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11679. /**
  11680. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11681. * @hidden
  11682. */
  11683. export class Stage<T extends Function> extends Array<{
  11684. index: number;
  11685. component: ISceneComponent;
  11686. action: T;
  11687. }> {
  11688. /**
  11689. * Hide ctor from the rest of the world.
  11690. * @param items The items to add.
  11691. */
  11692. private constructor();
  11693. /**
  11694. * Creates a new Stage.
  11695. * @returns A new instance of a Stage
  11696. */
  11697. static Create<T extends Function>(): Stage<T>;
  11698. /**
  11699. * Registers a step in an ordered way in the targeted stage.
  11700. * @param index Defines the position to register the step in
  11701. * @param component Defines the component attached to the step
  11702. * @param action Defines the action to launch during the step
  11703. */
  11704. registerStep(index: number, component: ISceneComponent, action: T): void;
  11705. /**
  11706. * Clears all the steps from the stage.
  11707. */
  11708. clear(): void;
  11709. }
  11710. }
  11711. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11712. import { Nullable } from "babylonjs/types";
  11713. import { Observable } from "babylonjs/Misc/observable";
  11714. import { Scene } from "babylonjs/scene";
  11715. import { Sprite } from "babylonjs/Sprites/sprite";
  11716. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11717. import { Ray } from "babylonjs/Culling/ray";
  11718. import { Camera } from "babylonjs/Cameras/camera";
  11719. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11720. import { ISceneComponent } from "babylonjs/sceneComponent";
  11721. module "babylonjs/scene" {
  11722. interface Scene {
  11723. /** @hidden */
  11724. _pointerOverSprite: Nullable<Sprite>;
  11725. /** @hidden */
  11726. _pickedDownSprite: Nullable<Sprite>;
  11727. /** @hidden */
  11728. _tempSpritePickingRay: Nullable<Ray>;
  11729. /**
  11730. * All of the sprite managers added to this scene
  11731. * @see http://doc.babylonjs.com/babylon101/sprites
  11732. */
  11733. spriteManagers: Array<ISpriteManager>;
  11734. /**
  11735. * An event triggered when sprites rendering is about to start
  11736. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11737. */
  11738. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11739. /**
  11740. * An event triggered when sprites rendering is done
  11741. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11742. */
  11743. onAfterSpritesRenderingObservable: Observable<Scene>;
  11744. /** @hidden */
  11745. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11746. /** Launch a ray to try to pick a sprite in the scene
  11747. * @param x position on screen
  11748. * @param y position on screen
  11749. * @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
  11750. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11751. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11752. * @returns a PickingInfo
  11753. */
  11754. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11755. /** Use the given ray to pick a sprite in the scene
  11756. * @param ray The ray (in world space) to use to pick meshes
  11757. * @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
  11758. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11759. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11760. * @returns a PickingInfo
  11761. */
  11762. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11763. /**
  11764. * Force the sprite under the pointer
  11765. * @param sprite defines the sprite to use
  11766. */
  11767. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11768. /**
  11769. * Gets the sprite under the pointer
  11770. * @returns a Sprite or null if no sprite is under the pointer
  11771. */
  11772. getPointerOverSprite(): Nullable<Sprite>;
  11773. }
  11774. }
  11775. /**
  11776. * Defines the sprite scene component responsible to manage sprites
  11777. * in a given scene.
  11778. */
  11779. export class SpriteSceneComponent implements ISceneComponent {
  11780. /**
  11781. * The component name helpfull to identify the component in the list of scene components.
  11782. */
  11783. readonly name: string;
  11784. /**
  11785. * The scene the component belongs to.
  11786. */
  11787. scene: Scene;
  11788. /** @hidden */
  11789. private _spritePredicate;
  11790. /**
  11791. * Creates a new instance of the component for the given scene
  11792. * @param scene Defines the scene to register the component in
  11793. */
  11794. constructor(scene: Scene);
  11795. /**
  11796. * Registers the component in a given scene
  11797. */
  11798. register(): void;
  11799. /**
  11800. * Rebuilds the elements related to this component in case of
  11801. * context lost for instance.
  11802. */
  11803. rebuild(): void;
  11804. /**
  11805. * Disposes the component and the associated ressources.
  11806. */
  11807. dispose(): void;
  11808. private _pickSpriteButKeepRay;
  11809. private _pointerMove;
  11810. private _pointerDown;
  11811. private _pointerUp;
  11812. }
  11813. }
  11814. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11815. /** @hidden */
  11816. export var fogFragmentDeclaration: {
  11817. name: string;
  11818. shader: string;
  11819. };
  11820. }
  11821. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11822. /** @hidden */
  11823. export var fogFragment: {
  11824. name: string;
  11825. shader: string;
  11826. };
  11827. }
  11828. declare module "babylonjs/Shaders/sprites.fragment" {
  11829. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11830. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11831. /** @hidden */
  11832. export var spritesPixelShader: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11838. /** @hidden */
  11839. export var fogVertexDeclaration: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module "babylonjs/Shaders/sprites.vertex" {
  11845. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11846. /** @hidden */
  11847. export var spritesVertexShader: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Sprites/spriteManager" {
  11853. import { IDisposable, Scene } from "babylonjs/scene";
  11854. import { Nullable } from "babylonjs/types";
  11855. import { Observable } from "babylonjs/Misc/observable";
  11856. import { Sprite } from "babylonjs/Sprites/sprite";
  11857. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11858. import { Camera } from "babylonjs/Cameras/camera";
  11859. import { Texture } from "babylonjs/Materials/Textures/texture";
  11860. import "babylonjs/Shaders/sprites.fragment";
  11861. import "babylonjs/Shaders/sprites.vertex";
  11862. import { Ray } from "babylonjs/Culling/ray";
  11863. /**
  11864. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11865. */
  11866. export interface ISpriteManager extends IDisposable {
  11867. /**
  11868. * Restricts the camera to viewing objects with the same layerMask.
  11869. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11870. */
  11871. layerMask: number;
  11872. /**
  11873. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11874. */
  11875. isPickable: boolean;
  11876. /**
  11877. * Specifies the rendering group id for this mesh (0 by default)
  11878. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11879. */
  11880. renderingGroupId: number;
  11881. /**
  11882. * Defines the list of sprites managed by the manager.
  11883. */
  11884. sprites: Array<Sprite>;
  11885. /**
  11886. * Tests the intersection of a sprite with a specific ray.
  11887. * @param ray The ray we are sending to test the collision
  11888. * @param camera The camera space we are sending rays in
  11889. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11890. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11891. * @returns picking info or null.
  11892. */
  11893. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11894. /**
  11895. * Renders the list of sprites on screen.
  11896. */
  11897. render(): void;
  11898. }
  11899. /**
  11900. * Class used to manage multiple sprites on the same spritesheet
  11901. * @see http://doc.babylonjs.com/babylon101/sprites
  11902. */
  11903. export class SpriteManager implements ISpriteManager {
  11904. /** defines the manager's name */
  11905. name: string;
  11906. /** Gets the list of sprites */
  11907. sprites: Sprite[];
  11908. /** Gets or sets the rendering group id (0 by default) */
  11909. renderingGroupId: number;
  11910. /** Gets or sets camera layer mask */
  11911. layerMask: number;
  11912. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11913. fogEnabled: boolean;
  11914. /** Gets or sets a boolean indicating if the sprites are pickable */
  11915. isPickable: boolean;
  11916. /** Defines the default width of a cell in the spritesheet */
  11917. cellWidth: number;
  11918. /** Defines the default height of a cell in the spritesheet */
  11919. cellHeight: number;
  11920. /**
  11921. * An event triggered when the manager is disposed.
  11922. */
  11923. onDisposeObservable: Observable<SpriteManager>;
  11924. private _onDisposeObserver;
  11925. /**
  11926. * Callback called when the manager is disposed
  11927. */
  11928. onDispose: () => void;
  11929. private _capacity;
  11930. private _spriteTexture;
  11931. private _epsilon;
  11932. private _scene;
  11933. private _vertexData;
  11934. private _buffer;
  11935. private _vertexBuffers;
  11936. private _indexBuffer;
  11937. private _effectBase;
  11938. private _effectFog;
  11939. /**
  11940. * Gets or sets the spritesheet texture
  11941. */
  11942. texture: Texture;
  11943. /**
  11944. * Creates a new sprite manager
  11945. * @param name defines the manager's name
  11946. * @param imgUrl defines the sprite sheet url
  11947. * @param capacity defines the maximum allowed number of sprites
  11948. * @param cellSize defines the size of a sprite cell
  11949. * @param scene defines the hosting scene
  11950. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11951. * @param samplingMode defines the smapling mode to use with spritesheet
  11952. */
  11953. constructor(
  11954. /** defines the manager's name */
  11955. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11956. private _appendSpriteVertex;
  11957. /**
  11958. * Intersects the sprites with a ray
  11959. * @param ray defines the ray to intersect with
  11960. * @param camera defines the current active camera
  11961. * @param predicate defines a predicate used to select candidate sprites
  11962. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11963. * @returns null if no hit or a PickingInfo
  11964. */
  11965. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11966. /**
  11967. * Render all child sprites
  11968. */
  11969. render(): void;
  11970. /**
  11971. * Release associated resources
  11972. */
  11973. dispose(): void;
  11974. }
  11975. }
  11976. declare module "babylonjs/Sprites/sprite" {
  11977. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11978. import { Nullable } from "babylonjs/types";
  11979. import { ActionManager } from "babylonjs/Actions/actionManager";
  11980. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11981. /**
  11982. * Class used to represent a sprite
  11983. * @see http://doc.babylonjs.com/babylon101/sprites
  11984. */
  11985. export class Sprite {
  11986. /** defines the name */
  11987. name: string;
  11988. /** Gets or sets the current world position */
  11989. position: Vector3;
  11990. /** Gets or sets the main color */
  11991. color: Color4;
  11992. /** Gets or sets the width */
  11993. width: number;
  11994. /** Gets or sets the height */
  11995. height: number;
  11996. /** Gets or sets rotation angle */
  11997. angle: number;
  11998. /** Gets or sets the cell index in the sprite sheet */
  11999. cellIndex: number;
  12000. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12001. invertU: number;
  12002. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12003. invertV: number;
  12004. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12005. disposeWhenFinishedAnimating: boolean;
  12006. /** Gets the list of attached animations */
  12007. animations: Animation[];
  12008. /** Gets or sets a boolean indicating if the sprite can be picked */
  12009. isPickable: boolean;
  12010. /**
  12011. * Gets or sets the associated action manager
  12012. */
  12013. actionManager: Nullable<ActionManager>;
  12014. private _animationStarted;
  12015. private _loopAnimation;
  12016. private _fromIndex;
  12017. private _toIndex;
  12018. private _delay;
  12019. private _direction;
  12020. private _manager;
  12021. private _time;
  12022. private _onAnimationEnd;
  12023. /**
  12024. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12025. */
  12026. isVisible: boolean;
  12027. /**
  12028. * Gets or sets the sprite size
  12029. */
  12030. size: number;
  12031. /**
  12032. * Creates a new Sprite
  12033. * @param name defines the name
  12034. * @param manager defines the manager
  12035. */
  12036. constructor(
  12037. /** defines the name */
  12038. name: string, manager: ISpriteManager);
  12039. /**
  12040. * Starts an animation
  12041. * @param from defines the initial key
  12042. * @param to defines the end key
  12043. * @param loop defines if the animation must loop
  12044. * @param delay defines the start delay (in ms)
  12045. * @param onAnimationEnd defines a callback to call when animation ends
  12046. */
  12047. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12048. /** Stops current animation (if any) */
  12049. stopAnimation(): void;
  12050. /** @hidden */
  12051. _animate(deltaTime: number): void;
  12052. /** Release associated resources */
  12053. dispose(): void;
  12054. }
  12055. }
  12056. declare module "babylonjs/Collisions/pickingInfo" {
  12057. import { Nullable } from "babylonjs/types";
  12058. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12060. import { Sprite } from "babylonjs/Sprites/sprite";
  12061. import { Ray } from "babylonjs/Culling/ray";
  12062. /**
  12063. * Information about the result of picking within a scene
  12064. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12065. */
  12066. export class PickingInfo {
  12067. /** @hidden */
  12068. _pickingUnavailable: boolean;
  12069. /**
  12070. * If the pick collided with an object
  12071. */
  12072. hit: boolean;
  12073. /**
  12074. * Distance away where the pick collided
  12075. */
  12076. distance: number;
  12077. /**
  12078. * The location of pick collision
  12079. */
  12080. pickedPoint: Nullable<Vector3>;
  12081. /**
  12082. * The mesh corresponding the the pick collision
  12083. */
  12084. pickedMesh: Nullable<AbstractMesh>;
  12085. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12086. bu: number;
  12087. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12088. bv: number;
  12089. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12090. faceId: number;
  12091. /** Id of the the submesh that was picked */
  12092. subMeshId: number;
  12093. /** If a sprite was picked, this will be the sprite the pick collided with */
  12094. pickedSprite: Nullable<Sprite>;
  12095. /**
  12096. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12097. */
  12098. originMesh: Nullable<AbstractMesh>;
  12099. /**
  12100. * The ray that was used to perform the picking.
  12101. */
  12102. ray: Nullable<Ray>;
  12103. /**
  12104. * Gets the normal correspodning to the face the pick collided with
  12105. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12106. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12107. * @returns The normal correspodning to the face the pick collided with
  12108. */
  12109. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12110. /**
  12111. * Gets the texture coordinates of where the pick occured
  12112. * @returns the vector containing the coordnates of the texture
  12113. */
  12114. getTextureCoordinates(): Nullable<Vector2>;
  12115. }
  12116. }
  12117. declare module "babylonjs/Events/pointerEvents" {
  12118. import { Nullable } from "babylonjs/types";
  12119. import { Vector2 } from "babylonjs/Maths/math";
  12120. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12121. import { Ray } from "babylonjs/Culling/ray";
  12122. /**
  12123. * Gather the list of pointer event types as constants.
  12124. */
  12125. export class PointerEventTypes {
  12126. /**
  12127. * 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.
  12128. */
  12129. static readonly POINTERDOWN: number;
  12130. /**
  12131. * The pointerup event is fired when a pointer is no longer active.
  12132. */
  12133. static readonly POINTERUP: number;
  12134. /**
  12135. * The pointermove event is fired when a pointer changes coordinates.
  12136. */
  12137. static readonly POINTERMOVE: number;
  12138. /**
  12139. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12140. */
  12141. static readonly POINTERWHEEL: number;
  12142. /**
  12143. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12144. */
  12145. static readonly POINTERPICK: number;
  12146. /**
  12147. * The pointertap event is fired when a the object has been touched and released without drag.
  12148. */
  12149. static readonly POINTERTAP: number;
  12150. /**
  12151. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12152. */
  12153. static readonly POINTERDOUBLETAP: number;
  12154. }
  12155. /**
  12156. * Base class of pointer info types.
  12157. */
  12158. export class PointerInfoBase {
  12159. /**
  12160. * Defines the type of event (PointerEventTypes)
  12161. */
  12162. type: number;
  12163. /**
  12164. * Defines the related dom event
  12165. */
  12166. event: PointerEvent | MouseWheelEvent;
  12167. /**
  12168. * Instantiates the base class of pointers info.
  12169. * @param type Defines the type of event (PointerEventTypes)
  12170. * @param event Defines the related dom event
  12171. */
  12172. constructor(
  12173. /**
  12174. * Defines the type of event (PointerEventTypes)
  12175. */
  12176. type: number,
  12177. /**
  12178. * Defines the related dom event
  12179. */
  12180. event: PointerEvent | MouseWheelEvent);
  12181. }
  12182. /**
  12183. * This class is used to store pointer related info for the onPrePointerObservable event.
  12184. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12185. */
  12186. export class PointerInfoPre extends PointerInfoBase {
  12187. /**
  12188. * Ray from a pointer if availible (eg. 6dof controller)
  12189. */
  12190. ray: Nullable<Ray>;
  12191. /**
  12192. * Defines the local position of the pointer on the canvas.
  12193. */
  12194. localPosition: Vector2;
  12195. /**
  12196. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12197. */
  12198. skipOnPointerObservable: boolean;
  12199. /**
  12200. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12201. * @param type Defines the type of event (PointerEventTypes)
  12202. * @param event Defines the related dom event
  12203. * @param localX Defines the local x coordinates of the pointer when the event occured
  12204. * @param localY Defines the local y coordinates of the pointer when the event occured
  12205. */
  12206. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12207. }
  12208. /**
  12209. * This type contains all the data related to a pointer event in Babylon.js.
  12210. * 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.
  12211. */
  12212. export class PointerInfo extends PointerInfoBase {
  12213. /**
  12214. * Defines the picking info associated to the info (if any)\
  12215. */
  12216. pickInfo: Nullable<PickingInfo>;
  12217. /**
  12218. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12219. * @param type Defines the type of event (PointerEventTypes)
  12220. * @param event Defines the related dom event
  12221. * @param pickInfo Defines the picking info associated to the info (if any)\
  12222. */
  12223. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12224. /**
  12225. * Defines the picking info associated to the info (if any)\
  12226. */
  12227. pickInfo: Nullable<PickingInfo>);
  12228. }
  12229. /**
  12230. * Data relating to a touch event on the screen.
  12231. */
  12232. export interface PointerTouch {
  12233. /**
  12234. * X coordinate of touch.
  12235. */
  12236. x: number;
  12237. /**
  12238. * Y coordinate of touch.
  12239. */
  12240. y: number;
  12241. /**
  12242. * Id of touch. Unique for each finger.
  12243. */
  12244. pointerId: number;
  12245. /**
  12246. * Event type passed from DOM.
  12247. */
  12248. type: any;
  12249. }
  12250. }
  12251. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12252. import { Nullable } from "babylonjs/types";
  12253. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12254. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12255. /**
  12256. * Manage the mouse inputs to control the movement of a free camera.
  12257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12258. */
  12259. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12260. /**
  12261. * Define if touch is enabled in the mouse input
  12262. */
  12263. touchEnabled: boolean;
  12264. /**
  12265. * Defines the camera the input is attached to.
  12266. */
  12267. camera: FreeCamera;
  12268. /**
  12269. * Defines the buttons associated with the input to handle camera move.
  12270. */
  12271. buttons: number[];
  12272. /**
  12273. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12274. */
  12275. angularSensibility: number;
  12276. private _pointerInput;
  12277. private _onMouseMove;
  12278. private _observer;
  12279. private previousPosition;
  12280. /**
  12281. * Manage the mouse inputs to control the movement of a free camera.
  12282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12283. * @param touchEnabled Defines if touch is enabled or not
  12284. */
  12285. constructor(
  12286. /**
  12287. * Define if touch is enabled in the mouse input
  12288. */
  12289. touchEnabled?: boolean);
  12290. /**
  12291. * Attach the input controls to a specific dom element to get the input from.
  12292. * @param element Defines the element the controls should be listened from
  12293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12294. */
  12295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12296. /**
  12297. * Called on JS contextmenu event.
  12298. * Override this method to provide functionality.
  12299. */
  12300. protected onContextMenu(evt: PointerEvent): void;
  12301. /**
  12302. * Detach the current controls from the specified dom element.
  12303. * @param element Defines the element to stop listening the inputs from
  12304. */
  12305. detachControl(element: Nullable<HTMLElement>): void;
  12306. /**
  12307. * Gets the class name of the current intput.
  12308. * @returns the class name
  12309. */
  12310. getClassName(): string;
  12311. /**
  12312. * Get the friendly name associated with the input class.
  12313. * @returns the input friendly name
  12314. */
  12315. getSimpleName(): string;
  12316. }
  12317. }
  12318. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12319. import { Nullable } from "babylonjs/types";
  12320. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12321. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12322. /**
  12323. * Manage the touch inputs to control the movement of a free camera.
  12324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12325. */
  12326. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12327. /**
  12328. * Defines the camera the input is attached to.
  12329. */
  12330. camera: FreeCamera;
  12331. /**
  12332. * Defines the touch sensibility for rotation.
  12333. * The higher the faster.
  12334. */
  12335. touchAngularSensibility: number;
  12336. /**
  12337. * Defines the touch sensibility for move.
  12338. * The higher the faster.
  12339. */
  12340. touchMoveSensibility: number;
  12341. private _offsetX;
  12342. private _offsetY;
  12343. private _pointerPressed;
  12344. private _pointerInput;
  12345. private _observer;
  12346. private _onLostFocus;
  12347. /**
  12348. * Attach the input controls to a specific dom element to get the input from.
  12349. * @param element Defines the element the controls should be listened from
  12350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12351. */
  12352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12353. /**
  12354. * Detach the current controls from the specified dom element.
  12355. * @param element Defines the element to stop listening the inputs from
  12356. */
  12357. detachControl(element: Nullable<HTMLElement>): void;
  12358. /**
  12359. * Update the current camera state depending on the inputs that have been used this frame.
  12360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12361. */
  12362. checkInputs(): void;
  12363. /**
  12364. * Gets the class name of the current intput.
  12365. * @returns the class name
  12366. */
  12367. getClassName(): string;
  12368. /**
  12369. * Get the friendly name associated with the input class.
  12370. * @returns the input friendly name
  12371. */
  12372. getSimpleName(): string;
  12373. }
  12374. }
  12375. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12376. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12377. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12378. /**
  12379. * Default Inputs manager for the FreeCamera.
  12380. * It groups all the default supported inputs for ease of use.
  12381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12382. */
  12383. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12384. /**
  12385. * Instantiates a new FreeCameraInputsManager.
  12386. * @param camera Defines the camera the inputs belong to
  12387. */
  12388. constructor(camera: FreeCamera);
  12389. /**
  12390. * Add keyboard input support to the input manager.
  12391. * @returns the current input manager
  12392. */
  12393. addKeyboard(): FreeCameraInputsManager;
  12394. /**
  12395. * Add mouse input support to the input manager.
  12396. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12397. * @returns the current input manager
  12398. */
  12399. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12400. /**
  12401. * Add touch input support to the input manager.
  12402. * @returns the current input manager
  12403. */
  12404. addTouch(): FreeCameraInputsManager;
  12405. }
  12406. }
  12407. declare module "babylonjs/Cameras/freeCamera" {
  12408. import { Vector3 } from "babylonjs/Maths/math";
  12409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12410. import { Scene } from "babylonjs/scene";
  12411. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12412. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12413. /**
  12414. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12415. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12417. */
  12418. export class FreeCamera extends TargetCamera {
  12419. /**
  12420. * Define the collision ellipsoid of the camera.
  12421. * This is helpful to simulate a camera body like the player body around the camera
  12422. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12423. */
  12424. ellipsoid: Vector3;
  12425. /**
  12426. * Define an offset for the position of the ellipsoid around the camera.
  12427. * This can be helpful to determine the center of the body near the gravity center of the body
  12428. * instead of its head.
  12429. */
  12430. ellipsoidOffset: Vector3;
  12431. /**
  12432. * Enable or disable collisions of the camera with the rest of the scene objects.
  12433. */
  12434. checkCollisions: boolean;
  12435. /**
  12436. * Enable or disable gravity on the camera.
  12437. */
  12438. applyGravity: boolean;
  12439. /**
  12440. * Define the input manager associated to the camera.
  12441. */
  12442. inputs: FreeCameraInputsManager;
  12443. /**
  12444. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12445. * Higher values reduce sensitivity.
  12446. */
  12447. /**
  12448. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12449. * Higher values reduce sensitivity.
  12450. */
  12451. angularSensibility: number;
  12452. /**
  12453. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12454. */
  12455. keysUp: number[];
  12456. /**
  12457. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12458. */
  12459. keysDown: number[];
  12460. /**
  12461. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12462. */
  12463. keysLeft: number[];
  12464. /**
  12465. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12466. */
  12467. keysRight: number[];
  12468. /**
  12469. * Event raised when the camera collide with a mesh in the scene.
  12470. */
  12471. onCollide: (collidedMesh: AbstractMesh) => void;
  12472. private _collider;
  12473. private _needMoveForGravity;
  12474. private _oldPosition;
  12475. private _diffPosition;
  12476. private _newPosition;
  12477. /** @hidden */
  12478. _localDirection: Vector3;
  12479. /** @hidden */
  12480. _transformedDirection: Vector3;
  12481. /**
  12482. * Instantiates a Free Camera.
  12483. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12484. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12486. * @param name Define the name of the camera in the scene
  12487. * @param position Define the start position of the camera in the scene
  12488. * @param scene Define the scene the camera belongs to
  12489. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12490. */
  12491. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12492. /**
  12493. * Attached controls to the current camera.
  12494. * @param element Defines the element the controls should be listened from
  12495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12496. */
  12497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12498. /**
  12499. * Detach the current controls from the camera.
  12500. * The camera will stop reacting to inputs.
  12501. * @param element Defines the element to stop listening the inputs from
  12502. */
  12503. detachControl(element: HTMLElement): void;
  12504. private _collisionMask;
  12505. /**
  12506. * Define a collision mask to limit the list of object the camera can collide with
  12507. */
  12508. collisionMask: number;
  12509. /** @hidden */
  12510. _collideWithWorld(displacement: Vector3): void;
  12511. private _onCollisionPositionChange;
  12512. /** @hidden */
  12513. _checkInputs(): void;
  12514. /** @hidden */
  12515. _decideIfNeedsToMove(): boolean;
  12516. /** @hidden */
  12517. _updatePosition(): void;
  12518. /**
  12519. * Destroy the camera and release the current resources hold by it.
  12520. */
  12521. dispose(): void;
  12522. /**
  12523. * Gets the current object class name.
  12524. * @return the class name
  12525. */
  12526. getClassName(): string;
  12527. }
  12528. }
  12529. declare module "babylonjs/Gamepads/gamepad" {
  12530. import { Observable } from "babylonjs/Misc/observable";
  12531. /**
  12532. * Represents a gamepad control stick position
  12533. */
  12534. export class StickValues {
  12535. /**
  12536. * The x component of the control stick
  12537. */
  12538. x: number;
  12539. /**
  12540. * The y component of the control stick
  12541. */
  12542. y: number;
  12543. /**
  12544. * Initializes the gamepad x and y control stick values
  12545. * @param x The x component of the gamepad control stick value
  12546. * @param y The y component of the gamepad control stick value
  12547. */
  12548. constructor(
  12549. /**
  12550. * The x component of the control stick
  12551. */
  12552. x: number,
  12553. /**
  12554. * The y component of the control stick
  12555. */
  12556. y: number);
  12557. }
  12558. /**
  12559. * An interface which manages callbacks for gamepad button changes
  12560. */
  12561. export interface GamepadButtonChanges {
  12562. /**
  12563. * Called when a gamepad has been changed
  12564. */
  12565. changed: boolean;
  12566. /**
  12567. * Called when a gamepad press event has been triggered
  12568. */
  12569. pressChanged: boolean;
  12570. /**
  12571. * Called when a touch event has been triggered
  12572. */
  12573. touchChanged: boolean;
  12574. /**
  12575. * Called when a value has changed
  12576. */
  12577. valueChanged: boolean;
  12578. }
  12579. /**
  12580. * Represents a gamepad
  12581. */
  12582. export class Gamepad {
  12583. /**
  12584. * The id of the gamepad
  12585. */
  12586. id: string;
  12587. /**
  12588. * The index of the gamepad
  12589. */
  12590. index: number;
  12591. /**
  12592. * The browser gamepad
  12593. */
  12594. browserGamepad: any;
  12595. /**
  12596. * Specifies what type of gamepad this represents
  12597. */
  12598. type: number;
  12599. private _leftStick;
  12600. private _rightStick;
  12601. /** @hidden */
  12602. _isConnected: boolean;
  12603. private _leftStickAxisX;
  12604. private _leftStickAxisY;
  12605. private _rightStickAxisX;
  12606. private _rightStickAxisY;
  12607. /**
  12608. * Triggered when the left control stick has been changed
  12609. */
  12610. private _onleftstickchanged;
  12611. /**
  12612. * Triggered when the right control stick has been changed
  12613. */
  12614. private _onrightstickchanged;
  12615. /**
  12616. * Represents a gamepad controller
  12617. */
  12618. static GAMEPAD: number;
  12619. /**
  12620. * Represents a generic controller
  12621. */
  12622. static GENERIC: number;
  12623. /**
  12624. * Represents an XBox controller
  12625. */
  12626. static XBOX: number;
  12627. /**
  12628. * Represents a pose-enabled controller
  12629. */
  12630. static POSE_ENABLED: number;
  12631. /**
  12632. * Specifies whether the left control stick should be Y-inverted
  12633. */
  12634. protected _invertLeftStickY: boolean;
  12635. /**
  12636. * Specifies if the gamepad has been connected
  12637. */
  12638. readonly isConnected: boolean;
  12639. /**
  12640. * Initializes the gamepad
  12641. * @param id The id of the gamepad
  12642. * @param index The index of the gamepad
  12643. * @param browserGamepad The browser gamepad
  12644. * @param leftStickX The x component of the left joystick
  12645. * @param leftStickY The y component of the left joystick
  12646. * @param rightStickX The x component of the right joystick
  12647. * @param rightStickY The y component of the right joystick
  12648. */
  12649. constructor(
  12650. /**
  12651. * The id of the gamepad
  12652. */
  12653. id: string,
  12654. /**
  12655. * The index of the gamepad
  12656. */
  12657. index: number,
  12658. /**
  12659. * The browser gamepad
  12660. */
  12661. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12662. /**
  12663. * Callback triggered when the left joystick has changed
  12664. * @param callback
  12665. */
  12666. onleftstickchanged(callback: (values: StickValues) => void): void;
  12667. /**
  12668. * Callback triggered when the right joystick has changed
  12669. * @param callback
  12670. */
  12671. onrightstickchanged(callback: (values: StickValues) => void): void;
  12672. /**
  12673. * Gets the left joystick
  12674. */
  12675. /**
  12676. * Sets the left joystick values
  12677. */
  12678. leftStick: StickValues;
  12679. /**
  12680. * Gets the right joystick
  12681. */
  12682. /**
  12683. * Sets the right joystick value
  12684. */
  12685. rightStick: StickValues;
  12686. /**
  12687. * Updates the gamepad joystick positions
  12688. */
  12689. update(): void;
  12690. /**
  12691. * Disposes the gamepad
  12692. */
  12693. dispose(): void;
  12694. }
  12695. /**
  12696. * Represents a generic gamepad
  12697. */
  12698. export class GenericPad extends Gamepad {
  12699. private _buttons;
  12700. private _onbuttondown;
  12701. private _onbuttonup;
  12702. /**
  12703. * Observable triggered when a button has been pressed
  12704. */
  12705. onButtonDownObservable: Observable<number>;
  12706. /**
  12707. * Observable triggered when a button has been released
  12708. */
  12709. onButtonUpObservable: Observable<number>;
  12710. /**
  12711. * Callback triggered when a button has been pressed
  12712. * @param callback Called when a button has been pressed
  12713. */
  12714. onbuttondown(callback: (buttonPressed: number) => void): void;
  12715. /**
  12716. * Callback triggered when a button has been released
  12717. * @param callback Called when a button has been released
  12718. */
  12719. onbuttonup(callback: (buttonReleased: number) => void): void;
  12720. /**
  12721. * Initializes the generic gamepad
  12722. * @param id The id of the generic gamepad
  12723. * @param index The index of the generic gamepad
  12724. * @param browserGamepad The browser gamepad
  12725. */
  12726. constructor(id: string, index: number, browserGamepad: any);
  12727. private _setButtonValue;
  12728. /**
  12729. * Updates the generic gamepad
  12730. */
  12731. update(): void;
  12732. /**
  12733. * Disposes the generic gamepad
  12734. */
  12735. dispose(): void;
  12736. }
  12737. }
  12738. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12739. import { Observable } from "babylonjs/Misc/observable";
  12740. import { Nullable } from "babylonjs/types";
  12741. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12744. import { Ray } from "babylonjs/Culling/ray";
  12745. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12746. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12747. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12748. /**
  12749. * Defines the types of pose enabled controllers that are supported
  12750. */
  12751. export enum PoseEnabledControllerType {
  12752. /**
  12753. * HTC Vive
  12754. */
  12755. VIVE = 0,
  12756. /**
  12757. * Oculus Rift
  12758. */
  12759. OCULUS = 1,
  12760. /**
  12761. * Windows mixed reality
  12762. */
  12763. WINDOWS = 2,
  12764. /**
  12765. * Samsung gear VR
  12766. */
  12767. GEAR_VR = 3,
  12768. /**
  12769. * Google Daydream
  12770. */
  12771. DAYDREAM = 4,
  12772. /**
  12773. * Generic
  12774. */
  12775. GENERIC = 5
  12776. }
  12777. /**
  12778. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12779. */
  12780. export interface MutableGamepadButton {
  12781. /**
  12782. * Value of the button/trigger
  12783. */
  12784. value: number;
  12785. /**
  12786. * If the button/trigger is currently touched
  12787. */
  12788. touched: boolean;
  12789. /**
  12790. * If the button/trigger is currently pressed
  12791. */
  12792. pressed: boolean;
  12793. }
  12794. /**
  12795. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12796. * @hidden
  12797. */
  12798. export interface ExtendedGamepadButton extends GamepadButton {
  12799. /**
  12800. * If the button/trigger is currently pressed
  12801. */
  12802. readonly pressed: boolean;
  12803. /**
  12804. * If the button/trigger is currently touched
  12805. */
  12806. readonly touched: boolean;
  12807. /**
  12808. * Value of the button/trigger
  12809. */
  12810. readonly value: number;
  12811. }
  12812. /** @hidden */
  12813. export interface _GamePadFactory {
  12814. /**
  12815. * Returns wether or not the current gamepad can be created for this type of controller.
  12816. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12817. * @returns true if it can be created, otherwise false
  12818. */
  12819. canCreate(gamepadInfo: any): boolean;
  12820. /**
  12821. * Creates a new instance of the Gamepad.
  12822. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12823. * @returns the new gamepad instance
  12824. */
  12825. create(gamepadInfo: any): Gamepad;
  12826. }
  12827. /**
  12828. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12829. */
  12830. export class PoseEnabledControllerHelper {
  12831. /** @hidden */
  12832. static _ControllerFactories: _GamePadFactory[];
  12833. /** @hidden */
  12834. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12835. /**
  12836. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12837. * @param vrGamepad the gamepad to initialized
  12838. * @returns a vr controller of the type the gamepad identified as
  12839. */
  12840. static InitiateController(vrGamepad: any): Gamepad;
  12841. }
  12842. /**
  12843. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12844. */
  12845. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12846. private _deviceRoomPosition;
  12847. private _deviceRoomRotationQuaternion;
  12848. /**
  12849. * The device position in babylon space
  12850. */
  12851. devicePosition: Vector3;
  12852. /**
  12853. * The device rotation in babylon space
  12854. */
  12855. deviceRotationQuaternion: Quaternion;
  12856. /**
  12857. * The scale factor of the device in babylon space
  12858. */
  12859. deviceScaleFactor: number;
  12860. /**
  12861. * (Likely devicePosition should be used instead) The device position in its room space
  12862. */
  12863. position: Vector3;
  12864. /**
  12865. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12866. */
  12867. rotationQuaternion: Quaternion;
  12868. /**
  12869. * The type of controller (Eg. Windows mixed reality)
  12870. */
  12871. controllerType: PoseEnabledControllerType;
  12872. protected _calculatedPosition: Vector3;
  12873. private _calculatedRotation;
  12874. /**
  12875. * The raw pose from the device
  12876. */
  12877. rawPose: DevicePose;
  12878. private _trackPosition;
  12879. private _maxRotationDistFromHeadset;
  12880. private _draggedRoomRotation;
  12881. /**
  12882. * @hidden
  12883. */
  12884. _disableTrackPosition(fixedPosition: Vector3): void;
  12885. /**
  12886. * Internal, the mesh attached to the controller
  12887. * @hidden
  12888. */
  12889. _mesh: Nullable<AbstractMesh>;
  12890. private _poseControlledCamera;
  12891. private _leftHandSystemQuaternion;
  12892. /**
  12893. * Internal, matrix used to convert room space to babylon space
  12894. * @hidden
  12895. */
  12896. _deviceToWorld: Matrix;
  12897. /**
  12898. * Node to be used when casting a ray from the controller
  12899. * @hidden
  12900. */
  12901. _pointingPoseNode: Nullable<TransformNode>;
  12902. /**
  12903. * Name of the child mesh that can be used to cast a ray from the controller
  12904. */
  12905. static readonly POINTING_POSE: string;
  12906. /**
  12907. * Creates a new PoseEnabledController from a gamepad
  12908. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12909. */
  12910. constructor(browserGamepad: any);
  12911. private _workingMatrix;
  12912. /**
  12913. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12914. */
  12915. update(): void;
  12916. /**
  12917. * Updates only the pose device and mesh without doing any button event checking
  12918. */
  12919. protected _updatePoseAndMesh(): void;
  12920. /**
  12921. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12922. * @param poseData raw pose fromthe device
  12923. */
  12924. updateFromDevice(poseData: DevicePose): void;
  12925. /**
  12926. * @hidden
  12927. */
  12928. _meshAttachedObservable: Observable<AbstractMesh>;
  12929. /**
  12930. * Attaches a mesh to the controller
  12931. * @param mesh the mesh to be attached
  12932. */
  12933. attachToMesh(mesh: AbstractMesh): void;
  12934. /**
  12935. * Attaches the controllers mesh to a camera
  12936. * @param camera the camera the mesh should be attached to
  12937. */
  12938. attachToPoseControlledCamera(camera: TargetCamera): void;
  12939. /**
  12940. * Disposes of the controller
  12941. */
  12942. dispose(): void;
  12943. /**
  12944. * The mesh that is attached to the controller
  12945. */
  12946. readonly mesh: Nullable<AbstractMesh>;
  12947. /**
  12948. * Gets the ray of the controller in the direction the controller is pointing
  12949. * @param length the length the resulting ray should be
  12950. * @returns a ray in the direction the controller is pointing
  12951. */
  12952. getForwardRay(length?: number): Ray;
  12953. }
  12954. }
  12955. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12956. import { Observable } from "babylonjs/Misc/observable";
  12957. import { Scene } from "babylonjs/scene";
  12958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12959. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12960. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12961. /**
  12962. * Defines the WebVRController object that represents controllers tracked in 3D space
  12963. */
  12964. export abstract class WebVRController extends PoseEnabledController {
  12965. /**
  12966. * Internal, the default controller model for the controller
  12967. */
  12968. protected _defaultModel: AbstractMesh;
  12969. /**
  12970. * Fired when the trigger state has changed
  12971. */
  12972. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12973. /**
  12974. * Fired when the main button state has changed
  12975. */
  12976. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12977. /**
  12978. * Fired when the secondary button state has changed
  12979. */
  12980. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12981. /**
  12982. * Fired when the pad state has changed
  12983. */
  12984. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12985. /**
  12986. * Fired when controllers stick values have changed
  12987. */
  12988. onPadValuesChangedObservable: Observable<StickValues>;
  12989. /**
  12990. * Array of button availible on the controller
  12991. */
  12992. protected _buttons: Array<MutableGamepadButton>;
  12993. private _onButtonStateChange;
  12994. /**
  12995. * Fired when a controller button's state has changed
  12996. * @param callback the callback containing the button that was modified
  12997. */
  12998. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12999. /**
  13000. * X and Y axis corrisponding to the controllers joystick
  13001. */
  13002. pad: StickValues;
  13003. /**
  13004. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13005. */
  13006. hand: string;
  13007. /**
  13008. * The default controller model for the controller
  13009. */
  13010. readonly defaultModel: AbstractMesh;
  13011. /**
  13012. * Creates a new WebVRController from a gamepad
  13013. * @param vrGamepad the gamepad that the WebVRController should be created from
  13014. */
  13015. constructor(vrGamepad: any);
  13016. /**
  13017. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13018. */
  13019. update(): void;
  13020. /**
  13021. * Function to be called when a button is modified
  13022. */
  13023. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13024. /**
  13025. * Loads a mesh and attaches it to the controller
  13026. * @param scene the scene the mesh should be added to
  13027. * @param meshLoaded callback for when the mesh has been loaded
  13028. */
  13029. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13030. private _setButtonValue;
  13031. private _changes;
  13032. private _checkChanges;
  13033. /**
  13034. * Disposes of th webVRCOntroller
  13035. */
  13036. dispose(): void;
  13037. }
  13038. }
  13039. declare module "babylonjs/Lights/hemisphericLight" {
  13040. import { Nullable } from "babylonjs/types";
  13041. import { Scene } from "babylonjs/scene";
  13042. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13043. import { Effect } from "babylonjs/Materials/effect";
  13044. import { Light } from "babylonjs/Lights/light";
  13045. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13046. /**
  13047. * The HemisphericLight simulates the ambient environment light,
  13048. * so the passed direction is the light reflection direction, not the incoming direction.
  13049. */
  13050. export class HemisphericLight extends Light {
  13051. /**
  13052. * The groundColor is the light in the opposite direction to the one specified during creation.
  13053. * 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.
  13054. */
  13055. groundColor: Color3;
  13056. /**
  13057. * The light reflection direction, not the incoming direction.
  13058. */
  13059. direction: Vector3;
  13060. /**
  13061. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13062. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13063. * The HemisphericLight can't cast shadows.
  13064. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13065. * @param name The friendly name of the light
  13066. * @param direction The direction of the light reflection
  13067. * @param scene The scene the light belongs to
  13068. */
  13069. constructor(name: string, direction: Vector3, scene: Scene);
  13070. protected _buildUniformLayout(): void;
  13071. /**
  13072. * Returns the string "HemisphericLight".
  13073. * @return The class name
  13074. */
  13075. getClassName(): string;
  13076. /**
  13077. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13078. * Returns the updated direction.
  13079. * @param target The target the direction should point to
  13080. * @return The computed direction
  13081. */
  13082. setDirectionToTarget(target: Vector3): Vector3;
  13083. /**
  13084. * Returns the shadow generator associated to the light.
  13085. * @returns Always null for hemispheric lights because it does not support shadows.
  13086. */
  13087. getShadowGenerator(): Nullable<IShadowGenerator>;
  13088. /**
  13089. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13090. * @param effect The effect to update
  13091. * @param lightIndex The index of the light in the effect to update
  13092. * @returns The hemispheric light
  13093. */
  13094. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13095. /**
  13096. * Computes the world matrix of the node
  13097. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13098. * @param useWasUpdatedFlag defines a reserved property
  13099. * @returns the world matrix
  13100. */
  13101. computeWorldMatrix(): Matrix;
  13102. /**
  13103. * Returns the integer 3.
  13104. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13105. */
  13106. getTypeID(): number;
  13107. /**
  13108. * Prepares the list of defines specific to the light type.
  13109. * @param defines the list of defines
  13110. * @param lightIndex defines the index of the light for the effect
  13111. */
  13112. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13113. }
  13114. }
  13115. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13116. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13117. import { Nullable } from "babylonjs/types";
  13118. import { Observable } from "babylonjs/Misc/observable";
  13119. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13120. import { Scene } from "babylonjs/scene";
  13121. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13122. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13123. import { Node } from "babylonjs/node";
  13124. import { Ray } from "babylonjs/Culling/ray";
  13125. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13126. /**
  13127. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13128. * IMPORTANT!! The data is right-hand data.
  13129. * @export
  13130. * @interface DevicePose
  13131. */
  13132. export interface DevicePose {
  13133. /**
  13134. * The position of the device, values in array are [x,y,z].
  13135. */
  13136. readonly position: Nullable<Float32Array>;
  13137. /**
  13138. * The linearVelocity of the device, values in array are [x,y,z].
  13139. */
  13140. readonly linearVelocity: Nullable<Float32Array>;
  13141. /**
  13142. * The linearAcceleration of the device, values in array are [x,y,z].
  13143. */
  13144. readonly linearAcceleration: Nullable<Float32Array>;
  13145. /**
  13146. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13147. */
  13148. readonly orientation: Nullable<Float32Array>;
  13149. /**
  13150. * The angularVelocity of the device, values in array are [x,y,z].
  13151. */
  13152. readonly angularVelocity: Nullable<Float32Array>;
  13153. /**
  13154. * The angularAcceleration of the device, values in array are [x,y,z].
  13155. */
  13156. readonly angularAcceleration: Nullable<Float32Array>;
  13157. }
  13158. /**
  13159. * Interface representing a pose controlled object in Babylon.
  13160. * A pose controlled object has both regular pose values as well as pose values
  13161. * from an external device such as a VR head mounted display
  13162. */
  13163. export interface PoseControlled {
  13164. /**
  13165. * The position of the object in babylon space.
  13166. */
  13167. position: Vector3;
  13168. /**
  13169. * The rotation quaternion of the object in babylon space.
  13170. */
  13171. rotationQuaternion: Quaternion;
  13172. /**
  13173. * The position of the device in babylon space.
  13174. */
  13175. devicePosition?: Vector3;
  13176. /**
  13177. * The rotation quaternion of the device in babylon space.
  13178. */
  13179. deviceRotationQuaternion: Quaternion;
  13180. /**
  13181. * The raw pose coming from the device.
  13182. */
  13183. rawPose: Nullable<DevicePose>;
  13184. /**
  13185. * The scale of the device to be used when translating from device space to babylon space.
  13186. */
  13187. deviceScaleFactor: number;
  13188. /**
  13189. * Updates the poseControlled values based on the input device pose.
  13190. * @param poseData the pose data to update the object with
  13191. */
  13192. updateFromDevice(poseData: DevicePose): void;
  13193. }
  13194. /**
  13195. * Set of options to customize the webVRCamera
  13196. */
  13197. export interface WebVROptions {
  13198. /**
  13199. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13200. */
  13201. trackPosition?: boolean;
  13202. /**
  13203. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13204. */
  13205. positionScale?: number;
  13206. /**
  13207. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13208. */
  13209. displayName?: string;
  13210. /**
  13211. * Should the native controller meshes be initialized. (default: true)
  13212. */
  13213. controllerMeshes?: boolean;
  13214. /**
  13215. * Creating a default HemiLight only on controllers. (default: true)
  13216. */
  13217. defaultLightingOnControllers?: boolean;
  13218. /**
  13219. * If you don't want to use the default VR button of the helper. (default: false)
  13220. */
  13221. useCustomVRButton?: boolean;
  13222. /**
  13223. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13224. */
  13225. customVRButton?: HTMLButtonElement;
  13226. /**
  13227. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13228. */
  13229. rayLength?: number;
  13230. /**
  13231. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13232. */
  13233. defaultHeight?: number;
  13234. }
  13235. /**
  13236. * This represents a WebVR camera.
  13237. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13238. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13239. */
  13240. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13241. private webVROptions;
  13242. /**
  13243. * @hidden
  13244. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13245. */
  13246. _vrDevice: any;
  13247. /**
  13248. * The rawPose of the vrDevice.
  13249. */
  13250. rawPose: Nullable<DevicePose>;
  13251. private _onVREnabled;
  13252. private _specsVersion;
  13253. private _attached;
  13254. private _frameData;
  13255. protected _descendants: Array<Node>;
  13256. private _deviceRoomPosition;
  13257. /** @hidden */
  13258. _deviceRoomRotationQuaternion: Quaternion;
  13259. private _standingMatrix;
  13260. /**
  13261. * Represents device position in babylon space.
  13262. */
  13263. devicePosition: Vector3;
  13264. /**
  13265. * Represents device rotation in babylon space.
  13266. */
  13267. deviceRotationQuaternion: Quaternion;
  13268. /**
  13269. * The scale of the device to be used when translating from device space to babylon space.
  13270. */
  13271. deviceScaleFactor: number;
  13272. private _deviceToWorld;
  13273. private _worldToDevice;
  13274. /**
  13275. * References to the webVR controllers for the vrDevice.
  13276. */
  13277. controllers: Array<WebVRController>;
  13278. /**
  13279. * Emits an event when a controller is attached.
  13280. */
  13281. onControllersAttachedObservable: Observable<WebVRController[]>;
  13282. /**
  13283. * Emits an event when a controller's mesh has been loaded;
  13284. */
  13285. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13286. /**
  13287. * Emits an event when the HMD's pose has been updated.
  13288. */
  13289. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13290. private _poseSet;
  13291. /**
  13292. * If the rig cameras be used as parent instead of this camera.
  13293. */
  13294. rigParenting: boolean;
  13295. private _lightOnControllers;
  13296. private _defaultHeight?;
  13297. /**
  13298. * Instantiates a WebVRFreeCamera.
  13299. * @param name The name of the WebVRFreeCamera
  13300. * @param position The starting anchor position for the camera
  13301. * @param scene The scene the camera belongs to
  13302. * @param webVROptions a set of customizable options for the webVRCamera
  13303. */
  13304. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13305. /**
  13306. * Gets the device distance from the ground in meters.
  13307. * @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.
  13308. */
  13309. deviceDistanceToRoomGround(): number;
  13310. /**
  13311. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13312. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13313. */
  13314. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13315. /**
  13316. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13317. * @returns A promise with a boolean set to if the standing matrix is supported.
  13318. */
  13319. useStandingMatrixAsync(): Promise<boolean>;
  13320. /**
  13321. * Disposes the camera
  13322. */
  13323. dispose(): void;
  13324. /**
  13325. * Gets a vrController by name.
  13326. * @param name The name of the controller to retreive
  13327. * @returns the controller matching the name specified or null if not found
  13328. */
  13329. getControllerByName(name: string): Nullable<WebVRController>;
  13330. private _leftController;
  13331. /**
  13332. * The controller corrisponding to the users left hand.
  13333. */
  13334. readonly leftController: Nullable<WebVRController>;
  13335. private _rightController;
  13336. /**
  13337. * The controller corrisponding to the users right hand.
  13338. */
  13339. readonly rightController: Nullable<WebVRController>;
  13340. /**
  13341. * Casts a ray forward from the vrCamera's gaze.
  13342. * @param length Length of the ray (default: 100)
  13343. * @returns the ray corrisponding to the gaze
  13344. */
  13345. getForwardRay(length?: number): Ray;
  13346. /**
  13347. * @hidden
  13348. * Updates the camera based on device's frame data
  13349. */
  13350. _checkInputs(): void;
  13351. /**
  13352. * Updates the poseControlled values based on the input device pose.
  13353. * @param poseData Pose coming from the device
  13354. */
  13355. updateFromDevice(poseData: DevicePose): void;
  13356. private _htmlElementAttached;
  13357. private _detachIfAttached;
  13358. /**
  13359. * WebVR's attach control will start broadcasting frames to the device.
  13360. * Note that in certain browsers (chrome for example) this function must be called
  13361. * within a user-interaction callback. Example:
  13362. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13363. *
  13364. * @param element html element to attach the vrDevice to
  13365. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13366. */
  13367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13368. /**
  13369. * Detaches the camera from the html element and disables VR
  13370. *
  13371. * @param element html element to detach from
  13372. */
  13373. detachControl(element: HTMLElement): void;
  13374. /**
  13375. * @returns the name of this class
  13376. */
  13377. getClassName(): string;
  13378. /**
  13379. * Calls resetPose on the vrDisplay
  13380. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13381. */
  13382. resetToCurrentRotation(): void;
  13383. /**
  13384. * @hidden
  13385. * Updates the rig cameras (left and right eye)
  13386. */
  13387. _updateRigCameras(): void;
  13388. private _workingVector;
  13389. private _oneVector;
  13390. private _workingMatrix;
  13391. private updateCacheCalled;
  13392. private _correctPositionIfNotTrackPosition;
  13393. /**
  13394. * @hidden
  13395. * Updates the cached values of the camera
  13396. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13397. */
  13398. _updateCache(ignoreParentClass?: boolean): void;
  13399. /**
  13400. * @hidden
  13401. * Get current device position in babylon world
  13402. */
  13403. _computeDevicePosition(): void;
  13404. /**
  13405. * Updates the current device position and rotation in the babylon world
  13406. */
  13407. update(): void;
  13408. /**
  13409. * @hidden
  13410. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13411. * @returns an identity matrix
  13412. */
  13413. _getViewMatrix(): Matrix;
  13414. private _tmpMatrix;
  13415. /**
  13416. * This function is called by the two RIG cameras.
  13417. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13418. * @hidden
  13419. */
  13420. _getWebVRViewMatrix(): Matrix;
  13421. /** @hidden */
  13422. _getWebVRProjectionMatrix(): Matrix;
  13423. private _onGamepadConnectedObserver;
  13424. private _onGamepadDisconnectedObserver;
  13425. private _updateCacheWhenTrackingDisabledObserver;
  13426. /**
  13427. * Initializes the controllers and their meshes
  13428. */
  13429. initControllers(): void;
  13430. }
  13431. }
  13432. declare module "babylonjs/PostProcesses/postProcess" {
  13433. import { Nullable } from "babylonjs/types";
  13434. import { SmartArray } from "babylonjs/Misc/smartArray";
  13435. import { Observable } from "babylonjs/Misc/observable";
  13436. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13437. import { Camera } from "babylonjs/Cameras/camera";
  13438. import { Effect } from "babylonjs/Materials/effect";
  13439. import "babylonjs/Shaders/postprocess.vertex";
  13440. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13442. import { Engine } from "babylonjs/Engines/engine";
  13443. /**
  13444. * Size options for a post process
  13445. */
  13446. export type PostProcessOptions = {
  13447. width: number;
  13448. height: number;
  13449. };
  13450. /**
  13451. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13452. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13453. */
  13454. export class PostProcess {
  13455. /** Name of the PostProcess. */
  13456. name: string;
  13457. /**
  13458. * Gets or sets the unique id of the post process
  13459. */
  13460. uniqueId: number;
  13461. /**
  13462. * Width of the texture to apply the post process on
  13463. */
  13464. width: number;
  13465. /**
  13466. * Height of the texture to apply the post process on
  13467. */
  13468. height: number;
  13469. /**
  13470. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13471. * @hidden
  13472. */
  13473. _outputTexture: Nullable<InternalTexture>;
  13474. /**
  13475. * Sampling mode used by the shader
  13476. * See https://doc.babylonjs.com/classes/3.1/texture
  13477. */
  13478. renderTargetSamplingMode: number;
  13479. /**
  13480. * Clear color to use when screen clearing
  13481. */
  13482. clearColor: Color4;
  13483. /**
  13484. * If the buffer needs to be cleared before applying the post process. (default: true)
  13485. * Should be set to false if shader will overwrite all previous pixels.
  13486. */
  13487. autoClear: boolean;
  13488. /**
  13489. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13490. */
  13491. alphaMode: number;
  13492. /**
  13493. * Sets the setAlphaBlendConstants of the babylon engine
  13494. */
  13495. alphaConstants: Color4;
  13496. /**
  13497. * Animations to be used for the post processing
  13498. */
  13499. animations: import("babylonjs/Animations/animation").Animation[];
  13500. /**
  13501. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13502. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13503. */
  13504. enablePixelPerfectMode: boolean;
  13505. /**
  13506. * Force the postprocess to be applied without taking in account viewport
  13507. */
  13508. forceFullscreenViewport: boolean;
  13509. /**
  13510. * List of inspectable custom properties (used by the Inspector)
  13511. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13512. */
  13513. inspectableCustomProperties: IInspectable[];
  13514. /**
  13515. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13516. *
  13517. * | Value | Type | Description |
  13518. * | ----- | ----------------------------------- | ----------- |
  13519. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13520. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13521. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13522. *
  13523. */
  13524. scaleMode: number;
  13525. /**
  13526. * Force textures to be a power of two (default: false)
  13527. */
  13528. alwaysForcePOT: boolean;
  13529. private _samples;
  13530. /**
  13531. * Number of sample textures (default: 1)
  13532. */
  13533. samples: number;
  13534. /**
  13535. * Modify the scale of the post process to be the same as the viewport (default: false)
  13536. */
  13537. adaptScaleToCurrentViewport: boolean;
  13538. private _camera;
  13539. private _scene;
  13540. private _engine;
  13541. private _options;
  13542. private _reusable;
  13543. private _textureType;
  13544. /**
  13545. * Smart array of input and output textures for the post process.
  13546. * @hidden
  13547. */
  13548. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13549. /**
  13550. * The index in _textures that corresponds to the output texture.
  13551. * @hidden
  13552. */
  13553. _currentRenderTextureInd: number;
  13554. private _effect;
  13555. private _samplers;
  13556. private _fragmentUrl;
  13557. private _vertexUrl;
  13558. private _parameters;
  13559. private _scaleRatio;
  13560. protected _indexParameters: any;
  13561. private _shareOutputWithPostProcess;
  13562. private _texelSize;
  13563. private _forcedOutputTexture;
  13564. /**
  13565. * Returns the fragment url or shader name used in the post process.
  13566. * @returns the fragment url or name in the shader store.
  13567. */
  13568. getEffectName(): string;
  13569. /**
  13570. * An event triggered when the postprocess is activated.
  13571. */
  13572. onActivateObservable: Observable<Camera>;
  13573. private _onActivateObserver;
  13574. /**
  13575. * A function that is added to the onActivateObservable
  13576. */
  13577. onActivate: Nullable<(camera: Camera) => void>;
  13578. /**
  13579. * An event triggered when the postprocess changes its size.
  13580. */
  13581. onSizeChangedObservable: Observable<PostProcess>;
  13582. private _onSizeChangedObserver;
  13583. /**
  13584. * A function that is added to the onSizeChangedObservable
  13585. */
  13586. onSizeChanged: (postProcess: PostProcess) => void;
  13587. /**
  13588. * An event triggered when the postprocess applies its effect.
  13589. */
  13590. onApplyObservable: Observable<Effect>;
  13591. private _onApplyObserver;
  13592. /**
  13593. * A function that is added to the onApplyObservable
  13594. */
  13595. onApply: (effect: Effect) => void;
  13596. /**
  13597. * An event triggered before rendering the postprocess
  13598. */
  13599. onBeforeRenderObservable: Observable<Effect>;
  13600. private _onBeforeRenderObserver;
  13601. /**
  13602. * A function that is added to the onBeforeRenderObservable
  13603. */
  13604. onBeforeRender: (effect: Effect) => void;
  13605. /**
  13606. * An event triggered after rendering the postprocess
  13607. */
  13608. onAfterRenderObservable: Observable<Effect>;
  13609. private _onAfterRenderObserver;
  13610. /**
  13611. * A function that is added to the onAfterRenderObservable
  13612. */
  13613. onAfterRender: (efect: Effect) => void;
  13614. /**
  13615. * 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
  13616. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13617. */
  13618. inputTexture: InternalTexture;
  13619. /**
  13620. * Gets the camera which post process is applied to.
  13621. * @returns The camera the post process is applied to.
  13622. */
  13623. getCamera(): Camera;
  13624. /**
  13625. * Gets the texel size of the postprocess.
  13626. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13627. */
  13628. readonly texelSize: Vector2;
  13629. /**
  13630. * Creates a new instance PostProcess
  13631. * @param name The name of the PostProcess.
  13632. * @param fragmentUrl The url of the fragment shader to be used.
  13633. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13634. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13635. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13636. * @param camera The camera to apply the render pass to.
  13637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13638. * @param engine The engine which the post process will be applied. (default: current engine)
  13639. * @param reusable If the post process can be reused on the same frame. (default: false)
  13640. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13641. * @param textureType Type of textures used when performing the post process. (default: 0)
  13642. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13643. * @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
  13644. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13645. */
  13646. constructor(
  13647. /** Name of the PostProcess. */
  13648. 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);
  13649. /**
  13650. * Gets a string idenfifying the name of the class
  13651. * @returns "PostProcess" string
  13652. */
  13653. getClassName(): string;
  13654. /**
  13655. * Gets the engine which this post process belongs to.
  13656. * @returns The engine the post process was enabled with.
  13657. */
  13658. getEngine(): Engine;
  13659. /**
  13660. * The effect that is created when initializing the post process.
  13661. * @returns The created effect corrisponding the the postprocess.
  13662. */
  13663. getEffect(): Effect;
  13664. /**
  13665. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13666. * @param postProcess The post process to share the output with.
  13667. * @returns This post process.
  13668. */
  13669. shareOutputWith(postProcess: PostProcess): PostProcess;
  13670. /**
  13671. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13672. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13673. */
  13674. useOwnOutput(): void;
  13675. /**
  13676. * Updates the effect with the current post process compile time values and recompiles the shader.
  13677. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13678. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13679. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13680. * @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
  13681. * @param onCompiled Called when the shader has been compiled.
  13682. * @param onError Called if there is an error when compiling a shader.
  13683. */
  13684. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13685. /**
  13686. * The post process is reusable if it can be used multiple times within one frame.
  13687. * @returns If the post process is reusable
  13688. */
  13689. isReusable(): boolean;
  13690. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13691. markTextureDirty(): void;
  13692. /**
  13693. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13694. * 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.
  13695. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13696. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13697. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13698. * @returns The target texture that was bound to be written to.
  13699. */
  13700. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13701. /**
  13702. * If the post process is supported.
  13703. */
  13704. readonly isSupported: boolean;
  13705. /**
  13706. * The aspect ratio of the output texture.
  13707. */
  13708. readonly aspectRatio: number;
  13709. /**
  13710. * Get a value indicating if the post-process is ready to be used
  13711. * @returns true if the post-process is ready (shader is compiled)
  13712. */
  13713. isReady(): boolean;
  13714. /**
  13715. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13716. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13717. */
  13718. apply(): Nullable<Effect>;
  13719. private _disposeTextures;
  13720. /**
  13721. * Disposes the post process.
  13722. * @param camera The camera to dispose the post process on.
  13723. */
  13724. dispose(camera?: Camera): void;
  13725. }
  13726. }
  13727. declare module "babylonjs/PostProcesses/postProcessManager" {
  13728. import { Nullable } from "babylonjs/types";
  13729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13730. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13731. import { Scene } from "babylonjs/scene";
  13732. /**
  13733. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13734. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13735. */
  13736. export class PostProcessManager {
  13737. private _scene;
  13738. private _indexBuffer;
  13739. private _vertexBuffers;
  13740. /**
  13741. * Creates a new instance PostProcess
  13742. * @param scene The scene that the post process is associated with.
  13743. */
  13744. constructor(scene: Scene);
  13745. private _prepareBuffers;
  13746. private _buildIndexBuffer;
  13747. /**
  13748. * Rebuilds the vertex buffers of the manager.
  13749. * @hidden
  13750. */
  13751. _rebuild(): void;
  13752. /**
  13753. * Prepares a frame to be run through a post process.
  13754. * @param sourceTexture The input texture to the post procesess. (default: null)
  13755. * @param postProcesses An array of post processes to be run. (default: null)
  13756. * @returns True if the post processes were able to be run.
  13757. * @hidden
  13758. */
  13759. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13760. /**
  13761. * Manually render a set of post processes to a texture.
  13762. * @param postProcesses An array of post processes to be run.
  13763. * @param targetTexture The target texture to render to.
  13764. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13765. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13766. * @param lodLevel defines which lod of the texture to render to
  13767. */
  13768. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13769. /**
  13770. * Finalize the result of the output of the postprocesses.
  13771. * @param doNotPresent If true the result will not be displayed to the screen.
  13772. * @param targetTexture The target texture to render to.
  13773. * @param faceIndex The index of the face to bind the target texture to.
  13774. * @param postProcesses The array of post processes to render.
  13775. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13776. * @hidden
  13777. */
  13778. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13779. /**
  13780. * Disposes of the post process manager.
  13781. */
  13782. dispose(): void;
  13783. }
  13784. }
  13785. declare module "babylonjs/Layers/layerSceneComponent" {
  13786. import { Scene } from "babylonjs/scene";
  13787. import { ISceneComponent } from "babylonjs/sceneComponent";
  13788. import { Layer } from "babylonjs/Layers/layer";
  13789. module "babylonjs/abstractScene" {
  13790. interface AbstractScene {
  13791. /**
  13792. * The list of layers (background and foreground) of the scene
  13793. */
  13794. layers: Array<Layer>;
  13795. }
  13796. }
  13797. /**
  13798. * Defines the layer scene component responsible to manage any layers
  13799. * in a given scene.
  13800. */
  13801. export class LayerSceneComponent implements ISceneComponent {
  13802. /**
  13803. * The component name helpfull to identify the component in the list of scene components.
  13804. */
  13805. readonly name: string;
  13806. /**
  13807. * The scene the component belongs to.
  13808. */
  13809. scene: Scene;
  13810. private _engine;
  13811. /**
  13812. * Creates a new instance of the component for the given scene
  13813. * @param scene Defines the scene to register the component in
  13814. */
  13815. constructor(scene: Scene);
  13816. /**
  13817. * Registers the component in a given scene
  13818. */
  13819. register(): void;
  13820. /**
  13821. * Rebuilds the elements related to this component in case of
  13822. * context lost for instance.
  13823. */
  13824. rebuild(): void;
  13825. /**
  13826. * Disposes the component and the associated ressources.
  13827. */
  13828. dispose(): void;
  13829. private _draw;
  13830. private _drawCameraPredicate;
  13831. private _drawCameraBackground;
  13832. private _drawCameraForeground;
  13833. private _drawRenderTargetPredicate;
  13834. private _drawRenderTargetBackground;
  13835. private _drawRenderTargetForeground;
  13836. }
  13837. }
  13838. declare module "babylonjs/Shaders/layer.fragment" {
  13839. /** @hidden */
  13840. export var layerPixelShader: {
  13841. name: string;
  13842. shader: string;
  13843. };
  13844. }
  13845. declare module "babylonjs/Shaders/layer.vertex" {
  13846. /** @hidden */
  13847. export var layerVertexShader: {
  13848. name: string;
  13849. shader: string;
  13850. };
  13851. }
  13852. declare module "babylonjs/Layers/layer" {
  13853. import { Observable } from "babylonjs/Misc/observable";
  13854. import { Nullable } from "babylonjs/types";
  13855. import { Scene } from "babylonjs/scene";
  13856. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13857. import { Texture } from "babylonjs/Materials/Textures/texture";
  13858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13859. import "babylonjs/Shaders/layer.fragment";
  13860. import "babylonjs/Shaders/layer.vertex";
  13861. /**
  13862. * This represents a full screen 2d layer.
  13863. * This can be useful to display a picture in the background of your scene for instance.
  13864. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13865. */
  13866. export class Layer {
  13867. /**
  13868. * Define the name of the layer.
  13869. */
  13870. name: string;
  13871. /**
  13872. * Define the texture the layer should display.
  13873. */
  13874. texture: Nullable<Texture>;
  13875. /**
  13876. * Is the layer in background or foreground.
  13877. */
  13878. isBackground: boolean;
  13879. /**
  13880. * Define the color of the layer (instead of texture).
  13881. */
  13882. color: Color4;
  13883. /**
  13884. * Define the scale of the layer in order to zoom in out of the texture.
  13885. */
  13886. scale: Vector2;
  13887. /**
  13888. * Define an offset for the layer in order to shift the texture.
  13889. */
  13890. offset: Vector2;
  13891. /**
  13892. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13893. */
  13894. alphaBlendingMode: number;
  13895. /**
  13896. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13897. * Alpha test will not mix with the background color in case of transparency.
  13898. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13899. */
  13900. alphaTest: boolean;
  13901. /**
  13902. * Define a mask to restrict the layer to only some of the scene cameras.
  13903. */
  13904. layerMask: number;
  13905. /**
  13906. * Define the list of render target the layer is visible into.
  13907. */
  13908. renderTargetTextures: RenderTargetTexture[];
  13909. /**
  13910. * Define if the layer is only used in renderTarget or if it also
  13911. * renders in the main frame buffer of the canvas.
  13912. */
  13913. renderOnlyInRenderTargetTextures: boolean;
  13914. private _scene;
  13915. private _vertexBuffers;
  13916. private _indexBuffer;
  13917. private _effect;
  13918. private _alphaTestEffect;
  13919. /**
  13920. * An event triggered when the layer is disposed.
  13921. */
  13922. onDisposeObservable: Observable<Layer>;
  13923. private _onDisposeObserver;
  13924. /**
  13925. * Back compatibility with callback before the onDisposeObservable existed.
  13926. * The set callback will be triggered when the layer has been disposed.
  13927. */
  13928. onDispose: () => void;
  13929. /**
  13930. * An event triggered before rendering the scene
  13931. */
  13932. onBeforeRenderObservable: Observable<Layer>;
  13933. private _onBeforeRenderObserver;
  13934. /**
  13935. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13936. * The set callback will be triggered just before rendering the layer.
  13937. */
  13938. onBeforeRender: () => void;
  13939. /**
  13940. * An event triggered after rendering the scene
  13941. */
  13942. onAfterRenderObservable: Observable<Layer>;
  13943. private _onAfterRenderObserver;
  13944. /**
  13945. * Back compatibility with callback before the onAfterRenderObservable existed.
  13946. * The set callback will be triggered just after rendering the layer.
  13947. */
  13948. onAfterRender: () => void;
  13949. /**
  13950. * Instantiates a new layer.
  13951. * This represents a full screen 2d layer.
  13952. * This can be useful to display a picture in the background of your scene for instance.
  13953. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13954. * @param name Define the name of the layer in the scene
  13955. * @param imgUrl Define the url of the texture to display in the layer
  13956. * @param scene Define the scene the layer belongs to
  13957. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13958. * @param color Defines a color for the layer
  13959. */
  13960. constructor(
  13961. /**
  13962. * Define the name of the layer.
  13963. */
  13964. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13965. private _createIndexBuffer;
  13966. /** @hidden */
  13967. _rebuild(): void;
  13968. /**
  13969. * Renders the layer in the scene.
  13970. */
  13971. render(): void;
  13972. /**
  13973. * Disposes and releases the associated ressources.
  13974. */
  13975. dispose(): void;
  13976. }
  13977. }
  13978. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13979. import { Scene } from "babylonjs/scene";
  13980. import { ISceneComponent } from "babylonjs/sceneComponent";
  13981. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13982. module "babylonjs/abstractScene" {
  13983. interface AbstractScene {
  13984. /**
  13985. * The list of procedural textures added to the scene
  13986. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13987. */
  13988. proceduralTextures: Array<ProceduralTexture>;
  13989. }
  13990. }
  13991. /**
  13992. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13993. * in a given scene.
  13994. */
  13995. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13996. /**
  13997. * The component name helpfull to identify the component in the list of scene components.
  13998. */
  13999. readonly name: string;
  14000. /**
  14001. * The scene the component belongs to.
  14002. */
  14003. scene: Scene;
  14004. /**
  14005. * Creates a new instance of the component for the given scene
  14006. * @param scene Defines the scene to register the component in
  14007. */
  14008. constructor(scene: Scene);
  14009. /**
  14010. * Registers the component in a given scene
  14011. */
  14012. register(): void;
  14013. /**
  14014. * Rebuilds the elements related to this component in case of
  14015. * context lost for instance.
  14016. */
  14017. rebuild(): void;
  14018. /**
  14019. * Disposes the component and the associated ressources.
  14020. */
  14021. dispose(): void;
  14022. private _beforeClear;
  14023. }
  14024. }
  14025. declare module "babylonjs/Shaders/procedural.vertex" {
  14026. /** @hidden */
  14027. export var proceduralVertexShader: {
  14028. name: string;
  14029. shader: string;
  14030. };
  14031. }
  14032. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14033. import { Observable } from "babylonjs/Misc/observable";
  14034. import { Nullable } from "babylonjs/types";
  14035. import { Scene } from "babylonjs/scene";
  14036. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14037. import { Effect } from "babylonjs/Materials/effect";
  14038. import { Texture } from "babylonjs/Materials/Textures/texture";
  14039. import "babylonjs/Shaders/procedural.vertex";
  14040. /**
  14041. * 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.
  14042. * This is the base class of any Procedural texture and contains most of the shareable code.
  14043. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14044. */
  14045. export class ProceduralTexture extends Texture {
  14046. isCube: boolean;
  14047. /**
  14048. * Define if the texture is enabled or not (disabled texture will not render)
  14049. */
  14050. isEnabled: boolean;
  14051. /**
  14052. * Define if the texture must be cleared before rendering (default is true)
  14053. */
  14054. autoClear: boolean;
  14055. /**
  14056. * Callback called when the texture is generated
  14057. */
  14058. onGenerated: () => void;
  14059. /**
  14060. * Event raised when the texture is generated
  14061. */
  14062. onGeneratedObservable: Observable<ProceduralTexture>;
  14063. /** @hidden */
  14064. _generateMipMaps: boolean;
  14065. /** @hidden **/
  14066. _effect: Effect;
  14067. /** @hidden */
  14068. _textures: {
  14069. [key: string]: Texture;
  14070. };
  14071. private _size;
  14072. private _currentRefreshId;
  14073. private _refreshRate;
  14074. private _vertexBuffers;
  14075. private _indexBuffer;
  14076. private _uniforms;
  14077. private _samplers;
  14078. private _fragment;
  14079. private _floats;
  14080. private _ints;
  14081. private _floatsArrays;
  14082. private _colors3;
  14083. private _colors4;
  14084. private _vectors2;
  14085. private _vectors3;
  14086. private _matrices;
  14087. private _fallbackTexture;
  14088. private _fallbackTextureUsed;
  14089. private _engine;
  14090. private _cachedDefines;
  14091. private _contentUpdateId;
  14092. private _contentData;
  14093. /**
  14094. * Instantiates a new procedural texture.
  14095. * 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.
  14096. * This is the base class of any Procedural texture and contains most of the shareable code.
  14097. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14098. * @param name Define the name of the texture
  14099. * @param size Define the size of the texture to create
  14100. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14101. * @param scene Define the scene the texture belongs to
  14102. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14103. * @param generateMipMaps Define if the texture should creates mip maps or not
  14104. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14105. */
  14106. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14107. /**
  14108. * The effect that is created when initializing the post process.
  14109. * @returns The created effect corrisponding the the postprocess.
  14110. */
  14111. getEffect(): Effect;
  14112. /**
  14113. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14114. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14115. */
  14116. getContent(): Nullable<ArrayBufferView>;
  14117. private _createIndexBuffer;
  14118. /** @hidden */
  14119. _rebuild(): void;
  14120. /**
  14121. * Resets the texture in order to recreate its associated resources.
  14122. * This can be called in case of context loss
  14123. */
  14124. reset(): void;
  14125. protected _getDefines(): string;
  14126. /**
  14127. * Is the texture ready to be used ? (rendered at least once)
  14128. * @returns true if ready, otherwise, false.
  14129. */
  14130. isReady(): boolean;
  14131. /**
  14132. * Resets the refresh counter of the texture and start bak from scratch.
  14133. * Could be useful to regenerate the texture if it is setup to render only once.
  14134. */
  14135. resetRefreshCounter(): void;
  14136. /**
  14137. * Set the fragment shader to use in order to render the texture.
  14138. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14139. */
  14140. setFragment(fragment: any): void;
  14141. /**
  14142. * Define the refresh rate of the texture or the rendering frequency.
  14143. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14144. */
  14145. refreshRate: number;
  14146. /** @hidden */
  14147. _shouldRender(): boolean;
  14148. /**
  14149. * Get the size the texture is rendering at.
  14150. * @returns the size (texture is always squared)
  14151. */
  14152. getRenderSize(): number;
  14153. /**
  14154. * Resize the texture to new value.
  14155. * @param size Define the new size the texture should have
  14156. * @param generateMipMaps Define whether the new texture should create mip maps
  14157. */
  14158. resize(size: number, generateMipMaps: boolean): void;
  14159. private _checkUniform;
  14160. /**
  14161. * Set a texture in the shader program used to render.
  14162. * @param name Define the name of the uniform samplers as defined in the shader
  14163. * @param texture Define the texture to bind to this sampler
  14164. * @return the texture itself allowing "fluent" like uniform updates
  14165. */
  14166. setTexture(name: string, texture: Texture): ProceduralTexture;
  14167. /**
  14168. * Set a float in the shader.
  14169. * @param name Define the name of the uniform as defined in the shader
  14170. * @param value Define the value to give to the uniform
  14171. * @return the texture itself allowing "fluent" like uniform updates
  14172. */
  14173. setFloat(name: string, value: number): ProceduralTexture;
  14174. /**
  14175. * Set a int in the shader.
  14176. * @param name Define the name of the uniform as defined in the shader
  14177. * @param value Define the value to give to the uniform
  14178. * @return the texture itself allowing "fluent" like uniform updates
  14179. */
  14180. setInt(name: string, value: number): ProceduralTexture;
  14181. /**
  14182. * Set an array of floats in the shader.
  14183. * @param name Define the name of the uniform as defined in the shader
  14184. * @param value Define the value to give to the uniform
  14185. * @return the texture itself allowing "fluent" like uniform updates
  14186. */
  14187. setFloats(name: string, value: number[]): ProceduralTexture;
  14188. /**
  14189. * Set a vec3 in the shader from a Color3.
  14190. * @param name Define the name of the uniform as defined in the shader
  14191. * @param value Define the value to give to the uniform
  14192. * @return the texture itself allowing "fluent" like uniform updates
  14193. */
  14194. setColor3(name: string, value: Color3): ProceduralTexture;
  14195. /**
  14196. * Set a vec4 in the shader from a Color4.
  14197. * @param name Define the name of the uniform as defined in the shader
  14198. * @param value Define the value to give to the uniform
  14199. * @return the texture itself allowing "fluent" like uniform updates
  14200. */
  14201. setColor4(name: string, value: Color4): ProceduralTexture;
  14202. /**
  14203. * Set a vec2 in the shader from a Vector2.
  14204. * @param name Define the name of the uniform as defined in the shader
  14205. * @param value Define the value to give to the uniform
  14206. * @return the texture itself allowing "fluent" like uniform updates
  14207. */
  14208. setVector2(name: string, value: Vector2): ProceduralTexture;
  14209. /**
  14210. * Set a vec3 in the shader from a Vector3.
  14211. * @param name Define the name of the uniform as defined in the shader
  14212. * @param value Define the value to give to the uniform
  14213. * @return the texture itself allowing "fluent" like uniform updates
  14214. */
  14215. setVector3(name: string, value: Vector3): ProceduralTexture;
  14216. /**
  14217. * Set a mat4 in the shader from a MAtrix.
  14218. * @param name Define the name of the uniform as defined in the shader
  14219. * @param value Define the value to give to the uniform
  14220. * @return the texture itself allowing "fluent" like uniform updates
  14221. */
  14222. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14223. /**
  14224. * Render the texture to its associated render target.
  14225. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14226. */
  14227. render(useCameraPostProcess?: boolean): void;
  14228. /**
  14229. * Clone the texture.
  14230. * @returns the cloned texture
  14231. */
  14232. clone(): ProceduralTexture;
  14233. /**
  14234. * Dispose the texture and release its asoociated resources.
  14235. */
  14236. dispose(): void;
  14237. }
  14238. }
  14239. declare module "babylonjs/Particles/baseParticleSystem" {
  14240. import { Nullable } from "babylonjs/types";
  14241. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14243. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14244. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14245. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14246. import { Scene } from "babylonjs/scene";
  14247. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14248. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14249. import { Texture } from "babylonjs/Materials/Textures/texture";
  14250. import { Animation } from "babylonjs/Animations/animation";
  14251. /**
  14252. * This represents the base class for particle system in Babylon.
  14253. * 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.
  14254. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14255. * @example https://doc.babylonjs.com/babylon101/particles
  14256. */
  14257. export class BaseParticleSystem {
  14258. /**
  14259. * Source color is added to the destination color without alpha affecting the result
  14260. */
  14261. static BLENDMODE_ONEONE: number;
  14262. /**
  14263. * Blend current color and particle color using particle’s alpha
  14264. */
  14265. static BLENDMODE_STANDARD: number;
  14266. /**
  14267. * Add current color and particle color multiplied by particle’s alpha
  14268. */
  14269. static BLENDMODE_ADD: number;
  14270. /**
  14271. * Multiply current color with particle color
  14272. */
  14273. static BLENDMODE_MULTIPLY: number;
  14274. /**
  14275. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14276. */
  14277. static BLENDMODE_MULTIPLYADD: number;
  14278. /**
  14279. * List of animations used by the particle system.
  14280. */
  14281. animations: Animation[];
  14282. /**
  14283. * The id of the Particle system.
  14284. */
  14285. id: string;
  14286. /**
  14287. * The friendly name of the Particle system.
  14288. */
  14289. name: string;
  14290. /**
  14291. * The rendering group used by the Particle system to chose when to render.
  14292. */
  14293. renderingGroupId: number;
  14294. /**
  14295. * The emitter represents the Mesh or position we are attaching the particle system to.
  14296. */
  14297. emitter: Nullable<AbstractMesh | Vector3>;
  14298. /**
  14299. * The maximum number of particles to emit per frame
  14300. */
  14301. emitRate: number;
  14302. /**
  14303. * If you want to launch only a few particles at once, that can be done, as well.
  14304. */
  14305. manualEmitCount: number;
  14306. /**
  14307. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14308. */
  14309. updateSpeed: number;
  14310. /**
  14311. * The amount of time the particle system is running (depends of the overall update speed).
  14312. */
  14313. targetStopDuration: number;
  14314. /**
  14315. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14316. */
  14317. disposeOnStop: boolean;
  14318. /**
  14319. * Minimum power of emitting particles.
  14320. */
  14321. minEmitPower: number;
  14322. /**
  14323. * Maximum power of emitting particles.
  14324. */
  14325. maxEmitPower: number;
  14326. /**
  14327. * Minimum life time of emitting particles.
  14328. */
  14329. minLifeTime: number;
  14330. /**
  14331. * Maximum life time of emitting particles.
  14332. */
  14333. maxLifeTime: number;
  14334. /**
  14335. * Minimum Size of emitting particles.
  14336. */
  14337. minSize: number;
  14338. /**
  14339. * Maximum Size of emitting particles.
  14340. */
  14341. maxSize: number;
  14342. /**
  14343. * Minimum scale of emitting particles on X axis.
  14344. */
  14345. minScaleX: number;
  14346. /**
  14347. * Maximum scale of emitting particles on X axis.
  14348. */
  14349. maxScaleX: number;
  14350. /**
  14351. * Minimum scale of emitting particles on Y axis.
  14352. */
  14353. minScaleY: number;
  14354. /**
  14355. * Maximum scale of emitting particles on Y axis.
  14356. */
  14357. maxScaleY: number;
  14358. /**
  14359. * Gets or sets the minimal initial rotation in radians.
  14360. */
  14361. minInitialRotation: number;
  14362. /**
  14363. * Gets or sets the maximal initial rotation in radians.
  14364. */
  14365. maxInitialRotation: number;
  14366. /**
  14367. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14368. */
  14369. minAngularSpeed: number;
  14370. /**
  14371. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14372. */
  14373. maxAngularSpeed: number;
  14374. /**
  14375. * The texture used to render each particle. (this can be a spritesheet)
  14376. */
  14377. particleTexture: Nullable<Texture>;
  14378. /**
  14379. * The layer mask we are rendering the particles through.
  14380. */
  14381. layerMask: number;
  14382. /**
  14383. * This can help using your own shader to render the particle system.
  14384. * The according effect will be created
  14385. */
  14386. customShader: any;
  14387. /**
  14388. * By default particle system starts as soon as they are created. This prevents the
  14389. * automatic start to happen and let you decide when to start emitting particles.
  14390. */
  14391. preventAutoStart: boolean;
  14392. private _noiseTexture;
  14393. /**
  14394. * Gets or sets a texture used to add random noise to particle positions
  14395. */
  14396. noiseTexture: Nullable<ProceduralTexture>;
  14397. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14398. noiseStrength: Vector3;
  14399. /**
  14400. * Callback triggered when the particle animation is ending.
  14401. */
  14402. onAnimationEnd: Nullable<() => void>;
  14403. /**
  14404. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14405. */
  14406. blendMode: number;
  14407. /**
  14408. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14409. * to override the particles.
  14410. */
  14411. forceDepthWrite: boolean;
  14412. /** 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 */
  14413. preWarmCycles: number;
  14414. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14415. preWarmStepOffset: number;
  14416. /**
  14417. * 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)
  14418. */
  14419. spriteCellChangeSpeed: number;
  14420. /**
  14421. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14422. */
  14423. startSpriteCellID: number;
  14424. /**
  14425. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14426. */
  14427. endSpriteCellID: number;
  14428. /**
  14429. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14430. */
  14431. spriteCellWidth: number;
  14432. /**
  14433. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14434. */
  14435. spriteCellHeight: number;
  14436. /**
  14437. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14438. */
  14439. spriteRandomStartCell: boolean;
  14440. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14441. translationPivot: Vector2;
  14442. /** @hidden */
  14443. protected _isAnimationSheetEnabled: boolean;
  14444. /**
  14445. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14446. */
  14447. beginAnimationOnStart: boolean;
  14448. /**
  14449. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14450. */
  14451. beginAnimationFrom: number;
  14452. /**
  14453. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14454. */
  14455. beginAnimationTo: number;
  14456. /**
  14457. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14458. */
  14459. beginAnimationLoop: boolean;
  14460. /**
  14461. * Gets or sets a world offset applied to all particles
  14462. */
  14463. worldOffset: Vector3;
  14464. /**
  14465. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14466. */
  14467. isAnimationSheetEnabled: boolean;
  14468. /**
  14469. * Get hosting scene
  14470. * @returns the scene
  14471. */
  14472. getScene(): Scene;
  14473. /**
  14474. * You can use gravity if you want to give an orientation to your particles.
  14475. */
  14476. gravity: Vector3;
  14477. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14478. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14479. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14480. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14481. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14482. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14483. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14484. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14485. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14486. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14487. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14488. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14489. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14490. /**
  14491. * Defines the delay in milliseconds before starting the system (0 by default)
  14492. */
  14493. startDelay: number;
  14494. /**
  14495. * Gets the current list of drag gradients.
  14496. * You must use addDragGradient and removeDragGradient to udpate this list
  14497. * @returns the list of drag gradients
  14498. */
  14499. getDragGradients(): Nullable<Array<FactorGradient>>;
  14500. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14501. limitVelocityDamping: number;
  14502. /**
  14503. * Gets the current list of limit velocity gradients.
  14504. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14505. * @returns the list of limit velocity gradients
  14506. */
  14507. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14508. /**
  14509. * Gets the current list of color gradients.
  14510. * You must use addColorGradient and removeColorGradient to udpate this list
  14511. * @returns the list of color gradients
  14512. */
  14513. getColorGradients(): Nullable<Array<ColorGradient>>;
  14514. /**
  14515. * Gets the current list of size gradients.
  14516. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14517. * @returns the list of size gradients
  14518. */
  14519. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14520. /**
  14521. * Gets the current list of color remap gradients.
  14522. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14523. * @returns the list of color remap gradients
  14524. */
  14525. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14526. /**
  14527. * Gets the current list of alpha remap gradients.
  14528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14529. * @returns the list of alpha remap gradients
  14530. */
  14531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Gets the current list of life time gradients.
  14534. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14535. * @returns the list of life time gradients
  14536. */
  14537. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14538. /**
  14539. * Gets the current list of angular speed gradients.
  14540. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14541. * @returns the list of angular speed gradients
  14542. */
  14543. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Gets the current list of velocity gradients.
  14546. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14547. * @returns the list of velocity gradients
  14548. */
  14549. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14550. /**
  14551. * Gets the current list of start size gradients.
  14552. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14553. * @returns the list of start size gradients
  14554. */
  14555. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Gets the current list of emit rate gradients.
  14558. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14559. * @returns the list of emit rate gradients
  14560. */
  14561. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14562. /**
  14563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14564. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14565. */
  14566. direction1: Vector3;
  14567. /**
  14568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14569. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14570. */
  14571. direction2: Vector3;
  14572. /**
  14573. * 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.
  14574. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14575. */
  14576. minEmitBox: Vector3;
  14577. /**
  14578. * 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.
  14579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14580. */
  14581. maxEmitBox: Vector3;
  14582. /**
  14583. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14584. */
  14585. color1: Color4;
  14586. /**
  14587. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14588. */
  14589. color2: Color4;
  14590. /**
  14591. * Color the particle will have at the end of its lifetime
  14592. */
  14593. colorDead: Color4;
  14594. /**
  14595. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14596. */
  14597. textureMask: Color4;
  14598. /**
  14599. * The particle emitter type defines the emitter used by the particle system.
  14600. * It can be for example box, sphere, or cone...
  14601. */
  14602. particleEmitterType: IParticleEmitterType;
  14603. /** @hidden */
  14604. _isSubEmitter: boolean;
  14605. /**
  14606. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14607. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14608. */
  14609. billboardMode: number;
  14610. protected _isBillboardBased: boolean;
  14611. /**
  14612. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14613. */
  14614. isBillboardBased: boolean;
  14615. /**
  14616. * The scene the particle system belongs to.
  14617. */
  14618. protected _scene: Scene;
  14619. /**
  14620. * Local cache of defines for image processing.
  14621. */
  14622. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14623. /**
  14624. * Default configuration related to image processing available in the standard Material.
  14625. */
  14626. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14627. /**
  14628. * Gets the image processing configuration used either in this material.
  14629. */
  14630. /**
  14631. * Sets the Default image processing configuration used either in the this material.
  14632. *
  14633. * If sets to null, the scene one is in use.
  14634. */
  14635. imageProcessingConfiguration: ImageProcessingConfiguration;
  14636. /**
  14637. * Attaches a new image processing configuration to the Standard Material.
  14638. * @param configuration
  14639. */
  14640. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14641. /** @hidden */
  14642. protected _reset(): void;
  14643. /** @hidden */
  14644. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14645. /**
  14646. * Instantiates a particle system.
  14647. * 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.
  14648. * @param name The name of the particle system
  14649. */
  14650. constructor(name: string);
  14651. /**
  14652. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14655. * @returns the emitter
  14656. */
  14657. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14658. /**
  14659. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14660. * @param radius The radius of the hemisphere to emit from
  14661. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14662. * @returns the emitter
  14663. */
  14664. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14665. /**
  14666. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14667. * @param radius The radius of the sphere to emit from
  14668. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14669. * @returns the emitter
  14670. */
  14671. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14672. /**
  14673. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14674. * @param radius The radius of the sphere to emit from
  14675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14677. * @returns the emitter
  14678. */
  14679. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14680. /**
  14681. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14682. * @param radius The radius of the emission cylinder
  14683. * @param height The height of the emission cylinder
  14684. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14685. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14686. * @returns the emitter
  14687. */
  14688. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14689. /**
  14690. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14691. * @param radius The radius of the cylinder to emit from
  14692. * @param height The height of the emission cylinder
  14693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14696. * @returns the emitter
  14697. */
  14698. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14699. /**
  14700. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14701. * @param radius The radius of the cone to emit from
  14702. * @param angle The base angle of the cone
  14703. * @returns the emitter
  14704. */
  14705. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14706. /**
  14707. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14710. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14711. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14712. * @returns the emitter
  14713. */
  14714. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14715. }
  14716. }
  14717. declare module "babylonjs/Particles/subEmitter" {
  14718. import { Scene } from "babylonjs/scene";
  14719. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14720. /**
  14721. * Type of sub emitter
  14722. */
  14723. export enum SubEmitterType {
  14724. /**
  14725. * Attached to the particle over it's lifetime
  14726. */
  14727. ATTACHED = 0,
  14728. /**
  14729. * Created when the particle dies
  14730. */
  14731. END = 1
  14732. }
  14733. /**
  14734. * Sub emitter class used to emit particles from an existing particle
  14735. */
  14736. export class SubEmitter {
  14737. /**
  14738. * the particle system to be used by the sub emitter
  14739. */
  14740. particleSystem: ParticleSystem;
  14741. /**
  14742. * Type of the submitter (Default: END)
  14743. */
  14744. type: SubEmitterType;
  14745. /**
  14746. * 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)
  14747. * Note: This only is supported when using an emitter of type Mesh
  14748. */
  14749. inheritDirection: boolean;
  14750. /**
  14751. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14752. */
  14753. inheritedVelocityAmount: number;
  14754. /**
  14755. * Creates a sub emitter
  14756. * @param particleSystem the particle system to be used by the sub emitter
  14757. */
  14758. constructor(
  14759. /**
  14760. * the particle system to be used by the sub emitter
  14761. */
  14762. particleSystem: ParticleSystem);
  14763. /**
  14764. * Clones the sub emitter
  14765. * @returns the cloned sub emitter
  14766. */
  14767. clone(): SubEmitter;
  14768. /**
  14769. * Serialize current object to a JSON object
  14770. * @returns the serialized object
  14771. */
  14772. serialize(): any;
  14773. /** @hidden */
  14774. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14775. /**
  14776. * Creates a new SubEmitter from a serialized JSON version
  14777. * @param serializationObject defines the JSON object to read from
  14778. * @param scene defines the hosting scene
  14779. * @param rootUrl defines the rootUrl for data loading
  14780. * @returns a new SubEmitter
  14781. */
  14782. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14783. /** Release associated resources */
  14784. dispose(): void;
  14785. }
  14786. }
  14787. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14788. /** @hidden */
  14789. export var clipPlaneFragmentDeclaration: {
  14790. name: string;
  14791. shader: string;
  14792. };
  14793. }
  14794. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14795. /** @hidden */
  14796. export var imageProcessingDeclaration: {
  14797. name: string;
  14798. shader: string;
  14799. };
  14800. }
  14801. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14802. /** @hidden */
  14803. export var imageProcessingFunctions: {
  14804. name: string;
  14805. shader: string;
  14806. };
  14807. }
  14808. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14809. /** @hidden */
  14810. export var clipPlaneFragment: {
  14811. name: string;
  14812. shader: string;
  14813. };
  14814. }
  14815. declare module "babylonjs/Shaders/particles.fragment" {
  14816. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14817. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14818. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14819. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14820. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14821. /** @hidden */
  14822. export var particlesPixelShader: {
  14823. name: string;
  14824. shader: string;
  14825. };
  14826. }
  14827. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14828. /** @hidden */
  14829. export var clipPlaneVertexDeclaration: {
  14830. name: string;
  14831. shader: string;
  14832. };
  14833. }
  14834. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14835. /** @hidden */
  14836. export var clipPlaneVertex: {
  14837. name: string;
  14838. shader: string;
  14839. };
  14840. }
  14841. declare module "babylonjs/Shaders/particles.vertex" {
  14842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14843. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14844. /** @hidden */
  14845. export var particlesVertexShader: {
  14846. name: string;
  14847. shader: string;
  14848. };
  14849. }
  14850. declare module "babylonjs/Particles/particleSystem" {
  14851. import { Nullable } from "babylonjs/types";
  14852. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14853. import { Observable } from "babylonjs/Misc/observable";
  14854. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14855. import { Effect } from "babylonjs/Materials/effect";
  14856. import { Scene, IDisposable } from "babylonjs/scene";
  14857. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14858. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14859. import { Particle } from "babylonjs/Particles/particle";
  14860. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14861. import "babylonjs/Shaders/particles.fragment";
  14862. import "babylonjs/Shaders/particles.vertex";
  14863. /**
  14864. * This represents a particle system in Babylon.
  14865. * 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.
  14866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14867. * @example https://doc.babylonjs.com/babylon101/particles
  14868. */
  14869. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14870. /**
  14871. * Billboard mode will only apply to Y axis
  14872. */
  14873. static readonly BILLBOARDMODE_Y: number;
  14874. /**
  14875. * Billboard mode will apply to all axes
  14876. */
  14877. static readonly BILLBOARDMODE_ALL: number;
  14878. /**
  14879. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14880. */
  14881. static readonly BILLBOARDMODE_STRETCHED: number;
  14882. /**
  14883. * This function can be defined to provide custom update for active particles.
  14884. * This function will be called instead of regular update (age, position, color, etc.).
  14885. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14886. */
  14887. updateFunction: (particles: Particle[]) => void;
  14888. private _emitterWorldMatrix;
  14889. /**
  14890. * This function can be defined to specify initial direction for every new particle.
  14891. * It by default use the emitterType defined function
  14892. */
  14893. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14894. /**
  14895. * This function can be defined to specify initial position for every new particle.
  14896. * It by default use the emitterType defined function
  14897. */
  14898. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14899. /**
  14900. * @hidden
  14901. */
  14902. _inheritedVelocityOffset: Vector3;
  14903. /**
  14904. * An event triggered when the system is disposed
  14905. */
  14906. onDisposeObservable: Observable<ParticleSystem>;
  14907. private _onDisposeObserver;
  14908. /**
  14909. * Sets a callback that will be triggered when the system is disposed
  14910. */
  14911. onDispose: () => void;
  14912. private _particles;
  14913. private _epsilon;
  14914. private _capacity;
  14915. private _stockParticles;
  14916. private _newPartsExcess;
  14917. private _vertexData;
  14918. private _vertexBuffer;
  14919. private _vertexBuffers;
  14920. private _spriteBuffer;
  14921. private _indexBuffer;
  14922. private _effect;
  14923. private _customEffect;
  14924. private _cachedDefines;
  14925. private _scaledColorStep;
  14926. private _colorDiff;
  14927. private _scaledDirection;
  14928. private _scaledGravity;
  14929. private _currentRenderId;
  14930. private _alive;
  14931. private _useInstancing;
  14932. private _started;
  14933. private _stopped;
  14934. private _actualFrame;
  14935. private _scaledUpdateSpeed;
  14936. private _vertexBufferSize;
  14937. /** @hidden */
  14938. _currentEmitRateGradient: Nullable<FactorGradient>;
  14939. /** @hidden */
  14940. _currentEmitRate1: number;
  14941. /** @hidden */
  14942. _currentEmitRate2: number;
  14943. /** @hidden */
  14944. _currentStartSizeGradient: Nullable<FactorGradient>;
  14945. /** @hidden */
  14946. _currentStartSize1: number;
  14947. /** @hidden */
  14948. _currentStartSize2: number;
  14949. private readonly _rawTextureWidth;
  14950. private _rampGradientsTexture;
  14951. private _useRampGradients;
  14952. /** Gets or sets a boolean indicating that ramp gradients must be used
  14953. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14954. */
  14955. useRampGradients: boolean;
  14956. /**
  14957. * 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.
  14958. * 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: [])
  14959. */
  14960. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14961. private _subEmitters;
  14962. /**
  14963. * @hidden
  14964. * If the particle systems emitter should be disposed when the particle system is disposed
  14965. */
  14966. _disposeEmitterOnDispose: boolean;
  14967. /**
  14968. * The current active Sub-systems, this property is used by the root particle system only.
  14969. */
  14970. activeSubSystems: Array<ParticleSystem>;
  14971. private _rootParticleSystem;
  14972. /**
  14973. * Gets the current list of active particles
  14974. */
  14975. readonly particles: Particle[];
  14976. /**
  14977. * Returns the string "ParticleSystem"
  14978. * @returns a string containing the class name
  14979. */
  14980. getClassName(): string;
  14981. /**
  14982. * Instantiates a particle system.
  14983. * 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.
  14984. * @param name The name of the particle system
  14985. * @param capacity The max number of particles alive at the same time
  14986. * @param scene The scene the particle system belongs to
  14987. * @param customEffect a custom effect used to change the way particles are rendered by default
  14988. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14989. * @param epsilon Offset used to render the particles
  14990. */
  14991. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14992. private _addFactorGradient;
  14993. private _removeFactorGradient;
  14994. /**
  14995. * Adds a new life time gradient
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param factor defines the life time factor to affect to the specified gradient
  14998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14999. * @returns the current particle system
  15000. */
  15001. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15002. /**
  15003. * Remove a specific life time gradient
  15004. * @param gradient defines the gradient to remove
  15005. * @returns the current particle system
  15006. */
  15007. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15008. /**
  15009. * Adds a new size gradient
  15010. * @param gradient defines the gradient to use (between 0 and 1)
  15011. * @param factor defines the size factor to affect to the specified gradient
  15012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15013. * @returns the current particle system
  15014. */
  15015. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15016. /**
  15017. * Remove a specific size gradient
  15018. * @param gradient defines the gradient to remove
  15019. * @returns the current particle system
  15020. */
  15021. removeSizeGradient(gradient: number): IParticleSystem;
  15022. /**
  15023. * Adds a new color remap gradient
  15024. * @param gradient defines the gradient to use (between 0 and 1)
  15025. * @param min defines the color remap minimal range
  15026. * @param max defines the color remap maximal range
  15027. * @returns the current particle system
  15028. */
  15029. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15030. /**
  15031. * Remove a specific color remap gradient
  15032. * @param gradient defines the gradient to remove
  15033. * @returns the current particle system
  15034. */
  15035. removeColorRemapGradient(gradient: number): IParticleSystem;
  15036. /**
  15037. * Adds a new alpha remap gradient
  15038. * @param gradient defines the gradient to use (between 0 and 1)
  15039. * @param min defines the alpha remap minimal range
  15040. * @param max defines the alpha remap maximal range
  15041. * @returns the current particle system
  15042. */
  15043. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15044. /**
  15045. * Remove a specific alpha remap gradient
  15046. * @param gradient defines the gradient to remove
  15047. * @returns the current particle system
  15048. */
  15049. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15050. /**
  15051. * Adds a new angular speed gradient
  15052. * @param gradient defines the gradient to use (between 0 and 1)
  15053. * @param factor defines the angular speed to affect to the specified gradient
  15054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15055. * @returns the current particle system
  15056. */
  15057. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15058. /**
  15059. * Remove a specific angular speed gradient
  15060. * @param gradient defines the gradient to remove
  15061. * @returns the current particle system
  15062. */
  15063. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15064. /**
  15065. * Adds a new velocity gradient
  15066. * @param gradient defines the gradient to use (between 0 and 1)
  15067. * @param factor defines the velocity to affect to the specified gradient
  15068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15069. * @returns the current particle system
  15070. */
  15071. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15072. /**
  15073. * Remove a specific velocity gradient
  15074. * @param gradient defines the gradient to remove
  15075. * @returns the current particle system
  15076. */
  15077. removeVelocityGradient(gradient: number): IParticleSystem;
  15078. /**
  15079. * Adds a new limit velocity gradient
  15080. * @param gradient defines the gradient to use (between 0 and 1)
  15081. * @param factor defines the limit velocity value to affect to the specified gradient
  15082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15083. * @returns the current particle system
  15084. */
  15085. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15086. /**
  15087. * Remove a specific limit velocity gradient
  15088. * @param gradient defines the gradient to remove
  15089. * @returns the current particle system
  15090. */
  15091. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15092. /**
  15093. * Adds a new drag gradient
  15094. * @param gradient defines the gradient to use (between 0 and 1)
  15095. * @param factor defines the drag value to affect to the specified gradient
  15096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15097. * @returns the current particle system
  15098. */
  15099. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15100. /**
  15101. * Remove a specific drag gradient
  15102. * @param gradient defines the gradient to remove
  15103. * @returns the current particle system
  15104. */
  15105. removeDragGradient(gradient: number): IParticleSystem;
  15106. /**
  15107. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15108. * @param gradient defines the gradient to use (between 0 and 1)
  15109. * @param factor defines the emit rate value to affect to the specified gradient
  15110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15111. * @returns the current particle system
  15112. */
  15113. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15114. /**
  15115. * Remove a specific emit rate gradient
  15116. * @param gradient defines the gradient to remove
  15117. * @returns the current particle system
  15118. */
  15119. removeEmitRateGradient(gradient: number): IParticleSystem;
  15120. /**
  15121. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15122. * @param gradient defines the gradient to use (between 0 and 1)
  15123. * @param factor defines the start size value to affect to the specified gradient
  15124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15125. * @returns the current particle system
  15126. */
  15127. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15128. /**
  15129. * Remove a specific start size gradient
  15130. * @param gradient defines the gradient to remove
  15131. * @returns the current particle system
  15132. */
  15133. removeStartSizeGradient(gradient: number): IParticleSystem;
  15134. private _createRampGradientTexture;
  15135. /**
  15136. * Gets the current list of ramp gradients.
  15137. * You must use addRampGradient and removeRampGradient to udpate this list
  15138. * @returns the list of ramp gradients
  15139. */
  15140. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15141. /**
  15142. * Adds a new ramp gradient used to remap particle colors
  15143. * @param gradient defines the gradient to use (between 0 and 1)
  15144. * @param color defines the color to affect to the specified gradient
  15145. * @returns the current particle system
  15146. */
  15147. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15148. /**
  15149. * Remove a specific ramp gradient
  15150. * @param gradient defines the gradient to remove
  15151. * @returns the current particle system
  15152. */
  15153. removeRampGradient(gradient: number): ParticleSystem;
  15154. /**
  15155. * Adds a new color gradient
  15156. * @param gradient defines the gradient to use (between 0 and 1)
  15157. * @param color1 defines the color to affect to the specified gradient
  15158. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15159. * @returns this particle system
  15160. */
  15161. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15162. /**
  15163. * Remove a specific color gradient
  15164. * @param gradient defines the gradient to remove
  15165. * @returns this particle system
  15166. */
  15167. removeColorGradient(gradient: number): IParticleSystem;
  15168. private _fetchR;
  15169. protected _reset(): void;
  15170. private _resetEffect;
  15171. private _createVertexBuffers;
  15172. private _createIndexBuffer;
  15173. /**
  15174. * Gets the maximum number of particles active at the same time.
  15175. * @returns The max number of active particles.
  15176. */
  15177. getCapacity(): number;
  15178. /**
  15179. * Gets whether there are still active particles in the system.
  15180. * @returns True if it is alive, otherwise false.
  15181. */
  15182. isAlive(): boolean;
  15183. /**
  15184. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15185. * @returns True if it has been started, otherwise false.
  15186. */
  15187. isStarted(): boolean;
  15188. private _prepareSubEmitterInternalArray;
  15189. /**
  15190. * Starts the particle system and begins to emit
  15191. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15192. */
  15193. start(delay?: number): void;
  15194. /**
  15195. * Stops the particle system.
  15196. * @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.
  15197. */
  15198. stop(stopSubEmitters?: boolean): void;
  15199. /**
  15200. * Remove all active particles
  15201. */
  15202. reset(): void;
  15203. /**
  15204. * @hidden (for internal use only)
  15205. */
  15206. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15207. /**
  15208. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15209. * Its lifetime will start back at 0.
  15210. */
  15211. recycleParticle: (particle: Particle) => void;
  15212. private _stopSubEmitters;
  15213. private _createParticle;
  15214. private _removeFromRoot;
  15215. private _emitFromParticle;
  15216. private _update;
  15217. /** @hidden */
  15218. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15219. /** @hidden */
  15220. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15221. /** @hidden */
  15222. private _getEffect;
  15223. /**
  15224. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15225. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15226. */
  15227. animate(preWarmOnly?: boolean): void;
  15228. private _appendParticleVertices;
  15229. /**
  15230. * Rebuilds the particle system.
  15231. */
  15232. rebuild(): void;
  15233. /**
  15234. * Is this system ready to be used/rendered
  15235. * @return true if the system is ready
  15236. */
  15237. isReady(): boolean;
  15238. private _render;
  15239. /**
  15240. * Renders the particle system in its current state.
  15241. * @returns the current number of particles
  15242. */
  15243. render(): number;
  15244. /**
  15245. * Disposes the particle system and free the associated resources
  15246. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15247. */
  15248. dispose(disposeTexture?: boolean): void;
  15249. /**
  15250. * Clones the particle system.
  15251. * @param name The name of the cloned object
  15252. * @param newEmitter The new emitter to use
  15253. * @returns the cloned particle system
  15254. */
  15255. clone(name: string, newEmitter: any): ParticleSystem;
  15256. /**
  15257. * Serializes the particle system to a JSON object.
  15258. * @returns the JSON object
  15259. */
  15260. serialize(): any;
  15261. /** @hidden */
  15262. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15263. /** @hidden */
  15264. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15265. /**
  15266. * Parses a JSON object to create a particle system.
  15267. * @param parsedParticleSystem The JSON object to parse
  15268. * @param scene The scene to create the particle system in
  15269. * @param rootUrl The root url to use to load external dependencies like texture
  15270. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15271. * @returns the Parsed particle system
  15272. */
  15273. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15274. }
  15275. }
  15276. declare module "babylonjs/Particles/particle" {
  15277. import { Nullable } from "babylonjs/types";
  15278. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15279. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15280. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15281. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15282. /**
  15283. * A particle represents one of the element emitted by a particle system.
  15284. * This is mainly define by its coordinates, direction, velocity and age.
  15285. */
  15286. export class Particle {
  15287. /**
  15288. * The particle system the particle belongs to.
  15289. */
  15290. particleSystem: ParticleSystem;
  15291. private static _Count;
  15292. /**
  15293. * Unique ID of the particle
  15294. */
  15295. id: number;
  15296. /**
  15297. * The world position of the particle in the scene.
  15298. */
  15299. position: Vector3;
  15300. /**
  15301. * The world direction of the particle in the scene.
  15302. */
  15303. direction: Vector3;
  15304. /**
  15305. * The color of the particle.
  15306. */
  15307. color: Color4;
  15308. /**
  15309. * The color change of the particle per step.
  15310. */
  15311. colorStep: Color4;
  15312. /**
  15313. * Defines how long will the life of the particle be.
  15314. */
  15315. lifeTime: number;
  15316. /**
  15317. * The current age of the particle.
  15318. */
  15319. age: number;
  15320. /**
  15321. * The current size of the particle.
  15322. */
  15323. size: number;
  15324. /**
  15325. * The current scale of the particle.
  15326. */
  15327. scale: Vector2;
  15328. /**
  15329. * The current angle of the particle.
  15330. */
  15331. angle: number;
  15332. /**
  15333. * Defines how fast is the angle changing.
  15334. */
  15335. angularSpeed: number;
  15336. /**
  15337. * Defines the cell index used by the particle to be rendered from a sprite.
  15338. */
  15339. cellIndex: number;
  15340. /**
  15341. * The information required to support color remapping
  15342. */
  15343. remapData: Vector4;
  15344. /** @hidden */
  15345. _randomCellOffset?: number;
  15346. /** @hidden */
  15347. _initialDirection: Nullable<Vector3>;
  15348. /** @hidden */
  15349. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15350. /** @hidden */
  15351. _initialStartSpriteCellID: number;
  15352. /** @hidden */
  15353. _initialEndSpriteCellID: number;
  15354. /** @hidden */
  15355. _currentColorGradient: Nullable<ColorGradient>;
  15356. /** @hidden */
  15357. _currentColor1: Color4;
  15358. /** @hidden */
  15359. _currentColor2: Color4;
  15360. /** @hidden */
  15361. _currentSizeGradient: Nullable<FactorGradient>;
  15362. /** @hidden */
  15363. _currentSize1: number;
  15364. /** @hidden */
  15365. _currentSize2: number;
  15366. /** @hidden */
  15367. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15368. /** @hidden */
  15369. _currentAngularSpeed1: number;
  15370. /** @hidden */
  15371. _currentAngularSpeed2: number;
  15372. /** @hidden */
  15373. _currentVelocityGradient: Nullable<FactorGradient>;
  15374. /** @hidden */
  15375. _currentVelocity1: number;
  15376. /** @hidden */
  15377. _currentVelocity2: number;
  15378. /** @hidden */
  15379. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15380. /** @hidden */
  15381. _currentLimitVelocity1: number;
  15382. /** @hidden */
  15383. _currentLimitVelocity2: number;
  15384. /** @hidden */
  15385. _currentDragGradient: Nullable<FactorGradient>;
  15386. /** @hidden */
  15387. _currentDrag1: number;
  15388. /** @hidden */
  15389. _currentDrag2: number;
  15390. /** @hidden */
  15391. _randomNoiseCoordinates1: Vector3;
  15392. /** @hidden */
  15393. _randomNoiseCoordinates2: Vector3;
  15394. /**
  15395. * Creates a new instance Particle
  15396. * @param particleSystem the particle system the particle belongs to
  15397. */
  15398. constructor(
  15399. /**
  15400. * The particle system the particle belongs to.
  15401. */
  15402. particleSystem: ParticleSystem);
  15403. private updateCellInfoFromSystem;
  15404. /**
  15405. * Defines how the sprite cell index is updated for the particle
  15406. */
  15407. updateCellIndex(): void;
  15408. /** @hidden */
  15409. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15410. /** @hidden */
  15411. _inheritParticleInfoToSubEmitters(): void;
  15412. /** @hidden */
  15413. _reset(): void;
  15414. /**
  15415. * Copy the properties of particle to another one.
  15416. * @param other the particle to copy the information to.
  15417. */
  15418. copyTo(other: Particle): void;
  15419. }
  15420. }
  15421. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15422. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15423. import { Effect } from "babylonjs/Materials/effect";
  15424. import { Particle } from "babylonjs/Particles/particle";
  15425. /**
  15426. * Particle emitter represents a volume emitting particles.
  15427. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15428. */
  15429. export interface IParticleEmitterType {
  15430. /**
  15431. * Called by the particle System when the direction is computed for the created particle.
  15432. * @param worldMatrix is the world matrix of the particle system
  15433. * @param directionToUpdate is the direction vector to update with the result
  15434. * @param particle is the particle we are computed the direction for
  15435. */
  15436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15437. /**
  15438. * Called by the particle System when the position is computed for the created particle.
  15439. * @param worldMatrix is the world matrix of the particle system
  15440. * @param positionToUpdate is the position vector to update with the result
  15441. * @param particle is the particle we are computed the position for
  15442. */
  15443. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15444. /**
  15445. * Clones the current emitter and returns a copy of it
  15446. * @returns the new emitter
  15447. */
  15448. clone(): IParticleEmitterType;
  15449. /**
  15450. * Called by the GPUParticleSystem to setup the update shader
  15451. * @param effect defines the update shader
  15452. */
  15453. applyToShader(effect: Effect): void;
  15454. /**
  15455. * Returns a string to use to update the GPU particles update shader
  15456. * @returns the effect defines string
  15457. */
  15458. getEffectDefines(): string;
  15459. /**
  15460. * Returns a string representing the class name
  15461. * @returns a string containing the class name
  15462. */
  15463. getClassName(): string;
  15464. /**
  15465. * Serializes the particle system to a JSON object.
  15466. * @returns the JSON object
  15467. */
  15468. serialize(): any;
  15469. /**
  15470. * Parse properties from a JSON object
  15471. * @param serializationObject defines the JSON object
  15472. */
  15473. parse(serializationObject: any): void;
  15474. }
  15475. }
  15476. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15477. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15478. import { Effect } from "babylonjs/Materials/effect";
  15479. import { Particle } from "babylonjs/Particles/particle";
  15480. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15481. /**
  15482. * Particle emitter emitting particles from the inside of a box.
  15483. * It emits the particles randomly between 2 given directions.
  15484. */
  15485. export class BoxParticleEmitter implements IParticleEmitterType {
  15486. /**
  15487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15488. */
  15489. direction1: Vector3;
  15490. /**
  15491. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15492. */
  15493. direction2: Vector3;
  15494. /**
  15495. * 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.
  15496. */
  15497. minEmitBox: Vector3;
  15498. /**
  15499. * 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.
  15500. */
  15501. maxEmitBox: Vector3;
  15502. /**
  15503. * Creates a new instance BoxParticleEmitter
  15504. */
  15505. constructor();
  15506. /**
  15507. * Called by the particle System when the direction is computed for the created particle.
  15508. * @param worldMatrix is the world matrix of the particle system
  15509. * @param directionToUpdate is the direction vector to update with the result
  15510. * @param particle is the particle we are computed the direction for
  15511. */
  15512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15513. /**
  15514. * Called by the particle System when the position is computed for the created particle.
  15515. * @param worldMatrix is the world matrix of the particle system
  15516. * @param positionToUpdate is the position vector to update with the result
  15517. * @param particle is the particle we are computed the position for
  15518. */
  15519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15520. /**
  15521. * Clones the current emitter and returns a copy of it
  15522. * @returns the new emitter
  15523. */
  15524. clone(): BoxParticleEmitter;
  15525. /**
  15526. * Called by the GPUParticleSystem to setup the update shader
  15527. * @param effect defines the update shader
  15528. */
  15529. applyToShader(effect: Effect): void;
  15530. /**
  15531. * Returns a string to use to update the GPU particles update shader
  15532. * @returns a string containng the defines string
  15533. */
  15534. getEffectDefines(): string;
  15535. /**
  15536. * Returns the string "BoxParticleEmitter"
  15537. * @returns a string containing the class name
  15538. */
  15539. getClassName(): string;
  15540. /**
  15541. * Serializes the particle system to a JSON object.
  15542. * @returns the JSON object
  15543. */
  15544. serialize(): any;
  15545. /**
  15546. * Parse properties from a JSON object
  15547. * @param serializationObject defines the JSON object
  15548. */
  15549. parse(serializationObject: any): void;
  15550. }
  15551. }
  15552. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15553. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15554. import { Effect } from "babylonjs/Materials/effect";
  15555. import { Particle } from "babylonjs/Particles/particle";
  15556. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15557. /**
  15558. * Particle emitter emitting particles from the inside of a cone.
  15559. * It emits the particles alongside the cone volume from the base to the particle.
  15560. * The emission direction might be randomized.
  15561. */
  15562. export class ConeParticleEmitter implements IParticleEmitterType {
  15563. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15564. directionRandomizer: number;
  15565. private _radius;
  15566. private _angle;
  15567. private _height;
  15568. /**
  15569. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15570. */
  15571. radiusRange: number;
  15572. /**
  15573. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15574. */
  15575. heightRange: number;
  15576. /**
  15577. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15578. */
  15579. emitFromSpawnPointOnly: boolean;
  15580. /**
  15581. * Gets or sets the radius of the emission cone
  15582. */
  15583. radius: number;
  15584. /**
  15585. * Gets or sets the angle of the emission cone
  15586. */
  15587. angle: number;
  15588. private _buildHeight;
  15589. /**
  15590. * Creates a new instance ConeParticleEmitter
  15591. * @param radius the radius of the emission cone (1 by default)
  15592. * @param angle the cone base angle (PI by default)
  15593. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15594. */
  15595. constructor(radius?: number, angle?: number,
  15596. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15597. directionRandomizer?: number);
  15598. /**
  15599. * Called by the particle System when the direction is computed for the created particle.
  15600. * @param worldMatrix is the world matrix of the particle system
  15601. * @param directionToUpdate is the direction vector to update with the result
  15602. * @param particle is the particle we are computed the direction for
  15603. */
  15604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15605. /**
  15606. * Called by the particle System when the position is computed for the created particle.
  15607. * @param worldMatrix is the world matrix of the particle system
  15608. * @param positionToUpdate is the position vector to update with the result
  15609. * @param particle is the particle we are computed the position for
  15610. */
  15611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15612. /**
  15613. * Clones the current emitter and returns a copy of it
  15614. * @returns the new emitter
  15615. */
  15616. clone(): ConeParticleEmitter;
  15617. /**
  15618. * Called by the GPUParticleSystem to setup the update shader
  15619. * @param effect defines the update shader
  15620. */
  15621. applyToShader(effect: Effect): void;
  15622. /**
  15623. * Returns a string to use to update the GPU particles update shader
  15624. * @returns a string containng the defines string
  15625. */
  15626. getEffectDefines(): string;
  15627. /**
  15628. * Returns the string "ConeParticleEmitter"
  15629. * @returns a string containing the class name
  15630. */
  15631. getClassName(): string;
  15632. /**
  15633. * Serializes the particle system to a JSON object.
  15634. * @returns the JSON object
  15635. */
  15636. serialize(): any;
  15637. /**
  15638. * Parse properties from a JSON object
  15639. * @param serializationObject defines the JSON object
  15640. */
  15641. parse(serializationObject: any): void;
  15642. }
  15643. }
  15644. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15645. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15646. import { Effect } from "babylonjs/Materials/effect";
  15647. import { Particle } from "babylonjs/Particles/particle";
  15648. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15649. /**
  15650. * Particle emitter emitting particles from the inside of a cylinder.
  15651. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15652. */
  15653. export class CylinderParticleEmitter implements IParticleEmitterType {
  15654. /**
  15655. * The radius of the emission cylinder.
  15656. */
  15657. radius: number;
  15658. /**
  15659. * The height of the emission cylinder.
  15660. */
  15661. height: number;
  15662. /**
  15663. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15664. */
  15665. radiusRange: number;
  15666. /**
  15667. * How much to randomize the particle direction [0-1].
  15668. */
  15669. directionRandomizer: number;
  15670. /**
  15671. * Creates a new instance CylinderParticleEmitter
  15672. * @param radius the radius of the emission cylinder (1 by default)
  15673. * @param height the height of the emission cylinder (1 by default)
  15674. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15676. */
  15677. constructor(
  15678. /**
  15679. * The radius of the emission cylinder.
  15680. */
  15681. radius?: number,
  15682. /**
  15683. * The height of the emission cylinder.
  15684. */
  15685. height?: number,
  15686. /**
  15687. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15688. */
  15689. radiusRange?: number,
  15690. /**
  15691. * How much to randomize the particle direction [0-1].
  15692. */
  15693. directionRandomizer?: number);
  15694. /**
  15695. * Called by the particle System when the direction is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param directionToUpdate is the direction vector to update with the result
  15698. * @param particle is the particle we are computed the direction for
  15699. */
  15700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Called by the particle System when the position is computed for the created particle.
  15703. * @param worldMatrix is the world matrix of the particle system
  15704. * @param positionToUpdate is the position vector to update with the result
  15705. * @param particle is the particle we are computed the position for
  15706. */
  15707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15708. /**
  15709. * Clones the current emitter and returns a copy of it
  15710. * @returns the new emitter
  15711. */
  15712. clone(): CylinderParticleEmitter;
  15713. /**
  15714. * Called by the GPUParticleSystem to setup the update shader
  15715. * @param effect defines the update shader
  15716. */
  15717. applyToShader(effect: Effect): void;
  15718. /**
  15719. * Returns a string to use to update the GPU particles update shader
  15720. * @returns a string containng the defines string
  15721. */
  15722. getEffectDefines(): string;
  15723. /**
  15724. * Returns the string "CylinderParticleEmitter"
  15725. * @returns a string containing the class name
  15726. */
  15727. getClassName(): string;
  15728. /**
  15729. * Serializes the particle system to a JSON object.
  15730. * @returns the JSON object
  15731. */
  15732. serialize(): any;
  15733. /**
  15734. * Parse properties from a JSON object
  15735. * @param serializationObject defines the JSON object
  15736. */
  15737. parse(serializationObject: any): void;
  15738. }
  15739. /**
  15740. * Particle emitter emitting particles from the inside of a cylinder.
  15741. * It emits the particles randomly between two vectors.
  15742. */
  15743. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15744. /**
  15745. * The min limit of the emission direction.
  15746. */
  15747. direction1: Vector3;
  15748. /**
  15749. * The max limit of the emission direction.
  15750. */
  15751. direction2: Vector3;
  15752. /**
  15753. * Creates a new instance CylinderDirectedParticleEmitter
  15754. * @param radius the radius of the emission cylinder (1 by default)
  15755. * @param height the height of the emission cylinder (1 by default)
  15756. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15757. * @param direction1 the min limit of the emission direction (up vector by default)
  15758. * @param direction2 the max limit of the emission direction (up vector by default)
  15759. */
  15760. constructor(radius?: number, height?: number, radiusRange?: number,
  15761. /**
  15762. * The min limit of the emission direction.
  15763. */
  15764. direction1?: Vector3,
  15765. /**
  15766. * The max limit of the emission direction.
  15767. */
  15768. direction2?: Vector3);
  15769. /**
  15770. * Called by the particle System when the direction is computed for the created particle.
  15771. * @param worldMatrix is the world matrix of the particle system
  15772. * @param directionToUpdate is the direction vector to update with the result
  15773. * @param particle is the particle we are computed the direction for
  15774. */
  15775. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15776. /**
  15777. * Clones the current emitter and returns a copy of it
  15778. * @returns the new emitter
  15779. */
  15780. clone(): CylinderDirectedParticleEmitter;
  15781. /**
  15782. * Called by the GPUParticleSystem to setup the update shader
  15783. * @param effect defines the update shader
  15784. */
  15785. applyToShader(effect: Effect): void;
  15786. /**
  15787. * Returns a string to use to update the GPU particles update shader
  15788. * @returns a string containng the defines string
  15789. */
  15790. getEffectDefines(): string;
  15791. /**
  15792. * Returns the string "CylinderDirectedParticleEmitter"
  15793. * @returns a string containing the class name
  15794. */
  15795. getClassName(): string;
  15796. /**
  15797. * Serializes the particle system to a JSON object.
  15798. * @returns the JSON object
  15799. */
  15800. serialize(): any;
  15801. /**
  15802. * Parse properties from a JSON object
  15803. * @param serializationObject defines the JSON object
  15804. */
  15805. parse(serializationObject: any): void;
  15806. }
  15807. }
  15808. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15809. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15810. import { Effect } from "babylonjs/Materials/effect";
  15811. import { Particle } from "babylonjs/Particles/particle";
  15812. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15813. /**
  15814. * Particle emitter emitting particles from the inside of a hemisphere.
  15815. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15816. */
  15817. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15818. /**
  15819. * The radius of the emission hemisphere.
  15820. */
  15821. radius: number;
  15822. /**
  15823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15824. */
  15825. radiusRange: number;
  15826. /**
  15827. * How much to randomize the particle direction [0-1].
  15828. */
  15829. directionRandomizer: number;
  15830. /**
  15831. * Creates a new instance HemisphericParticleEmitter
  15832. * @param radius the radius of the emission hemisphere (1 by default)
  15833. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15834. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15835. */
  15836. constructor(
  15837. /**
  15838. * The radius of the emission hemisphere.
  15839. */
  15840. radius?: number,
  15841. /**
  15842. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15843. */
  15844. radiusRange?: number,
  15845. /**
  15846. * How much to randomize the particle direction [0-1].
  15847. */
  15848. directionRandomizer?: number);
  15849. /**
  15850. * Called by the particle System when the direction is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param directionToUpdate is the direction vector to update with the result
  15853. * @param particle is the particle we are computed the direction for
  15854. */
  15855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Called by the particle System when the position is computed for the created particle.
  15858. * @param worldMatrix is the world matrix of the particle system
  15859. * @param positionToUpdate is the position vector to update with the result
  15860. * @param particle is the particle we are computed the position for
  15861. */
  15862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15863. /**
  15864. * Clones the current emitter and returns a copy of it
  15865. * @returns the new emitter
  15866. */
  15867. clone(): HemisphericParticleEmitter;
  15868. /**
  15869. * Called by the GPUParticleSystem to setup the update shader
  15870. * @param effect defines the update shader
  15871. */
  15872. applyToShader(effect: Effect): void;
  15873. /**
  15874. * Returns a string to use to update the GPU particles update shader
  15875. * @returns a string containng the defines string
  15876. */
  15877. getEffectDefines(): string;
  15878. /**
  15879. * Returns the string "HemisphericParticleEmitter"
  15880. * @returns a string containing the class name
  15881. */
  15882. getClassName(): string;
  15883. /**
  15884. * Serializes the particle system to a JSON object.
  15885. * @returns the JSON object
  15886. */
  15887. serialize(): any;
  15888. /**
  15889. * Parse properties from a JSON object
  15890. * @param serializationObject defines the JSON object
  15891. */
  15892. parse(serializationObject: any): void;
  15893. }
  15894. }
  15895. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15896. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15897. import { Effect } from "babylonjs/Materials/effect";
  15898. import { Particle } from "babylonjs/Particles/particle";
  15899. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15900. /**
  15901. * Particle emitter emitting particles from a point.
  15902. * It emits the particles randomly between 2 given directions.
  15903. */
  15904. export class PointParticleEmitter implements IParticleEmitterType {
  15905. /**
  15906. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15907. */
  15908. direction1: Vector3;
  15909. /**
  15910. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15911. */
  15912. direction2: Vector3;
  15913. /**
  15914. * Creates a new instance PointParticleEmitter
  15915. */
  15916. constructor();
  15917. /**
  15918. * Called by the particle System when the direction is computed for the created particle.
  15919. * @param worldMatrix is the world matrix of the particle system
  15920. * @param directionToUpdate is the direction vector to update with the result
  15921. * @param particle is the particle we are computed the direction for
  15922. */
  15923. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15924. /**
  15925. * Called by the particle System when the position is computed for the created particle.
  15926. * @param worldMatrix is the world matrix of the particle system
  15927. * @param positionToUpdate is the position vector to update with the result
  15928. * @param particle is the particle we are computed the position for
  15929. */
  15930. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15931. /**
  15932. * Clones the current emitter and returns a copy of it
  15933. * @returns the new emitter
  15934. */
  15935. clone(): PointParticleEmitter;
  15936. /**
  15937. * Called by the GPUParticleSystem to setup the update shader
  15938. * @param effect defines the update shader
  15939. */
  15940. applyToShader(effect: Effect): void;
  15941. /**
  15942. * Returns a string to use to update the GPU particles update shader
  15943. * @returns a string containng the defines string
  15944. */
  15945. getEffectDefines(): string;
  15946. /**
  15947. * Returns the string "PointParticleEmitter"
  15948. * @returns a string containing the class name
  15949. */
  15950. getClassName(): string;
  15951. /**
  15952. * Serializes the particle system to a JSON object.
  15953. * @returns the JSON object
  15954. */
  15955. serialize(): any;
  15956. /**
  15957. * Parse properties from a JSON object
  15958. * @param serializationObject defines the JSON object
  15959. */
  15960. parse(serializationObject: any): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15964. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15965. import { Effect } from "babylonjs/Materials/effect";
  15966. import { Particle } from "babylonjs/Particles/particle";
  15967. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15968. /**
  15969. * Particle emitter emitting particles from the inside of a sphere.
  15970. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15971. */
  15972. export class SphereParticleEmitter implements IParticleEmitterType {
  15973. /**
  15974. * The radius of the emission sphere.
  15975. */
  15976. radius: number;
  15977. /**
  15978. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15979. */
  15980. radiusRange: number;
  15981. /**
  15982. * How much to randomize the particle direction [0-1].
  15983. */
  15984. directionRandomizer: number;
  15985. /**
  15986. * Creates a new instance SphereParticleEmitter
  15987. * @param radius the radius of the emission sphere (1 by default)
  15988. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15989. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15990. */
  15991. constructor(
  15992. /**
  15993. * The radius of the emission sphere.
  15994. */
  15995. radius?: number,
  15996. /**
  15997. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15998. */
  15999. radiusRange?: number,
  16000. /**
  16001. * How much to randomize the particle direction [0-1].
  16002. */
  16003. directionRandomizer?: number);
  16004. /**
  16005. * Called by the particle System when the direction is computed for the created particle.
  16006. * @param worldMatrix is the world matrix of the particle system
  16007. * @param directionToUpdate is the direction vector to update with the result
  16008. * @param particle is the particle we are computed the direction for
  16009. */
  16010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16011. /**
  16012. * Called by the particle System when the position is computed for the created particle.
  16013. * @param worldMatrix is the world matrix of the particle system
  16014. * @param positionToUpdate is the position vector to update with the result
  16015. * @param particle is the particle we are computed the position for
  16016. */
  16017. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16018. /**
  16019. * Clones the current emitter and returns a copy of it
  16020. * @returns the new emitter
  16021. */
  16022. clone(): SphereParticleEmitter;
  16023. /**
  16024. * Called by the GPUParticleSystem to setup the update shader
  16025. * @param effect defines the update shader
  16026. */
  16027. applyToShader(effect: Effect): void;
  16028. /**
  16029. * Returns a string to use to update the GPU particles update shader
  16030. * @returns a string containng the defines string
  16031. */
  16032. getEffectDefines(): string;
  16033. /**
  16034. * Returns the string "SphereParticleEmitter"
  16035. * @returns a string containing the class name
  16036. */
  16037. getClassName(): string;
  16038. /**
  16039. * Serializes the particle system to a JSON object.
  16040. * @returns the JSON object
  16041. */
  16042. serialize(): any;
  16043. /**
  16044. * Parse properties from a JSON object
  16045. * @param serializationObject defines the JSON object
  16046. */
  16047. parse(serializationObject: any): void;
  16048. }
  16049. /**
  16050. * Particle emitter emitting particles from the inside of a sphere.
  16051. * It emits the particles randomly between two vectors.
  16052. */
  16053. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16054. /**
  16055. * The min limit of the emission direction.
  16056. */
  16057. direction1: Vector3;
  16058. /**
  16059. * The max limit of the emission direction.
  16060. */
  16061. direction2: Vector3;
  16062. /**
  16063. * Creates a new instance SphereDirectedParticleEmitter
  16064. * @param radius the radius of the emission sphere (1 by default)
  16065. * @param direction1 the min limit of the emission direction (up vector by default)
  16066. * @param direction2 the max limit of the emission direction (up vector by default)
  16067. */
  16068. constructor(radius?: number,
  16069. /**
  16070. * The min limit of the emission direction.
  16071. */
  16072. direction1?: Vector3,
  16073. /**
  16074. * The max limit of the emission direction.
  16075. */
  16076. direction2?: Vector3);
  16077. /**
  16078. * Called by the particle System when the direction is computed for the created particle.
  16079. * @param worldMatrix is the world matrix of the particle system
  16080. * @param directionToUpdate is the direction vector to update with the result
  16081. * @param particle is the particle we are computed the direction for
  16082. */
  16083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16084. /**
  16085. * Clones the current emitter and returns a copy of it
  16086. * @returns the new emitter
  16087. */
  16088. clone(): SphereDirectedParticleEmitter;
  16089. /**
  16090. * Called by the GPUParticleSystem to setup the update shader
  16091. * @param effect defines the update shader
  16092. */
  16093. applyToShader(effect: Effect): void;
  16094. /**
  16095. * Returns a string to use to update the GPU particles update shader
  16096. * @returns a string containng the defines string
  16097. */
  16098. getEffectDefines(): string;
  16099. /**
  16100. * Returns the string "SphereDirectedParticleEmitter"
  16101. * @returns a string containing the class name
  16102. */
  16103. getClassName(): string;
  16104. /**
  16105. * Serializes the particle system to a JSON object.
  16106. * @returns the JSON object
  16107. */
  16108. serialize(): any;
  16109. /**
  16110. * Parse properties from a JSON object
  16111. * @param serializationObject defines the JSON object
  16112. */
  16113. parse(serializationObject: any): void;
  16114. }
  16115. }
  16116. declare module "babylonjs/Particles/EmitterTypes/index" {
  16117. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16118. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16119. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16120. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16121. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16122. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16123. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16124. }
  16125. declare module "babylonjs/Particles/IParticleSystem" {
  16126. import { Nullable } from "babylonjs/types";
  16127. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16130. import { Texture } from "babylonjs/Materials/Textures/texture";
  16131. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16132. import { Scene } from "babylonjs/scene";
  16133. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16134. import { Animation } from "babylonjs/Animations/animation";
  16135. /**
  16136. * Interface representing a particle system in Babylon.js.
  16137. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16138. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16139. */
  16140. export interface IParticleSystem {
  16141. /**
  16142. * List of animations used by the particle system.
  16143. */
  16144. animations: Animation[];
  16145. /**
  16146. * The id of the Particle system.
  16147. */
  16148. id: string;
  16149. /**
  16150. * The name of the Particle system.
  16151. */
  16152. name: string;
  16153. /**
  16154. * The emitter represents the Mesh or position we are attaching the particle system to.
  16155. */
  16156. emitter: Nullable<AbstractMesh | Vector3>;
  16157. /**
  16158. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16159. */
  16160. isBillboardBased: boolean;
  16161. /**
  16162. * The rendering group used by the Particle system to chose when to render.
  16163. */
  16164. renderingGroupId: number;
  16165. /**
  16166. * The layer mask we are rendering the particles through.
  16167. */
  16168. layerMask: number;
  16169. /**
  16170. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16171. */
  16172. updateSpeed: number;
  16173. /**
  16174. * The amount of time the particle system is running (depends of the overall update speed).
  16175. */
  16176. targetStopDuration: number;
  16177. /**
  16178. * The texture used to render each particle. (this can be a spritesheet)
  16179. */
  16180. particleTexture: Nullable<Texture>;
  16181. /**
  16182. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16183. */
  16184. blendMode: number;
  16185. /**
  16186. * Minimum life time of emitting particles.
  16187. */
  16188. minLifeTime: number;
  16189. /**
  16190. * Maximum life time of emitting particles.
  16191. */
  16192. maxLifeTime: number;
  16193. /**
  16194. * Minimum Size of emitting particles.
  16195. */
  16196. minSize: number;
  16197. /**
  16198. * Maximum Size of emitting particles.
  16199. */
  16200. maxSize: number;
  16201. /**
  16202. * Minimum scale of emitting particles on X axis.
  16203. */
  16204. minScaleX: number;
  16205. /**
  16206. * Maximum scale of emitting particles on X axis.
  16207. */
  16208. maxScaleX: number;
  16209. /**
  16210. * Minimum scale of emitting particles on Y axis.
  16211. */
  16212. minScaleY: number;
  16213. /**
  16214. * Maximum scale of emitting particles on Y axis.
  16215. */
  16216. maxScaleY: number;
  16217. /**
  16218. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16219. */
  16220. color1: Color4;
  16221. /**
  16222. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16223. */
  16224. color2: Color4;
  16225. /**
  16226. * Color the particle will have at the end of its lifetime.
  16227. */
  16228. colorDead: Color4;
  16229. /**
  16230. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16231. */
  16232. emitRate: number;
  16233. /**
  16234. * You can use gravity if you want to give an orientation to your particles.
  16235. */
  16236. gravity: Vector3;
  16237. /**
  16238. * Minimum power of emitting particles.
  16239. */
  16240. minEmitPower: number;
  16241. /**
  16242. * Maximum power of emitting particles.
  16243. */
  16244. maxEmitPower: number;
  16245. /**
  16246. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16247. */
  16248. minAngularSpeed: number;
  16249. /**
  16250. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16251. */
  16252. maxAngularSpeed: number;
  16253. /**
  16254. * Gets or sets the minimal initial rotation in radians.
  16255. */
  16256. minInitialRotation: number;
  16257. /**
  16258. * Gets or sets the maximal initial rotation in radians.
  16259. */
  16260. maxInitialRotation: number;
  16261. /**
  16262. * The particle emitter type defines the emitter used by the particle system.
  16263. * It can be for example box, sphere, or cone...
  16264. */
  16265. particleEmitterType: Nullable<IParticleEmitterType>;
  16266. /**
  16267. * Defines the delay in milliseconds before starting the system (0 by default)
  16268. */
  16269. startDelay: number;
  16270. /**
  16271. * 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
  16272. */
  16273. preWarmCycles: number;
  16274. /**
  16275. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16276. */
  16277. preWarmStepOffset: number;
  16278. /**
  16279. * 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)
  16280. */
  16281. spriteCellChangeSpeed: number;
  16282. /**
  16283. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16284. */
  16285. startSpriteCellID: number;
  16286. /**
  16287. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16288. */
  16289. endSpriteCellID: number;
  16290. /**
  16291. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16292. */
  16293. spriteCellWidth: number;
  16294. /**
  16295. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16296. */
  16297. spriteCellHeight: number;
  16298. /**
  16299. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16300. */
  16301. spriteRandomStartCell: boolean;
  16302. /**
  16303. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16304. */
  16305. isAnimationSheetEnabled: boolean;
  16306. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16307. translationPivot: Vector2;
  16308. /**
  16309. * Gets or sets a texture used to add random noise to particle positions
  16310. */
  16311. noiseTexture: Nullable<BaseTexture>;
  16312. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16313. noiseStrength: Vector3;
  16314. /**
  16315. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16316. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16317. */
  16318. billboardMode: number;
  16319. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16320. limitVelocityDamping: number;
  16321. /**
  16322. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16323. */
  16324. beginAnimationOnStart: boolean;
  16325. /**
  16326. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16327. */
  16328. beginAnimationFrom: number;
  16329. /**
  16330. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16331. */
  16332. beginAnimationTo: number;
  16333. /**
  16334. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16335. */
  16336. beginAnimationLoop: boolean;
  16337. /**
  16338. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16339. */
  16340. disposeOnStop: boolean;
  16341. /**
  16342. * Gets the maximum number of particles active at the same time.
  16343. * @returns The max number of active particles.
  16344. */
  16345. getCapacity(): number;
  16346. /**
  16347. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16348. * @returns True if it has been started, otherwise false.
  16349. */
  16350. isStarted(): boolean;
  16351. /**
  16352. * Animates the particle system for this frame.
  16353. */
  16354. animate(): void;
  16355. /**
  16356. * Renders the particle system in its current state.
  16357. * @returns the current number of particles
  16358. */
  16359. render(): number;
  16360. /**
  16361. * Dispose the particle system and frees its associated resources.
  16362. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16363. */
  16364. dispose(disposeTexture?: boolean): void;
  16365. /**
  16366. * Clones the particle system.
  16367. * @param name The name of the cloned object
  16368. * @param newEmitter The new emitter to use
  16369. * @returns the cloned particle system
  16370. */
  16371. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16372. /**
  16373. * Serializes the particle system to a JSON object.
  16374. * @returns the JSON object
  16375. */
  16376. serialize(): any;
  16377. /**
  16378. * Rebuild the particle system
  16379. */
  16380. rebuild(): void;
  16381. /**
  16382. * Starts the particle system and begins to emit
  16383. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16384. */
  16385. start(delay?: number): void;
  16386. /**
  16387. * Stops the particle system.
  16388. */
  16389. stop(): void;
  16390. /**
  16391. * Remove all active particles
  16392. */
  16393. reset(): void;
  16394. /**
  16395. * Is this system ready to be used/rendered
  16396. * @return true if the system is ready
  16397. */
  16398. isReady(): boolean;
  16399. /**
  16400. * Adds a new color gradient
  16401. * @param gradient defines the gradient to use (between 0 and 1)
  16402. * @param color1 defines the color to affect to the specified gradient
  16403. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16404. * @returns the current particle system
  16405. */
  16406. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16407. /**
  16408. * Remove a specific color gradient
  16409. * @param gradient defines the gradient to remove
  16410. * @returns the current particle system
  16411. */
  16412. removeColorGradient(gradient: number): IParticleSystem;
  16413. /**
  16414. * Adds a new size gradient
  16415. * @param gradient defines the gradient to use (between 0 and 1)
  16416. * @param factor defines the size factor to affect to the specified gradient
  16417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16418. * @returns the current particle system
  16419. */
  16420. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16421. /**
  16422. * Remove a specific size gradient
  16423. * @param gradient defines the gradient to remove
  16424. * @returns the current particle system
  16425. */
  16426. removeSizeGradient(gradient: number): IParticleSystem;
  16427. /**
  16428. * Gets the current list of color gradients.
  16429. * You must use addColorGradient and removeColorGradient to udpate this list
  16430. * @returns the list of color gradients
  16431. */
  16432. getColorGradients(): Nullable<Array<ColorGradient>>;
  16433. /**
  16434. * Gets the current list of size gradients.
  16435. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16436. * @returns the list of size gradients
  16437. */
  16438. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16439. /**
  16440. * Gets the current list of angular speed gradients.
  16441. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16442. * @returns the list of angular speed gradients
  16443. */
  16444. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16445. /**
  16446. * Adds a new angular speed gradient
  16447. * @param gradient defines the gradient to use (between 0 and 1)
  16448. * @param factor defines the angular speed to affect to the specified gradient
  16449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16450. * @returns the current particle system
  16451. */
  16452. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16453. /**
  16454. * Remove a specific angular speed gradient
  16455. * @param gradient defines the gradient to remove
  16456. * @returns the current particle system
  16457. */
  16458. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16459. /**
  16460. * Gets the current list of velocity gradients.
  16461. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16462. * @returns the list of velocity gradients
  16463. */
  16464. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16465. /**
  16466. * Adds a new velocity gradient
  16467. * @param gradient defines the gradient to use (between 0 and 1)
  16468. * @param factor defines the velocity to affect to the specified gradient
  16469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16470. * @returns the current particle system
  16471. */
  16472. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16473. /**
  16474. * Remove a specific velocity gradient
  16475. * @param gradient defines the gradient to remove
  16476. * @returns the current particle system
  16477. */
  16478. removeVelocityGradient(gradient: number): IParticleSystem;
  16479. /**
  16480. * Gets the current list of limit velocity gradients.
  16481. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16482. * @returns the list of limit velocity gradients
  16483. */
  16484. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16485. /**
  16486. * Adds a new limit velocity gradient
  16487. * @param gradient defines the gradient to use (between 0 and 1)
  16488. * @param factor defines the limit velocity to affect to the specified gradient
  16489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16490. * @returns the current particle system
  16491. */
  16492. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16493. /**
  16494. * Remove a specific limit velocity gradient
  16495. * @param gradient defines the gradient to remove
  16496. * @returns the current particle system
  16497. */
  16498. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16499. /**
  16500. * Adds a new drag gradient
  16501. * @param gradient defines the gradient to use (between 0 and 1)
  16502. * @param factor defines the drag to affect to the specified gradient
  16503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16504. * @returns the current particle system
  16505. */
  16506. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16507. /**
  16508. * Remove a specific drag gradient
  16509. * @param gradient defines the gradient to remove
  16510. * @returns the current particle system
  16511. */
  16512. removeDragGradient(gradient: number): IParticleSystem;
  16513. /**
  16514. * Gets the current list of drag gradients.
  16515. * You must use addDragGradient and removeDragGradient to udpate this list
  16516. * @returns the list of drag gradients
  16517. */
  16518. getDragGradients(): Nullable<Array<FactorGradient>>;
  16519. /**
  16520. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16521. * @param gradient defines the gradient to use (between 0 and 1)
  16522. * @param factor defines the emit rate to affect to the specified gradient
  16523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16524. * @returns the current particle system
  16525. */
  16526. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16527. /**
  16528. * Remove a specific emit rate gradient
  16529. * @param gradient defines the gradient to remove
  16530. * @returns the current particle system
  16531. */
  16532. removeEmitRateGradient(gradient: number): IParticleSystem;
  16533. /**
  16534. * Gets the current list of emit rate gradients.
  16535. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16536. * @returns the list of emit rate gradients
  16537. */
  16538. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16539. /**
  16540. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16541. * @param gradient defines the gradient to use (between 0 and 1)
  16542. * @param factor defines the start size to affect to the specified gradient
  16543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16544. * @returns the current particle system
  16545. */
  16546. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16547. /**
  16548. * Remove a specific start size gradient
  16549. * @param gradient defines the gradient to remove
  16550. * @returns the current particle system
  16551. */
  16552. removeStartSizeGradient(gradient: number): IParticleSystem;
  16553. /**
  16554. * Gets the current list of start size gradients.
  16555. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16556. * @returns the list of start size gradients
  16557. */
  16558. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16559. /**
  16560. * Adds a new life time gradient
  16561. * @param gradient defines the gradient to use (between 0 and 1)
  16562. * @param factor defines the life time factor to affect to the specified gradient
  16563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16564. * @returns the current particle system
  16565. */
  16566. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16567. /**
  16568. * Remove a specific life time gradient
  16569. * @param gradient defines the gradient to remove
  16570. * @returns the current particle system
  16571. */
  16572. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16573. /**
  16574. * Gets the current list of life time gradients.
  16575. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16576. * @returns the list of life time gradients
  16577. */
  16578. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16579. /**
  16580. * Gets the current list of color gradients.
  16581. * You must use addColorGradient and removeColorGradient to udpate this list
  16582. * @returns the list of color gradients
  16583. */
  16584. getColorGradients(): Nullable<Array<ColorGradient>>;
  16585. /**
  16586. * Adds a new ramp gradient used to remap particle colors
  16587. * @param gradient defines the gradient to use (between 0 and 1)
  16588. * @param color defines the color to affect to the specified gradient
  16589. * @returns the current particle system
  16590. */
  16591. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16592. /**
  16593. * Gets the current list of ramp gradients.
  16594. * You must use addRampGradient and removeRampGradient to udpate this list
  16595. * @returns the list of ramp gradients
  16596. */
  16597. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16598. /** Gets or sets a boolean indicating that ramp gradients must be used
  16599. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16600. */
  16601. useRampGradients: boolean;
  16602. /**
  16603. * Adds a new color remap gradient
  16604. * @param gradient defines the gradient to use (between 0 and 1)
  16605. * @param min defines the color remap minimal range
  16606. * @param max defines the color remap maximal range
  16607. * @returns the current particle system
  16608. */
  16609. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16610. /**
  16611. * Gets the current list of color remap gradients.
  16612. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16613. * @returns the list of color remap gradients
  16614. */
  16615. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16616. /**
  16617. * Adds a new alpha remap gradient
  16618. * @param gradient defines the gradient to use (between 0 and 1)
  16619. * @param min defines the alpha remap minimal range
  16620. * @param max defines the alpha remap maximal range
  16621. * @returns the current particle system
  16622. */
  16623. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16624. /**
  16625. * Gets the current list of alpha remap gradients.
  16626. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16627. * @returns the list of alpha remap gradients
  16628. */
  16629. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16630. /**
  16631. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16634. * @returns the emitter
  16635. */
  16636. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16637. /**
  16638. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16639. * @param radius The radius of the hemisphere to emit from
  16640. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16641. * @returns the emitter
  16642. */
  16643. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16644. /**
  16645. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16646. * @param radius The radius of the sphere to emit from
  16647. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16648. * @returns the emitter
  16649. */
  16650. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16651. /**
  16652. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16653. * @param radius The radius of the sphere to emit from
  16654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16656. * @returns the emitter
  16657. */
  16658. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16659. /**
  16660. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16661. * @param radius The radius of the emission cylinder
  16662. * @param height The height of the emission cylinder
  16663. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16664. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16665. * @returns the emitter
  16666. */
  16667. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16668. /**
  16669. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16670. * @param radius The radius of the cylinder to emit from
  16671. * @param height The height of the emission cylinder
  16672. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16673. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16674. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16675. * @returns the emitter
  16676. */
  16677. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16678. /**
  16679. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16680. * @param radius The radius of the cone to emit from
  16681. * @param angle The base angle of the cone
  16682. * @returns the emitter
  16683. */
  16684. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16685. /**
  16686. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16689. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16690. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16691. * @returns the emitter
  16692. */
  16693. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16694. /**
  16695. * Get hosting scene
  16696. * @returns the scene
  16697. */
  16698. getScene(): Scene;
  16699. }
  16700. }
  16701. declare module "babylonjs/Meshes/instancedMesh" {
  16702. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16703. import { Vector3 } from "babylonjs/Maths/math";
  16704. import { Camera } from "babylonjs/Cameras/camera";
  16705. import { Node } from "babylonjs/node";
  16706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16707. import { Mesh } from "babylonjs/Meshes/mesh";
  16708. import { Material } from "babylonjs/Materials/material";
  16709. import { Skeleton } from "babylonjs/Bones/skeleton";
  16710. /**
  16711. * Creates an instance based on a source mesh.
  16712. */
  16713. export class InstancedMesh extends AbstractMesh {
  16714. private _sourceMesh;
  16715. private _currentLOD;
  16716. /** @hidden */
  16717. _indexInSourceMeshInstanceArray: number;
  16718. constructor(name: string, source: Mesh);
  16719. /**
  16720. * Returns the string "InstancedMesh".
  16721. */
  16722. getClassName(): string;
  16723. /**
  16724. * If the source mesh receives shadows
  16725. */
  16726. readonly receiveShadows: boolean;
  16727. /**
  16728. * The material of the source mesh
  16729. */
  16730. readonly material: Nullable<Material>;
  16731. /**
  16732. * Visibility of the source mesh
  16733. */
  16734. readonly visibility: number;
  16735. /**
  16736. * Skeleton of the source mesh
  16737. */
  16738. readonly skeleton: Nullable<Skeleton>;
  16739. /**
  16740. * Rendering ground id of the source mesh
  16741. */
  16742. renderingGroupId: number;
  16743. /**
  16744. * Returns the total number of vertices (integer).
  16745. */
  16746. getTotalVertices(): number;
  16747. /**
  16748. * Returns a positive integer : the total number of indices in this mesh geometry.
  16749. * @returns the numner of indices or zero if the mesh has no geometry.
  16750. */
  16751. getTotalIndices(): number;
  16752. /**
  16753. * The source mesh of the instance
  16754. */
  16755. readonly sourceMesh: Mesh;
  16756. /**
  16757. * Is this node ready to be used/rendered
  16758. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16759. * @return {boolean} is it ready
  16760. */
  16761. isReady(completeCheck?: boolean): boolean;
  16762. /**
  16763. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16764. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16765. * @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.
  16766. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16767. */
  16768. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16769. /**
  16770. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16771. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16772. * The `data` are either a numeric array either a Float32Array.
  16773. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16774. * 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).
  16775. * Note that a new underlying VertexBuffer object is created each call.
  16776. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16777. *
  16778. * Possible `kind` values :
  16779. * - VertexBuffer.PositionKind
  16780. * - VertexBuffer.UVKind
  16781. * - VertexBuffer.UV2Kind
  16782. * - VertexBuffer.UV3Kind
  16783. * - VertexBuffer.UV4Kind
  16784. * - VertexBuffer.UV5Kind
  16785. * - VertexBuffer.UV6Kind
  16786. * - VertexBuffer.ColorKind
  16787. * - VertexBuffer.MatricesIndicesKind
  16788. * - VertexBuffer.MatricesIndicesExtraKind
  16789. * - VertexBuffer.MatricesWeightsKind
  16790. * - VertexBuffer.MatricesWeightsExtraKind
  16791. *
  16792. * Returns the Mesh.
  16793. */
  16794. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16795. /**
  16796. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16797. * If the mesh has no geometry, it is simply returned as it is.
  16798. * The `data` are either a numeric array either a Float32Array.
  16799. * No new underlying VertexBuffer object is created.
  16800. * 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.
  16801. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16802. *
  16803. * Possible `kind` values :
  16804. * - VertexBuffer.PositionKind
  16805. * - VertexBuffer.UVKind
  16806. * - VertexBuffer.UV2Kind
  16807. * - VertexBuffer.UV3Kind
  16808. * - VertexBuffer.UV4Kind
  16809. * - VertexBuffer.UV5Kind
  16810. * - VertexBuffer.UV6Kind
  16811. * - VertexBuffer.ColorKind
  16812. * - VertexBuffer.MatricesIndicesKind
  16813. * - VertexBuffer.MatricesIndicesExtraKind
  16814. * - VertexBuffer.MatricesWeightsKind
  16815. * - VertexBuffer.MatricesWeightsExtraKind
  16816. *
  16817. * Returns the Mesh.
  16818. */
  16819. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16820. /**
  16821. * Sets the mesh indices.
  16822. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16823. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16824. * This method creates a new index buffer each call.
  16825. * Returns the Mesh.
  16826. */
  16827. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16828. /**
  16829. * Boolean : True if the mesh owns the requested kind of data.
  16830. */
  16831. isVerticesDataPresent(kind: string): boolean;
  16832. /**
  16833. * Returns an array of indices (IndicesArray).
  16834. */
  16835. getIndices(): Nullable<IndicesArray>;
  16836. readonly _positions: Nullable<Vector3[]>;
  16837. /**
  16838. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16839. * This means the mesh underlying bounding box and sphere are recomputed.
  16840. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16841. * @returns the current mesh
  16842. */
  16843. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16844. /** @hidden */
  16845. _preActivate(): InstancedMesh;
  16846. /** @hidden */
  16847. _activate(renderId: number): InstancedMesh;
  16848. /**
  16849. * Returns the current associated LOD AbstractMesh.
  16850. */
  16851. getLOD(camera: Camera): AbstractMesh;
  16852. /** @hidden */
  16853. _syncSubMeshes(): InstancedMesh;
  16854. /** @hidden */
  16855. _generatePointsArray(): boolean;
  16856. /**
  16857. * Creates a new InstancedMesh from the current mesh.
  16858. * - name (string) : the cloned mesh name
  16859. * - newParent (optional Node) : the optional Node to parent the clone to.
  16860. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16861. *
  16862. * Returns the clone.
  16863. */
  16864. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16865. /**
  16866. * Disposes the InstancedMesh.
  16867. * Returns nothing.
  16868. */
  16869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16870. }
  16871. }
  16872. declare module "babylonjs/Materials/shaderMaterial" {
  16873. import { Scene } from "babylonjs/scene";
  16874. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16876. import { Mesh } from "babylonjs/Meshes/mesh";
  16877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16878. import { Texture } from "babylonjs/Materials/Textures/texture";
  16879. import { Material } from "babylonjs/Materials/material";
  16880. /**
  16881. * Defines the options associated with the creation of a shader material.
  16882. */
  16883. export interface IShaderMaterialOptions {
  16884. /**
  16885. * Does the material work in alpha blend mode
  16886. */
  16887. needAlphaBlending: boolean;
  16888. /**
  16889. * Does the material work in alpha test mode
  16890. */
  16891. needAlphaTesting: boolean;
  16892. /**
  16893. * The list of attribute names used in the shader
  16894. */
  16895. attributes: string[];
  16896. /**
  16897. * The list of unifrom names used in the shader
  16898. */
  16899. uniforms: string[];
  16900. /**
  16901. * The list of UBO names used in the shader
  16902. */
  16903. uniformBuffers: string[];
  16904. /**
  16905. * The list of sampler names used in the shader
  16906. */
  16907. samplers: string[];
  16908. /**
  16909. * The list of defines used in the shader
  16910. */
  16911. defines: string[];
  16912. }
  16913. /**
  16914. * 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.
  16915. *
  16916. * This returned material effects how the mesh will look based on the code in the shaders.
  16917. *
  16918. * @see http://doc.babylonjs.com/how_to/shader_material
  16919. */
  16920. export class ShaderMaterial extends Material {
  16921. private _shaderPath;
  16922. private _options;
  16923. private _textures;
  16924. private _textureArrays;
  16925. private _floats;
  16926. private _ints;
  16927. private _floatsArrays;
  16928. private _colors3;
  16929. private _colors3Arrays;
  16930. private _colors4;
  16931. private _vectors2;
  16932. private _vectors3;
  16933. private _vectors4;
  16934. private _matrices;
  16935. private _matrices3x3;
  16936. private _matrices2x2;
  16937. private _vectors2Arrays;
  16938. private _vectors3Arrays;
  16939. private _cachedWorldViewMatrix;
  16940. private _renderId;
  16941. /**
  16942. * Instantiate a new shader material.
  16943. * 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.
  16944. * This returned material effects how the mesh will look based on the code in the shaders.
  16945. * @see http://doc.babylonjs.com/how_to/shader_material
  16946. * @param name Define the name of the material in the scene
  16947. * @param scene Define the scene the material belongs to
  16948. * @param shaderPath Defines the route to the shader code in one of three ways:
  16949. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16950. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16951. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16952. * @param options Define the options used to create the shader
  16953. */
  16954. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16955. /**
  16956. * Gets the options used to compile the shader.
  16957. * They can be modified to trigger a new compilation
  16958. */
  16959. readonly options: IShaderMaterialOptions;
  16960. /**
  16961. * Gets the current class name of the material e.g. "ShaderMaterial"
  16962. * Mainly use in serialization.
  16963. * @returns the class name
  16964. */
  16965. getClassName(): string;
  16966. /**
  16967. * Specifies if the material will require alpha blending
  16968. * @returns a boolean specifying if alpha blending is needed
  16969. */
  16970. needAlphaBlending(): boolean;
  16971. /**
  16972. * Specifies if this material should be rendered in alpha test mode
  16973. * @returns a boolean specifying if an alpha test is needed.
  16974. */
  16975. needAlphaTesting(): boolean;
  16976. private _checkUniform;
  16977. /**
  16978. * Set a texture in the shader.
  16979. * @param name Define the name of the uniform samplers as defined in the shader
  16980. * @param texture Define the texture to bind to this sampler
  16981. * @return the material itself allowing "fluent" like uniform updates
  16982. */
  16983. setTexture(name: string, texture: Texture): ShaderMaterial;
  16984. /**
  16985. * Set a texture array in the shader.
  16986. * @param name Define the name of the uniform sampler array as defined in the shader
  16987. * @param textures Define the list of textures to bind to this sampler
  16988. * @return the material itself allowing "fluent" like uniform updates
  16989. */
  16990. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16991. /**
  16992. * Set a float in the shader.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the material itself allowing "fluent" like uniform updates
  16996. */
  16997. setFloat(name: string, value: number): ShaderMaterial;
  16998. /**
  16999. * Set a int in the shader.
  17000. * @param name Define the name of the uniform as defined in the shader
  17001. * @param value Define the value to give to the uniform
  17002. * @return the material itself allowing "fluent" like uniform updates
  17003. */
  17004. setInt(name: string, value: number): ShaderMaterial;
  17005. /**
  17006. * Set an array of floats in the shader.
  17007. * @param name Define the name of the uniform as defined in the shader
  17008. * @param value Define the value to give to the uniform
  17009. * @return the material itself allowing "fluent" like uniform updates
  17010. */
  17011. setFloats(name: string, value: number[]): ShaderMaterial;
  17012. /**
  17013. * Set a vec3 in the shader from a Color3.
  17014. * @param name Define the name of the uniform as defined in the shader
  17015. * @param value Define the value to give to the uniform
  17016. * @return the material itself allowing "fluent" like uniform updates
  17017. */
  17018. setColor3(name: string, value: Color3): ShaderMaterial;
  17019. /**
  17020. * Set a vec3 array in the shader from a Color3 array.
  17021. * @param name Define the name of the uniform as defined in the shader
  17022. * @param value Define the value to give to the uniform
  17023. * @return the material itself allowing "fluent" like uniform updates
  17024. */
  17025. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17026. /**
  17027. * Set a vec4 in the shader from a Color4.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the material itself allowing "fluent" like uniform updates
  17031. */
  17032. setColor4(name: string, value: Color4): ShaderMaterial;
  17033. /**
  17034. * Set a vec2 in the shader from a Vector2.
  17035. * @param name Define the name of the uniform as defined in the shader
  17036. * @param value Define the value to give to the uniform
  17037. * @return the material itself allowing "fluent" like uniform updates
  17038. */
  17039. setVector2(name: string, value: Vector2): ShaderMaterial;
  17040. /**
  17041. * Set a vec3 in the shader from a Vector3.
  17042. * @param name Define the name of the uniform as defined in the shader
  17043. * @param value Define the value to give to the uniform
  17044. * @return the material itself allowing "fluent" like uniform updates
  17045. */
  17046. setVector3(name: string, value: Vector3): ShaderMaterial;
  17047. /**
  17048. * Set a vec4 in the shader from a Vector4.
  17049. * @param name Define the name of the uniform as defined in the shader
  17050. * @param value Define the value to give to the uniform
  17051. * @return the material itself allowing "fluent" like uniform updates
  17052. */
  17053. setVector4(name: string, value: Vector4): ShaderMaterial;
  17054. /**
  17055. * Set a mat4 in the shader from a Matrix.
  17056. * @param name Define the name of the uniform as defined in the shader
  17057. * @param value Define the value to give to the uniform
  17058. * @return the material itself allowing "fluent" like uniform updates
  17059. */
  17060. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17061. /**
  17062. * Set a mat3 in the shader from a Float32Array.
  17063. * @param name Define the name of the uniform as defined in the shader
  17064. * @param value Define the value to give to the uniform
  17065. * @return the material itself allowing "fluent" like uniform updates
  17066. */
  17067. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17068. /**
  17069. * Set a mat2 in the shader from a Float32Array.
  17070. * @param name Define the name of the uniform as defined in the shader
  17071. * @param value Define the value to give to the uniform
  17072. * @return the material itself allowing "fluent" like uniform updates
  17073. */
  17074. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17075. /**
  17076. * Set a vec2 array in the shader from a number array.
  17077. * @param name Define the name of the uniform as defined in the shader
  17078. * @param value Define the value to give to the uniform
  17079. * @return the material itself allowing "fluent" like uniform updates
  17080. */
  17081. setArray2(name: string, value: number[]): ShaderMaterial;
  17082. /**
  17083. * Set a vec3 array in the shader from a number array.
  17084. * @param name Define the name of the uniform as defined in the shader
  17085. * @param value Define the value to give to the uniform
  17086. * @return the material itself allowing "fluent" like uniform updates
  17087. */
  17088. setArray3(name: string, value: number[]): ShaderMaterial;
  17089. private _checkCache;
  17090. /**
  17091. * Checks if the material is ready to render the requested mesh
  17092. * @param mesh Define the mesh to render
  17093. * @param useInstances Define whether or not the material is used with instances
  17094. * @returns true if ready, otherwise false
  17095. */
  17096. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17097. /**
  17098. * Binds the world matrix to the material
  17099. * @param world defines the world transformation matrix
  17100. */
  17101. bindOnlyWorldMatrix(world: Matrix): void;
  17102. /**
  17103. * Binds the material to the mesh
  17104. * @param world defines the world transformation matrix
  17105. * @param mesh defines the mesh to bind the material to
  17106. */
  17107. bind(world: Matrix, mesh?: Mesh): void;
  17108. /**
  17109. * Gets the active textures from the material
  17110. * @returns an array of textures
  17111. */
  17112. getActiveTextures(): BaseTexture[];
  17113. /**
  17114. * Specifies if the material uses a texture
  17115. * @param texture defines the texture to check against the material
  17116. * @returns a boolean specifying if the material uses the texture
  17117. */
  17118. hasTexture(texture: BaseTexture): boolean;
  17119. /**
  17120. * Makes a duplicate of the material, and gives it a new name
  17121. * @param name defines the new name for the duplicated material
  17122. * @returns the cloned material
  17123. */
  17124. clone(name: string): ShaderMaterial;
  17125. /**
  17126. * Disposes the material
  17127. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17128. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17129. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17130. */
  17131. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17132. /**
  17133. * Serializes this material in a JSON representation
  17134. * @returns the serialized material object
  17135. */
  17136. serialize(): any;
  17137. /**
  17138. * Creates a shader material from parsed shader material data
  17139. * @param source defines the JSON represnetation of the material
  17140. * @param scene defines the hosting scene
  17141. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17142. * @returns a new material
  17143. */
  17144. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17145. }
  17146. }
  17147. declare module "babylonjs/Shaders/color.fragment" {
  17148. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17149. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17150. /** @hidden */
  17151. export var colorPixelShader: {
  17152. name: string;
  17153. shader: string;
  17154. };
  17155. }
  17156. declare module "babylonjs/Shaders/color.vertex" {
  17157. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17158. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17159. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17160. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17161. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17162. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17163. /** @hidden */
  17164. export var colorVertexShader: {
  17165. name: string;
  17166. shader: string;
  17167. };
  17168. }
  17169. declare module "babylonjs/Meshes/linesMesh" {
  17170. import { Nullable } from "babylonjs/types";
  17171. import { Scene } from "babylonjs/scene";
  17172. import { Color3 } from "babylonjs/Maths/math";
  17173. import { Node } from "babylonjs/node";
  17174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17175. import { Mesh } from "babylonjs/Meshes/mesh";
  17176. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17177. import { Effect } from "babylonjs/Materials/effect";
  17178. import { Material } from "babylonjs/Materials/material";
  17179. import "babylonjs/Shaders/color.fragment";
  17180. import "babylonjs/Shaders/color.vertex";
  17181. /**
  17182. * Line mesh
  17183. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17184. */
  17185. export class LinesMesh extends Mesh {
  17186. /**
  17187. * If vertex color should be applied to the mesh
  17188. */
  17189. useVertexColor?: boolean | undefined;
  17190. /**
  17191. * If vertex alpha should be applied to the mesh
  17192. */
  17193. useVertexAlpha?: boolean | undefined;
  17194. /**
  17195. * Color of the line (Default: White)
  17196. */
  17197. color: Color3;
  17198. /**
  17199. * Alpha of the line (Default: 1)
  17200. */
  17201. alpha: number;
  17202. /**
  17203. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17204. * This margin is expressed in world space coordinates, so its value may vary.
  17205. * Default value is 0.1
  17206. */
  17207. intersectionThreshold: number;
  17208. private _colorShader;
  17209. /**
  17210. * Creates a new LinesMesh
  17211. * @param name defines the name
  17212. * @param scene defines the hosting scene
  17213. * @param parent defines the parent mesh if any
  17214. * @param source defines the optional source LinesMesh used to clone data from
  17215. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17216. * When false, achieved by calling a clone(), also passing False.
  17217. * This will make creation of children, recursive.
  17218. * @param useVertexColor defines if this LinesMesh supports vertex color
  17219. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17220. */
  17221. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17222. /**
  17223. * If vertex color should be applied to the mesh
  17224. */
  17225. useVertexColor?: boolean | undefined,
  17226. /**
  17227. * If vertex alpha should be applied to the mesh
  17228. */
  17229. useVertexAlpha?: boolean | undefined);
  17230. private _addClipPlaneDefine;
  17231. private _removeClipPlaneDefine;
  17232. isReady(): boolean;
  17233. /**
  17234. * Returns the string "LineMesh"
  17235. */
  17236. getClassName(): string;
  17237. /**
  17238. * @hidden
  17239. */
  17240. /**
  17241. * @hidden
  17242. */
  17243. material: Material;
  17244. /**
  17245. * @hidden
  17246. */
  17247. readonly checkCollisions: boolean;
  17248. /** @hidden */
  17249. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17250. /** @hidden */
  17251. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17252. /**
  17253. * Disposes of the line mesh
  17254. * @param doNotRecurse If children should be disposed
  17255. */
  17256. dispose(doNotRecurse?: boolean): void;
  17257. /**
  17258. * Returns a new LineMesh object cloned from the current one.
  17259. */
  17260. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17261. /**
  17262. * Creates a new InstancedLinesMesh object from the mesh model.
  17263. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17264. * @param name defines the name of the new instance
  17265. * @returns a new InstancedLinesMesh
  17266. */
  17267. createInstance(name: string): InstancedLinesMesh;
  17268. }
  17269. /**
  17270. * Creates an instance based on a source LinesMesh
  17271. */
  17272. export class InstancedLinesMesh extends InstancedMesh {
  17273. /**
  17274. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17275. * This margin is expressed in world space coordinates, so its value may vary.
  17276. * Initilized with the intersectionThreshold value of the source LinesMesh
  17277. */
  17278. intersectionThreshold: number;
  17279. constructor(name: string, source: LinesMesh);
  17280. /**
  17281. * Returns the string "InstancedLinesMesh".
  17282. */
  17283. getClassName(): string;
  17284. }
  17285. }
  17286. declare module "babylonjs/Shaders/line.fragment" {
  17287. /** @hidden */
  17288. export var linePixelShader: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module "babylonjs/Shaders/line.vertex" {
  17294. /** @hidden */
  17295. export var lineVertexShader: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Rendering/edgesRenderer" {
  17301. import { Nullable } from "babylonjs/types";
  17302. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17304. import { Vector3 } from "babylonjs/Maths/math";
  17305. import { IDisposable } from "babylonjs/scene";
  17306. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17307. import "babylonjs/Shaders/line.fragment";
  17308. import "babylonjs/Shaders/line.vertex";
  17309. module "babylonjs/Meshes/abstractMesh" {
  17310. interface AbstractMesh {
  17311. /**
  17312. * Disables the mesh edge rendering mode
  17313. * @returns the currentAbstractMesh
  17314. */
  17315. disableEdgesRendering(): AbstractMesh;
  17316. /**
  17317. * Enables the edge rendering mode on the mesh.
  17318. * This mode makes the mesh edges visible
  17319. * @param epsilon defines the maximal distance between two angles to detect a face
  17320. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17321. * @returns the currentAbstractMesh
  17322. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17323. */
  17324. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17325. /**
  17326. * Gets the edgesRenderer associated with the mesh
  17327. */
  17328. edgesRenderer: Nullable<EdgesRenderer>;
  17329. }
  17330. }
  17331. module "babylonjs/Meshes/linesMesh" {
  17332. interface LinesMesh {
  17333. /**
  17334. * Enables the edge rendering mode on the mesh.
  17335. * This mode makes the mesh edges visible
  17336. * @param epsilon defines the maximal distance between two angles to detect a face
  17337. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17338. * @returns the currentAbstractMesh
  17339. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17340. */
  17341. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17342. }
  17343. }
  17344. module "babylonjs/Meshes/linesMesh" {
  17345. interface InstancedLinesMesh {
  17346. /**
  17347. * Enables the edge rendering mode on the mesh.
  17348. * This mode makes the mesh edges visible
  17349. * @param epsilon defines the maximal distance between two angles to detect a face
  17350. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17351. * @returns the current InstancedLinesMesh
  17352. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17353. */
  17354. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17355. }
  17356. }
  17357. /**
  17358. * Defines the minimum contract an Edges renderer should follow.
  17359. */
  17360. export interface IEdgesRenderer extends IDisposable {
  17361. /**
  17362. * Gets or sets a boolean indicating if the edgesRenderer is active
  17363. */
  17364. isEnabled: boolean;
  17365. /**
  17366. * Renders the edges of the attached mesh,
  17367. */
  17368. render(): void;
  17369. /**
  17370. * Checks wether or not the edges renderer is ready to render.
  17371. * @return true if ready, otherwise false.
  17372. */
  17373. isReady(): boolean;
  17374. }
  17375. /**
  17376. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17377. */
  17378. export class EdgesRenderer implements IEdgesRenderer {
  17379. /**
  17380. * Define the size of the edges with an orthographic camera
  17381. */
  17382. edgesWidthScalerForOrthographic: number;
  17383. /**
  17384. * Define the size of the edges with a perspective camera
  17385. */
  17386. edgesWidthScalerForPerspective: number;
  17387. protected _source: AbstractMesh;
  17388. protected _linesPositions: number[];
  17389. protected _linesNormals: number[];
  17390. protected _linesIndices: number[];
  17391. protected _epsilon: number;
  17392. protected _indicesCount: number;
  17393. protected _lineShader: ShaderMaterial;
  17394. protected _ib: WebGLBuffer;
  17395. protected _buffers: {
  17396. [key: string]: Nullable<VertexBuffer>;
  17397. };
  17398. protected _checkVerticesInsteadOfIndices: boolean;
  17399. private _meshRebuildObserver;
  17400. private _meshDisposeObserver;
  17401. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17402. isEnabled: boolean;
  17403. /**
  17404. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17405. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17406. * @param source Mesh used to create edges
  17407. * @param epsilon sum of angles in adjacency to check for edge
  17408. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17409. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17410. */
  17411. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17412. protected _prepareRessources(): void;
  17413. /** @hidden */
  17414. _rebuild(): void;
  17415. /**
  17416. * Releases the required resources for the edges renderer
  17417. */
  17418. dispose(): void;
  17419. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17420. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17421. /**
  17422. * Checks if the pair of p0 and p1 is en edge
  17423. * @param faceIndex
  17424. * @param edge
  17425. * @param faceNormals
  17426. * @param p0
  17427. * @param p1
  17428. * @private
  17429. */
  17430. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17431. /**
  17432. * push line into the position, normal and index buffer
  17433. * @protected
  17434. */
  17435. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17436. /**
  17437. * Generates lines edges from adjacencjes
  17438. * @private
  17439. */
  17440. _generateEdgesLines(): void;
  17441. /**
  17442. * Checks wether or not the edges renderer is ready to render.
  17443. * @return true if ready, otherwise false.
  17444. */
  17445. isReady(): boolean;
  17446. /**
  17447. * Renders the edges of the attached mesh,
  17448. */
  17449. render(): void;
  17450. }
  17451. /**
  17452. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17453. */
  17454. export class LineEdgesRenderer extends EdgesRenderer {
  17455. /**
  17456. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17457. * @param source LineMesh used to generate edges
  17458. * @param epsilon not important (specified angle for edge detection)
  17459. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17460. */
  17461. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17462. /**
  17463. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17464. */
  17465. _generateEdgesLines(): void;
  17466. }
  17467. }
  17468. declare module "babylonjs/Rendering/renderingGroup" {
  17469. import { SmartArray } from "babylonjs/Misc/smartArray";
  17470. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17472. import { Nullable } from "babylonjs/types";
  17473. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17474. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17475. import { Material } from "babylonjs/Materials/material";
  17476. import { Scene } from "babylonjs/scene";
  17477. /**
  17478. * This represents the object necessary to create a rendering group.
  17479. * This is exclusively used and created by the rendering manager.
  17480. * To modify the behavior, you use the available helpers in your scene or meshes.
  17481. * @hidden
  17482. */
  17483. export class RenderingGroup {
  17484. index: number;
  17485. private _scene;
  17486. private _opaqueSubMeshes;
  17487. private _transparentSubMeshes;
  17488. private _alphaTestSubMeshes;
  17489. private _depthOnlySubMeshes;
  17490. private _particleSystems;
  17491. private _spriteManagers;
  17492. private _opaqueSortCompareFn;
  17493. private _alphaTestSortCompareFn;
  17494. private _transparentSortCompareFn;
  17495. private _renderOpaque;
  17496. private _renderAlphaTest;
  17497. private _renderTransparent;
  17498. private _edgesRenderers;
  17499. onBeforeTransparentRendering: () => void;
  17500. /**
  17501. * Set the opaque sort comparison function.
  17502. * If null the sub meshes will be render in the order they were created
  17503. */
  17504. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17505. /**
  17506. * Set the alpha test sort comparison function.
  17507. * If null the sub meshes will be render in the order they were created
  17508. */
  17509. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17510. /**
  17511. * Set the transparent sort comparison function.
  17512. * If null the sub meshes will be render in the order they were created
  17513. */
  17514. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17515. /**
  17516. * Creates a new rendering group.
  17517. * @param index The rendering group index
  17518. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17519. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17520. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17521. */
  17522. 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>);
  17523. /**
  17524. * Render all the sub meshes contained in the group.
  17525. * @param customRenderFunction Used to override the default render behaviour of the group.
  17526. * @returns true if rendered some submeshes.
  17527. */
  17528. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17529. /**
  17530. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17531. * @param subMeshes The submeshes to render
  17532. */
  17533. private renderOpaqueSorted;
  17534. /**
  17535. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17536. * @param subMeshes The submeshes to render
  17537. */
  17538. private renderAlphaTestSorted;
  17539. /**
  17540. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17541. * @param subMeshes The submeshes to render
  17542. */
  17543. private renderTransparentSorted;
  17544. /**
  17545. * Renders the submeshes in a specified order.
  17546. * @param subMeshes The submeshes to sort before render
  17547. * @param sortCompareFn The comparison function use to sort
  17548. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17549. * @param transparent Specifies to activate blending if true
  17550. */
  17551. private static renderSorted;
  17552. /**
  17553. * Renders the submeshes in the order they were dispatched (no sort applied).
  17554. * @param subMeshes The submeshes to render
  17555. */
  17556. private static renderUnsorted;
  17557. /**
  17558. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17559. * are rendered back to front if in the same alpha index.
  17560. *
  17561. * @param a The first submesh
  17562. * @param b The second submesh
  17563. * @returns The result of the comparison
  17564. */
  17565. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17566. /**
  17567. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17568. * are rendered back to front.
  17569. *
  17570. * @param a The first submesh
  17571. * @param b The second submesh
  17572. * @returns The result of the comparison
  17573. */
  17574. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17575. /**
  17576. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17577. * are rendered front to back (prevent overdraw).
  17578. *
  17579. * @param a The first submesh
  17580. * @param b The second submesh
  17581. * @returns The result of the comparison
  17582. */
  17583. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17584. /**
  17585. * Resets the different lists of submeshes to prepare a new frame.
  17586. */
  17587. prepare(): void;
  17588. dispose(): void;
  17589. /**
  17590. * Inserts the submesh in its correct queue depending on its material.
  17591. * @param subMesh The submesh to dispatch
  17592. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17593. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17594. */
  17595. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17596. dispatchSprites(spriteManager: ISpriteManager): void;
  17597. dispatchParticles(particleSystem: IParticleSystem): void;
  17598. private _renderParticles;
  17599. private _renderSprites;
  17600. }
  17601. }
  17602. declare module "babylonjs/Rendering/renderingManager" {
  17603. import { Nullable } from "babylonjs/types";
  17604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17606. import { SmartArray } from "babylonjs/Misc/smartArray";
  17607. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17608. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17609. import { Material } from "babylonjs/Materials/material";
  17610. import { Scene } from "babylonjs/scene";
  17611. import { Camera } from "babylonjs/Cameras/camera";
  17612. /**
  17613. * Interface describing the different options available in the rendering manager
  17614. * regarding Auto Clear between groups.
  17615. */
  17616. export interface IRenderingManagerAutoClearSetup {
  17617. /**
  17618. * Defines whether or not autoclear is enable.
  17619. */
  17620. autoClear: boolean;
  17621. /**
  17622. * Defines whether or not to autoclear the depth buffer.
  17623. */
  17624. depth: boolean;
  17625. /**
  17626. * Defines whether or not to autoclear the stencil buffer.
  17627. */
  17628. stencil: boolean;
  17629. }
  17630. /**
  17631. * This class is used by the onRenderingGroupObservable
  17632. */
  17633. export class RenderingGroupInfo {
  17634. /**
  17635. * The Scene that being rendered
  17636. */
  17637. scene: Scene;
  17638. /**
  17639. * The camera currently used for the rendering pass
  17640. */
  17641. camera: Nullable<Camera>;
  17642. /**
  17643. * The ID of the renderingGroup being processed
  17644. */
  17645. renderingGroupId: number;
  17646. }
  17647. /**
  17648. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17649. * It is enable to manage the different groups as well as the different necessary sort functions.
  17650. * This should not be used directly aside of the few static configurations
  17651. */
  17652. export class RenderingManager {
  17653. /**
  17654. * The max id used for rendering groups (not included)
  17655. */
  17656. static MAX_RENDERINGGROUPS: number;
  17657. /**
  17658. * The min id used for rendering groups (included)
  17659. */
  17660. static MIN_RENDERINGGROUPS: number;
  17661. /**
  17662. * Used to globally prevent autoclearing scenes.
  17663. */
  17664. static AUTOCLEAR: boolean;
  17665. /**
  17666. * @hidden
  17667. */
  17668. _useSceneAutoClearSetup: boolean;
  17669. private _scene;
  17670. private _renderingGroups;
  17671. private _depthStencilBufferAlreadyCleaned;
  17672. private _autoClearDepthStencil;
  17673. private _customOpaqueSortCompareFn;
  17674. private _customAlphaTestSortCompareFn;
  17675. private _customTransparentSortCompareFn;
  17676. private _renderingGroupInfo;
  17677. /**
  17678. * Instantiates a new rendering group for a particular scene
  17679. * @param scene Defines the scene the groups belongs to
  17680. */
  17681. constructor(scene: Scene);
  17682. private _clearDepthStencilBuffer;
  17683. /**
  17684. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17685. * @hidden
  17686. */
  17687. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17688. /**
  17689. * Resets the different information of the group to prepare a new frame
  17690. * @hidden
  17691. */
  17692. reset(): void;
  17693. /**
  17694. * Dispose and release the group and its associated resources.
  17695. * @hidden
  17696. */
  17697. dispose(): void;
  17698. /**
  17699. * Clear the info related to rendering groups preventing retention points during dispose.
  17700. */
  17701. freeRenderingGroups(): void;
  17702. private _prepareRenderingGroup;
  17703. /**
  17704. * Add a sprite manager to the rendering manager in order to render it this frame.
  17705. * @param spriteManager Define the sprite manager to render
  17706. */
  17707. dispatchSprites(spriteManager: ISpriteManager): void;
  17708. /**
  17709. * Add a particle system to the rendering manager in order to render it this frame.
  17710. * @param particleSystem Define the particle system to render
  17711. */
  17712. dispatchParticles(particleSystem: IParticleSystem): void;
  17713. /**
  17714. * Add a submesh to the manager in order to render it this frame
  17715. * @param subMesh The submesh to dispatch
  17716. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17717. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17718. */
  17719. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17720. /**
  17721. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17722. * This allowed control for front to back rendering or reversly depending of the special needs.
  17723. *
  17724. * @param renderingGroupId The rendering group id corresponding to its index
  17725. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17726. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17727. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17728. */
  17729. 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;
  17730. /**
  17731. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17732. *
  17733. * @param renderingGroupId The rendering group id corresponding to its index
  17734. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17735. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17736. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17737. */
  17738. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17739. /**
  17740. * Gets the current auto clear configuration for one rendering group of the rendering
  17741. * manager.
  17742. * @param index the rendering group index to get the information for
  17743. * @returns The auto clear setup for the requested rendering group
  17744. */
  17745. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17746. }
  17747. }
  17748. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17749. import { Observable } from "babylonjs/Misc/observable";
  17750. import { SmartArray } from "babylonjs/Misc/smartArray";
  17751. import { Nullable } from "babylonjs/types";
  17752. import { Camera } from "babylonjs/Cameras/camera";
  17753. import { Scene } from "babylonjs/scene";
  17754. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17755. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17758. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17759. import { Texture } from "babylonjs/Materials/Textures/texture";
  17760. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17761. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17762. import { Engine } from "babylonjs/Engines/engine";
  17763. /**
  17764. * This Helps creating a texture that will be created from a camera in your scene.
  17765. * It is basically a dynamic texture that could be used to create special effects for instance.
  17766. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17767. */
  17768. export class RenderTargetTexture extends Texture {
  17769. isCube: boolean;
  17770. /**
  17771. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17772. */
  17773. static readonly REFRESHRATE_RENDER_ONCE: number;
  17774. /**
  17775. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17776. */
  17777. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17778. /**
  17779. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17780. * the central point of your effect and can save a lot of performances.
  17781. */
  17782. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17783. /**
  17784. * Use this predicate to dynamically define the list of mesh you want to render.
  17785. * If set, the renderList property will be overwritten.
  17786. */
  17787. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17788. private _renderList;
  17789. /**
  17790. * Use this list to define the list of mesh you want to render.
  17791. */
  17792. renderList: Nullable<Array<AbstractMesh>>;
  17793. private _hookArray;
  17794. /**
  17795. * Define if particles should be rendered in your texture.
  17796. */
  17797. renderParticles: boolean;
  17798. /**
  17799. * Define if sprites should be rendered in your texture.
  17800. */
  17801. renderSprites: boolean;
  17802. /**
  17803. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17804. */
  17805. coordinatesMode: number;
  17806. /**
  17807. * Define the camera used to render the texture.
  17808. */
  17809. activeCamera: Nullable<Camera>;
  17810. /**
  17811. * Override the render function of the texture with your own one.
  17812. */
  17813. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17814. /**
  17815. * Define if camera post processes should be use while rendering the texture.
  17816. */
  17817. useCameraPostProcesses: boolean;
  17818. /**
  17819. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17820. */
  17821. ignoreCameraViewport: boolean;
  17822. private _postProcessManager;
  17823. private _postProcesses;
  17824. private _resizeObserver;
  17825. /**
  17826. * An event triggered when the texture is unbind.
  17827. */
  17828. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17829. /**
  17830. * An event triggered when the texture is unbind.
  17831. */
  17832. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17833. private _onAfterUnbindObserver;
  17834. /**
  17835. * Set a after unbind callback in the texture.
  17836. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17837. */
  17838. onAfterUnbind: () => void;
  17839. /**
  17840. * An event triggered before rendering the texture
  17841. */
  17842. onBeforeRenderObservable: Observable<number>;
  17843. private _onBeforeRenderObserver;
  17844. /**
  17845. * Set a before render callback in the texture.
  17846. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17847. */
  17848. onBeforeRender: (faceIndex: number) => void;
  17849. /**
  17850. * An event triggered after rendering the texture
  17851. */
  17852. onAfterRenderObservable: Observable<number>;
  17853. private _onAfterRenderObserver;
  17854. /**
  17855. * Set a after render callback in the texture.
  17856. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17857. */
  17858. onAfterRender: (faceIndex: number) => void;
  17859. /**
  17860. * An event triggered after the texture clear
  17861. */
  17862. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17863. private _onClearObserver;
  17864. /**
  17865. * Set a clear callback in the texture.
  17866. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17867. */
  17868. onClear: (Engine: Engine) => void;
  17869. /**
  17870. * Define the clear color of the Render Target if it should be different from the scene.
  17871. */
  17872. clearColor: Color4;
  17873. protected _size: number | {
  17874. width: number;
  17875. height: number;
  17876. };
  17877. protected _initialSizeParameter: number | {
  17878. width: number;
  17879. height: number;
  17880. } | {
  17881. ratio: number;
  17882. };
  17883. protected _sizeRatio: Nullable<number>;
  17884. /** @hidden */
  17885. _generateMipMaps: boolean;
  17886. protected _renderingManager: RenderingManager;
  17887. /** @hidden */
  17888. _waitingRenderList: string[];
  17889. protected _doNotChangeAspectRatio: boolean;
  17890. protected _currentRefreshId: number;
  17891. protected _refreshRate: number;
  17892. protected _textureMatrix: Matrix;
  17893. protected _samples: number;
  17894. protected _renderTargetOptions: RenderTargetCreationOptions;
  17895. /**
  17896. * Gets render target creation options that were used.
  17897. */
  17898. readonly renderTargetOptions: RenderTargetCreationOptions;
  17899. protected _engine: Engine;
  17900. protected _onRatioRescale(): void;
  17901. /**
  17902. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17903. * It must define where the camera used to render the texture is set
  17904. */
  17905. boundingBoxPosition: Vector3;
  17906. private _boundingBoxSize;
  17907. /**
  17908. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17909. * When defined, the cubemap will switch to local mode
  17910. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17911. * @example https://www.babylonjs-playground.com/#RNASML
  17912. */
  17913. boundingBoxSize: Vector3;
  17914. /**
  17915. * In case the RTT has been created with a depth texture, get the associated
  17916. * depth texture.
  17917. * Otherwise, return null.
  17918. */
  17919. depthStencilTexture: Nullable<InternalTexture>;
  17920. /**
  17921. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17922. * or used a shadow, depth texture...
  17923. * @param name The friendly name of the texture
  17924. * @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)
  17925. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17926. * @param generateMipMaps True if mip maps need to be generated after render.
  17927. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17928. * @param type The type of the buffer in the RTT (int, half float, float...)
  17929. * @param isCube True if a cube texture needs to be created
  17930. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17931. * @param generateDepthBuffer True to generate a depth buffer
  17932. * @param generateStencilBuffer True to generate a stencil buffer
  17933. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17934. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17935. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17936. */
  17937. constructor(name: string, size: number | {
  17938. width: number;
  17939. height: number;
  17940. } | {
  17941. ratio: number;
  17942. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17943. /**
  17944. * Creates a depth stencil texture.
  17945. * This is only available in WebGL 2 or with the depth texture extension available.
  17946. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17947. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17948. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17949. */
  17950. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17951. private _processSizeParameter;
  17952. /**
  17953. * Define the number of samples to use in case of MSAA.
  17954. * It defaults to one meaning no MSAA has been enabled.
  17955. */
  17956. samples: number;
  17957. /**
  17958. * Resets the refresh counter of the texture and start bak from scratch.
  17959. * Could be useful to regenerate the texture if it is setup to render only once.
  17960. */
  17961. resetRefreshCounter(): void;
  17962. /**
  17963. * Define the refresh rate of the texture or the rendering frequency.
  17964. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17965. */
  17966. refreshRate: number;
  17967. /**
  17968. * Adds a post process to the render target rendering passes.
  17969. * @param postProcess define the post process to add
  17970. */
  17971. addPostProcess(postProcess: PostProcess): void;
  17972. /**
  17973. * Clear all the post processes attached to the render target
  17974. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17975. */
  17976. clearPostProcesses(dispose?: boolean): void;
  17977. /**
  17978. * Remove one of the post process from the list of attached post processes to the texture
  17979. * @param postProcess define the post process to remove from the list
  17980. */
  17981. removePostProcess(postProcess: PostProcess): void;
  17982. /** @hidden */
  17983. _shouldRender(): boolean;
  17984. /**
  17985. * Gets the actual render size of the texture.
  17986. * @returns the width of the render size
  17987. */
  17988. getRenderSize(): number;
  17989. /**
  17990. * Gets the actual render width of the texture.
  17991. * @returns the width of the render size
  17992. */
  17993. getRenderWidth(): number;
  17994. /**
  17995. * Gets the actual render height of the texture.
  17996. * @returns the height of the render size
  17997. */
  17998. getRenderHeight(): number;
  17999. /**
  18000. * Get if the texture can be rescaled or not.
  18001. */
  18002. readonly canRescale: boolean;
  18003. /**
  18004. * Resize the texture using a ratio.
  18005. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18006. */
  18007. scale(ratio: number): void;
  18008. /**
  18009. * Get the texture reflection matrix used to rotate/transform the reflection.
  18010. * @returns the reflection matrix
  18011. */
  18012. getReflectionTextureMatrix(): Matrix;
  18013. /**
  18014. * Resize the texture to a new desired size.
  18015. * Be carrefull as it will recreate all the data in the new texture.
  18016. * @param size Define the new size. It can be:
  18017. * - a number for squared texture,
  18018. * - an object containing { width: number, height: number }
  18019. * - or an object containing a ratio { ratio: number }
  18020. */
  18021. resize(size: number | {
  18022. width: number;
  18023. height: number;
  18024. } | {
  18025. ratio: number;
  18026. }): void;
  18027. /**
  18028. * Renders all the objects from the render list into the texture.
  18029. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18030. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18031. */
  18032. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18033. private _bestReflectionRenderTargetDimension;
  18034. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18035. private renderToTarget;
  18036. /**
  18037. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18038. * This allowed control for front to back rendering or reversly depending of the special needs.
  18039. *
  18040. * @param renderingGroupId The rendering group id corresponding to its index
  18041. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18042. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18043. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18044. */
  18045. 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;
  18046. /**
  18047. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18048. *
  18049. * @param renderingGroupId The rendering group id corresponding to its index
  18050. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18051. */
  18052. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18053. /**
  18054. * Clones the texture.
  18055. * @returns the cloned texture
  18056. */
  18057. clone(): RenderTargetTexture;
  18058. /**
  18059. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18060. * @returns The JSON representation of the texture
  18061. */
  18062. serialize(): any;
  18063. /**
  18064. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18065. */
  18066. disposeFramebufferObjects(): void;
  18067. /**
  18068. * Dispose the texture and release its associated resources.
  18069. */
  18070. dispose(): void;
  18071. /** @hidden */
  18072. _rebuild(): void;
  18073. /**
  18074. * Clear the info related to rendering groups preventing retention point in material dispose.
  18075. */
  18076. freeRenderingGroups(): void;
  18077. }
  18078. }
  18079. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18080. import { Scene } from "babylonjs/scene";
  18081. import { Plane } from "babylonjs/Maths/math";
  18082. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18083. /**
  18084. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18085. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18086. * You can then easily use it as a reflectionTexture on a flat surface.
  18087. * In case the surface is not a plane, please consider relying on reflection probes.
  18088. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18089. */
  18090. export class MirrorTexture extends RenderTargetTexture {
  18091. private scene;
  18092. /**
  18093. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18094. * 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.
  18095. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18096. */
  18097. mirrorPlane: Plane;
  18098. /**
  18099. * Define the blur ratio used to blur the reflection if needed.
  18100. */
  18101. blurRatio: number;
  18102. /**
  18103. * Define the adaptive blur kernel used to blur the reflection if needed.
  18104. * This will autocompute the closest best match for the `blurKernel`
  18105. */
  18106. adaptiveBlurKernel: number;
  18107. /**
  18108. * Define the blur kernel used to blur the reflection if needed.
  18109. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18110. */
  18111. blurKernel: number;
  18112. /**
  18113. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18114. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18115. */
  18116. blurKernelX: number;
  18117. /**
  18118. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18119. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18120. */
  18121. blurKernelY: number;
  18122. private _autoComputeBlurKernel;
  18123. protected _onRatioRescale(): void;
  18124. private _updateGammaSpace;
  18125. private _imageProcessingConfigChangeObserver;
  18126. private _transformMatrix;
  18127. private _mirrorMatrix;
  18128. private _savedViewMatrix;
  18129. private _blurX;
  18130. private _blurY;
  18131. private _adaptiveBlurKernel;
  18132. private _blurKernelX;
  18133. private _blurKernelY;
  18134. private _blurRatio;
  18135. /**
  18136. * Instantiates a Mirror Texture.
  18137. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18138. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18139. * You can then easily use it as a reflectionTexture on a flat surface.
  18140. * In case the surface is not a plane, please consider relying on reflection probes.
  18141. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18142. * @param name
  18143. * @param size
  18144. * @param scene
  18145. * @param generateMipMaps
  18146. * @param type
  18147. * @param samplingMode
  18148. * @param generateDepthBuffer
  18149. */
  18150. constructor(name: string, size: number | {
  18151. width: number;
  18152. height: number;
  18153. } | {
  18154. ratio: number;
  18155. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18156. private _preparePostProcesses;
  18157. /**
  18158. * Clone the mirror texture.
  18159. * @returns the cloned texture
  18160. */
  18161. clone(): MirrorTexture;
  18162. /**
  18163. * Serialize the texture to a JSON representation you could use in Parse later on
  18164. * @returns the serialized JSON representation
  18165. */
  18166. serialize(): any;
  18167. /**
  18168. * Dispose the texture and release its associated resources.
  18169. */
  18170. dispose(): void;
  18171. }
  18172. }
  18173. declare module "babylonjs/Materials/Textures/texture" {
  18174. import { Observable } from "babylonjs/Misc/observable";
  18175. import { Nullable } from "babylonjs/types";
  18176. import { Scene } from "babylonjs/scene";
  18177. import { Matrix } from "babylonjs/Maths/math";
  18178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18179. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18180. /**
  18181. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18182. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18183. */
  18184. export class Texture extends BaseTexture {
  18185. /** @hidden */
  18186. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18187. /** @hidden */
  18188. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18189. /** @hidden */
  18190. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18191. /** nearest is mag = nearest and min = nearest and mip = linear */
  18192. static readonly NEAREST_SAMPLINGMODE: number;
  18193. /** nearest is mag = nearest and min = nearest and mip = linear */
  18194. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18196. static readonly BILINEAR_SAMPLINGMODE: number;
  18197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18198. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18199. /** Trilinear is mag = linear and min = linear and mip = linear */
  18200. static readonly TRILINEAR_SAMPLINGMODE: number;
  18201. /** Trilinear is mag = linear and min = linear and mip = linear */
  18202. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18203. /** mag = nearest and min = nearest and mip = nearest */
  18204. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18205. /** mag = nearest and min = linear and mip = nearest */
  18206. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18207. /** mag = nearest and min = linear and mip = linear */
  18208. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18209. /** mag = nearest and min = linear and mip = none */
  18210. static readonly NEAREST_LINEAR: number;
  18211. /** mag = nearest and min = nearest and mip = none */
  18212. static readonly NEAREST_NEAREST: number;
  18213. /** mag = linear and min = nearest and mip = nearest */
  18214. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18215. /** mag = linear and min = nearest and mip = linear */
  18216. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18217. /** mag = linear and min = linear and mip = none */
  18218. static readonly LINEAR_LINEAR: number;
  18219. /** mag = linear and min = nearest and mip = none */
  18220. static readonly LINEAR_NEAREST: number;
  18221. /** Explicit coordinates mode */
  18222. static readonly EXPLICIT_MODE: number;
  18223. /** Spherical coordinates mode */
  18224. static readonly SPHERICAL_MODE: number;
  18225. /** Planar coordinates mode */
  18226. static readonly PLANAR_MODE: number;
  18227. /** Cubic coordinates mode */
  18228. static readonly CUBIC_MODE: number;
  18229. /** Projection coordinates mode */
  18230. static readonly PROJECTION_MODE: number;
  18231. /** Inverse Cubic coordinates mode */
  18232. static readonly SKYBOX_MODE: number;
  18233. /** Inverse Cubic coordinates mode */
  18234. static readonly INVCUBIC_MODE: number;
  18235. /** Equirectangular coordinates mode */
  18236. static readonly EQUIRECTANGULAR_MODE: number;
  18237. /** Equirectangular Fixed coordinates mode */
  18238. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18239. /** Equirectangular Fixed Mirrored coordinates mode */
  18240. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18241. /** Texture is not repeating outside of 0..1 UVs */
  18242. static readonly CLAMP_ADDRESSMODE: number;
  18243. /** Texture is repeating outside of 0..1 UVs */
  18244. static readonly WRAP_ADDRESSMODE: number;
  18245. /** Texture is repeating and mirrored */
  18246. static readonly MIRROR_ADDRESSMODE: number;
  18247. /**
  18248. * 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
  18249. */
  18250. static UseSerializedUrlIfAny: boolean;
  18251. /**
  18252. * Define the url of the texture.
  18253. */
  18254. url: Nullable<string>;
  18255. /**
  18256. * Define an offset on the texture to offset the u coordinates of the UVs
  18257. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18258. */
  18259. uOffset: number;
  18260. /**
  18261. * Define an offset on the texture to offset the v coordinates of the UVs
  18262. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18263. */
  18264. vOffset: number;
  18265. /**
  18266. * Define an offset on the texture to scale the u coordinates of the UVs
  18267. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18268. */
  18269. uScale: number;
  18270. /**
  18271. * Define an offset on the texture to scale the v coordinates of the UVs
  18272. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18273. */
  18274. vScale: number;
  18275. /**
  18276. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18277. * @see http://doc.babylonjs.com/how_to/more_materials
  18278. */
  18279. uAng: number;
  18280. /**
  18281. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18282. * @see http://doc.babylonjs.com/how_to/more_materials
  18283. */
  18284. vAng: number;
  18285. /**
  18286. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18287. * @see http://doc.babylonjs.com/how_to/more_materials
  18288. */
  18289. wAng: number;
  18290. /**
  18291. * Defines the center of rotation (U)
  18292. */
  18293. uRotationCenter: number;
  18294. /**
  18295. * Defines the center of rotation (V)
  18296. */
  18297. vRotationCenter: number;
  18298. /**
  18299. * Defines the center of rotation (W)
  18300. */
  18301. wRotationCenter: number;
  18302. /**
  18303. * Are mip maps generated for this texture or not.
  18304. */
  18305. readonly noMipmap: boolean;
  18306. /**
  18307. * List of inspectable custom properties (used by the Inspector)
  18308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18309. */
  18310. inspectableCustomProperties: IInspectable[];
  18311. private _noMipmap;
  18312. /** @hidden */
  18313. _invertY: boolean;
  18314. private _rowGenerationMatrix;
  18315. private _cachedTextureMatrix;
  18316. private _projectionModeMatrix;
  18317. private _t0;
  18318. private _t1;
  18319. private _t2;
  18320. private _cachedUOffset;
  18321. private _cachedVOffset;
  18322. private _cachedUScale;
  18323. private _cachedVScale;
  18324. private _cachedUAng;
  18325. private _cachedVAng;
  18326. private _cachedWAng;
  18327. private _cachedProjectionMatrixId;
  18328. private _cachedCoordinatesMode;
  18329. /** @hidden */
  18330. protected _initialSamplingMode: number;
  18331. /** @hidden */
  18332. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18333. private _deleteBuffer;
  18334. protected _format: Nullable<number>;
  18335. private _delayedOnLoad;
  18336. private _delayedOnError;
  18337. /**
  18338. * Observable triggered once the texture has been loaded.
  18339. */
  18340. onLoadObservable: Observable<Texture>;
  18341. protected _isBlocking: boolean;
  18342. /**
  18343. * Is the texture preventing material to render while loading.
  18344. * If false, a default texture will be used instead of the loading one during the preparation step.
  18345. */
  18346. isBlocking: boolean;
  18347. /**
  18348. * Get the current sampling mode associated with the texture.
  18349. */
  18350. readonly samplingMode: number;
  18351. /**
  18352. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18353. */
  18354. readonly invertY: boolean;
  18355. /**
  18356. * Instantiates a new texture.
  18357. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18358. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18359. * @param url define the url of the picture to load as a texture
  18360. * @param scene define the scene the texture will belong to
  18361. * @param noMipmap define if the texture will require mip maps or not
  18362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18364. * @param onLoad define a callback triggered when the texture has been loaded
  18365. * @param onError define a callback triggered when an error occurred during the loading session
  18366. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18367. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18368. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18369. */
  18370. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18371. /**
  18372. * Update the url (and optional buffer) of this texture if url was null during construction.
  18373. * @param url the url of the texture
  18374. * @param buffer the buffer of the texture (defaults to null)
  18375. * @param onLoad callback called when the texture is loaded (defaults to null)
  18376. */
  18377. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18378. /**
  18379. * Finish the loading sequence of a texture flagged as delayed load.
  18380. * @hidden
  18381. */
  18382. delayLoad(): void;
  18383. private _prepareRowForTextureGeneration;
  18384. /**
  18385. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18386. * @returns the transform matrix of the texture.
  18387. */
  18388. getTextureMatrix(): Matrix;
  18389. /**
  18390. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18391. * @returns The reflection texture transform
  18392. */
  18393. getReflectionTextureMatrix(): Matrix;
  18394. /**
  18395. * Clones the texture.
  18396. * @returns the cloned texture
  18397. */
  18398. clone(): Texture;
  18399. /**
  18400. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18401. * @returns The JSON representation of the texture
  18402. */
  18403. serialize(): any;
  18404. /**
  18405. * Get the current class name of the texture useful for serialization or dynamic coding.
  18406. * @returns "Texture"
  18407. */
  18408. getClassName(): string;
  18409. /**
  18410. * Dispose the texture and release its associated resources.
  18411. */
  18412. dispose(): void;
  18413. /**
  18414. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18415. * @param parsedTexture Define the JSON representation of the texture
  18416. * @param scene Define the scene the parsed texture should be instantiated in
  18417. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18418. * @returns The parsed texture if successful
  18419. */
  18420. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18421. /**
  18422. * Creates a texture from its base 64 representation.
  18423. * @param data Define the base64 payload without the data: prefix
  18424. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18425. * @param scene Define the scene the texture should belong to
  18426. * @param noMipmap Forces the texture to not create mip map information if true
  18427. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18428. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18429. * @param onLoad define a callback triggered when the texture has been loaded
  18430. * @param onError define a callback triggered when an error occurred during the loading session
  18431. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18432. * @returns the created texture
  18433. */
  18434. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18435. /**
  18436. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18437. * @param data Define the base64 payload without the data: prefix
  18438. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18439. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18440. * @param scene Define the scene the texture should belong to
  18441. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18442. * @param noMipmap Forces the texture to not create mip map information if true
  18443. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18444. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18445. * @param onLoad define a callback triggered when the texture has been loaded
  18446. * @param onError define a callback triggered when an error occurred during the loading session
  18447. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18448. * @returns the created texture
  18449. */
  18450. 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;
  18451. }
  18452. }
  18453. declare module "babylonjs/Materials/Textures/rawTexture" {
  18454. import { Scene } from "babylonjs/scene";
  18455. import { Texture } from "babylonjs/Materials/Textures/texture";
  18456. /**
  18457. * Raw texture can help creating a texture directly from an array of data.
  18458. * This can be super useful if you either get the data from an uncompressed source or
  18459. * if you wish to create your texture pixel by pixel.
  18460. */
  18461. export class RawTexture extends Texture {
  18462. /**
  18463. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18464. */
  18465. format: number;
  18466. private _engine;
  18467. /**
  18468. * Instantiates a new RawTexture.
  18469. * Raw texture can help creating a texture directly from an array of data.
  18470. * This can be super useful if you either get the data from an uncompressed source or
  18471. * if you wish to create your texture pixel by pixel.
  18472. * @param data define the array of data to use to create the texture
  18473. * @param width define the width of the texture
  18474. * @param height define the height of the texture
  18475. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18476. * @param scene define the scene the texture belongs to
  18477. * @param generateMipMaps define whether mip maps should be generated or not
  18478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18480. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18481. */
  18482. constructor(data: ArrayBufferView, width: number, height: number,
  18483. /**
  18484. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18485. */
  18486. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18487. /**
  18488. * Updates the texture underlying data.
  18489. * @param data Define the new data of the texture
  18490. */
  18491. update(data: ArrayBufferView): void;
  18492. /**
  18493. * Creates a luminance texture from some data.
  18494. * @param data Define the texture data
  18495. * @param width Define the width of the texture
  18496. * @param height Define the height of the texture
  18497. * @param scene Define the scene the texture belongs to
  18498. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18499. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18500. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18501. * @returns the luminance texture
  18502. */
  18503. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18504. /**
  18505. * Creates a luminance alpha texture from some data.
  18506. * @param data Define the texture data
  18507. * @param width Define the width of the texture
  18508. * @param height Define the height of the texture
  18509. * @param scene Define the scene the texture belongs to
  18510. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18511. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18512. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18513. * @returns the luminance alpha texture
  18514. */
  18515. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18516. /**
  18517. * Creates an alpha texture from some data.
  18518. * @param data Define the texture data
  18519. * @param width Define the width of the texture
  18520. * @param height Define the height of the texture
  18521. * @param scene Define the scene the texture belongs to
  18522. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18523. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18524. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18525. * @returns the alpha texture
  18526. */
  18527. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18528. /**
  18529. * Creates a RGB texture from some data.
  18530. * @param data Define the texture data
  18531. * @param width Define the width of the texture
  18532. * @param height Define the height of the texture
  18533. * @param scene Define the scene the texture belongs to
  18534. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18535. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18536. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18537. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18538. * @returns the RGB alpha texture
  18539. */
  18540. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18541. /**
  18542. * Creates a RGBA texture from some data.
  18543. * @param data Define the texture data
  18544. * @param width Define the width of the texture
  18545. * @param height Define the height of the texture
  18546. * @param scene Define the scene the texture belongs to
  18547. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18548. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18549. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18550. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18551. * @returns the RGBA texture
  18552. */
  18553. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18554. /**
  18555. * Creates a R texture from some data.
  18556. * @param data Define the texture data
  18557. * @param width Define the width of the texture
  18558. * @param height Define the height of the texture
  18559. * @param scene Define the scene the texture belongs to
  18560. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18563. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18564. * @returns the R texture
  18565. */
  18566. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18567. }
  18568. }
  18569. declare module "babylonjs/Animations/runtimeAnimation" {
  18570. import { Animation } from "babylonjs/Animations/animation";
  18571. import { Animatable } from "babylonjs/Animations/animatable";
  18572. import { Scene } from "babylonjs/scene";
  18573. /**
  18574. * Defines a runtime animation
  18575. */
  18576. export class RuntimeAnimation {
  18577. private _events;
  18578. /**
  18579. * The current frame of the runtime animation
  18580. */
  18581. private _currentFrame;
  18582. /**
  18583. * The animation used by the runtime animation
  18584. */
  18585. private _animation;
  18586. /**
  18587. * The target of the runtime animation
  18588. */
  18589. private _target;
  18590. /**
  18591. * The initiating animatable
  18592. */
  18593. private _host;
  18594. /**
  18595. * The original value of the runtime animation
  18596. */
  18597. private _originalValue;
  18598. /**
  18599. * The original blend value of the runtime animation
  18600. */
  18601. private _originalBlendValue;
  18602. /**
  18603. * The offsets cache of the runtime animation
  18604. */
  18605. private _offsetsCache;
  18606. /**
  18607. * The high limits cache of the runtime animation
  18608. */
  18609. private _highLimitsCache;
  18610. /**
  18611. * Specifies if the runtime animation has been stopped
  18612. */
  18613. private _stopped;
  18614. /**
  18615. * The blending factor of the runtime animation
  18616. */
  18617. private _blendingFactor;
  18618. /**
  18619. * The BabylonJS scene
  18620. */
  18621. private _scene;
  18622. /**
  18623. * The current value of the runtime animation
  18624. */
  18625. private _currentValue;
  18626. /** @hidden */
  18627. _workValue: any;
  18628. /**
  18629. * The active target of the runtime animation
  18630. */
  18631. private _activeTarget;
  18632. /**
  18633. * The target path of the runtime animation
  18634. */
  18635. private _targetPath;
  18636. /**
  18637. * The weight of the runtime animation
  18638. */
  18639. private _weight;
  18640. /**
  18641. * The ratio offset of the runtime animation
  18642. */
  18643. private _ratioOffset;
  18644. /**
  18645. * The previous delay of the runtime animation
  18646. */
  18647. private _previousDelay;
  18648. /**
  18649. * The previous ratio of the runtime animation
  18650. */
  18651. private _previousRatio;
  18652. /**
  18653. * Gets the current frame of the runtime animation
  18654. */
  18655. readonly currentFrame: number;
  18656. /**
  18657. * Gets the weight of the runtime animation
  18658. */
  18659. readonly weight: number;
  18660. /**
  18661. * Gets the current value of the runtime animation
  18662. */
  18663. readonly currentValue: any;
  18664. /**
  18665. * Gets the target path of the runtime animation
  18666. */
  18667. readonly targetPath: string;
  18668. /**
  18669. * Gets the actual target of the runtime animation
  18670. */
  18671. readonly target: any;
  18672. /**
  18673. * Create a new RuntimeAnimation object
  18674. * @param target defines the target of the animation
  18675. * @param animation defines the source animation object
  18676. * @param scene defines the hosting scene
  18677. * @param host defines the initiating Animatable
  18678. */
  18679. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18680. /**
  18681. * Gets the animation from the runtime animation
  18682. */
  18683. readonly animation: Animation;
  18684. /**
  18685. * Resets the runtime animation to the beginning
  18686. * @param restoreOriginal defines whether to restore the target property to the original value
  18687. */
  18688. reset(restoreOriginal?: boolean): void;
  18689. /**
  18690. * Specifies if the runtime animation is stopped
  18691. * @returns Boolean specifying if the runtime animation is stopped
  18692. */
  18693. isStopped(): boolean;
  18694. /**
  18695. * Disposes of the runtime animation
  18696. */
  18697. dispose(): void;
  18698. /**
  18699. * Interpolates the animation from the current frame
  18700. * @param currentFrame The frame to interpolate the animation to
  18701. * @param repeatCount The number of times that the animation should loop
  18702. * @param loopMode The type of looping mode to use
  18703. * @param offsetValue Animation offset value
  18704. * @param highLimitValue The high limit value
  18705. * @returns The interpolated value
  18706. */
  18707. private _interpolate;
  18708. /**
  18709. * Apply the interpolated value to the target
  18710. * @param currentValue defines the value computed by the animation
  18711. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18712. */
  18713. setValue(currentValue: any, weight?: number): void;
  18714. private _setValue;
  18715. /**
  18716. * Gets the loop pmode of the runtime animation
  18717. * @returns Loop Mode
  18718. */
  18719. private _getCorrectLoopMode;
  18720. /**
  18721. * Move the current animation to a given frame
  18722. * @param frame defines the frame to move to
  18723. */
  18724. goToFrame(frame: number): void;
  18725. /**
  18726. * @hidden Internal use only
  18727. */
  18728. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18729. /**
  18730. * Execute the current animation
  18731. * @param delay defines the delay to add to the current frame
  18732. * @param from defines the lower bound of the animation range
  18733. * @param to defines the upper bound of the animation range
  18734. * @param loop defines if the current animation must loop
  18735. * @param speedRatio defines the current speed ratio
  18736. * @param weight defines the weight of the animation (default is -1 so no weight)
  18737. * @param onLoop optional callback called when animation loops
  18738. * @returns a boolean indicating if the animation is running
  18739. */
  18740. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18741. }
  18742. }
  18743. declare module "babylonjs/Animations/animatable" {
  18744. import { Animation } from "babylonjs/Animations/animation";
  18745. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18746. import { Nullable } from "babylonjs/types";
  18747. import { Observable } from "babylonjs/Misc/observable";
  18748. import { Scene } from "babylonjs/scene";
  18749. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18750. import { Node } from "babylonjs/node";
  18751. /**
  18752. * Class used to store an actual running animation
  18753. */
  18754. export class Animatable {
  18755. /** defines the target object */
  18756. target: any;
  18757. /** defines the starting frame number (default is 0) */
  18758. fromFrame: number;
  18759. /** defines the ending frame number (default is 100) */
  18760. toFrame: number;
  18761. /** defines if the animation must loop (default is false) */
  18762. loopAnimation: boolean;
  18763. /** defines a callback to call when animation ends if it is not looping */
  18764. onAnimationEnd?: (() => void) | null | undefined;
  18765. /** defines a callback to call when animation loops */
  18766. onAnimationLoop?: (() => void) | null | undefined;
  18767. private _localDelayOffset;
  18768. private _pausedDelay;
  18769. private _runtimeAnimations;
  18770. private _paused;
  18771. private _scene;
  18772. private _speedRatio;
  18773. private _weight;
  18774. private _syncRoot;
  18775. /**
  18776. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18777. * This will only apply for non looping animation (default is true)
  18778. */
  18779. disposeOnEnd: boolean;
  18780. /**
  18781. * Gets a boolean indicating if the animation has started
  18782. */
  18783. animationStarted: boolean;
  18784. /**
  18785. * Observer raised when the animation ends
  18786. */
  18787. onAnimationEndObservable: Observable<Animatable>;
  18788. /**
  18789. * Observer raised when the animation loops
  18790. */
  18791. onAnimationLoopObservable: Observable<Animatable>;
  18792. /**
  18793. * Gets the root Animatable used to synchronize and normalize animations
  18794. */
  18795. readonly syncRoot: Animatable;
  18796. /**
  18797. * Gets the current frame of the first RuntimeAnimation
  18798. * Used to synchronize Animatables
  18799. */
  18800. readonly masterFrame: number;
  18801. /**
  18802. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18803. */
  18804. weight: number;
  18805. /**
  18806. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18807. */
  18808. speedRatio: number;
  18809. /**
  18810. * Creates a new Animatable
  18811. * @param scene defines the hosting scene
  18812. * @param target defines the target object
  18813. * @param fromFrame defines the starting frame number (default is 0)
  18814. * @param toFrame defines the ending frame number (default is 100)
  18815. * @param loopAnimation defines if the animation must loop (default is false)
  18816. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18817. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18818. * @param animations defines a group of animation to add to the new Animatable
  18819. * @param onAnimationLoop defines a callback to call when animation loops
  18820. */
  18821. constructor(scene: Scene,
  18822. /** defines the target object */
  18823. target: any,
  18824. /** defines the starting frame number (default is 0) */
  18825. fromFrame?: number,
  18826. /** defines the ending frame number (default is 100) */
  18827. toFrame?: number,
  18828. /** defines if the animation must loop (default is false) */
  18829. loopAnimation?: boolean, speedRatio?: number,
  18830. /** defines a callback to call when animation ends if it is not looping */
  18831. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18832. /** defines a callback to call when animation loops */
  18833. onAnimationLoop?: (() => void) | null | undefined);
  18834. /**
  18835. * Synchronize and normalize current Animatable with a source Animatable
  18836. * This is useful when using animation weights and when animations are not of the same length
  18837. * @param root defines the root Animatable to synchronize with
  18838. * @returns the current Animatable
  18839. */
  18840. syncWith(root: Animatable): Animatable;
  18841. /**
  18842. * Gets the list of runtime animations
  18843. * @returns an array of RuntimeAnimation
  18844. */
  18845. getAnimations(): RuntimeAnimation[];
  18846. /**
  18847. * Adds more animations to the current animatable
  18848. * @param target defines the target of the animations
  18849. * @param animations defines the new animations to add
  18850. */
  18851. appendAnimations(target: any, animations: Animation[]): void;
  18852. /**
  18853. * Gets the source animation for a specific property
  18854. * @param property defines the propertyu to look for
  18855. * @returns null or the source animation for the given property
  18856. */
  18857. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18858. /**
  18859. * Gets the runtime animation for a specific property
  18860. * @param property defines the propertyu to look for
  18861. * @returns null or the runtime animation for the given property
  18862. */
  18863. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18864. /**
  18865. * Resets the animatable to its original state
  18866. */
  18867. reset(): void;
  18868. /**
  18869. * Allows the animatable to blend with current running animations
  18870. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18871. * @param blendingSpeed defines the blending speed to use
  18872. */
  18873. enableBlending(blendingSpeed: number): void;
  18874. /**
  18875. * Disable animation blending
  18876. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18877. */
  18878. disableBlending(): void;
  18879. /**
  18880. * Jump directly to a given frame
  18881. * @param frame defines the frame to jump to
  18882. */
  18883. goToFrame(frame: number): void;
  18884. /**
  18885. * Pause the animation
  18886. */
  18887. pause(): void;
  18888. /**
  18889. * Restart the animation
  18890. */
  18891. restart(): void;
  18892. private _raiseOnAnimationEnd;
  18893. /**
  18894. * Stop and delete the current animation
  18895. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18896. * @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)
  18897. */
  18898. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18899. /**
  18900. * Wait asynchronously for the animation to end
  18901. * @returns a promise which will be fullfilled when the animation ends
  18902. */
  18903. waitAsync(): Promise<Animatable>;
  18904. /** @hidden */
  18905. _animate(delay: number): boolean;
  18906. }
  18907. module "babylonjs/scene" {
  18908. interface Scene {
  18909. /** @hidden */
  18910. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18911. /** @hidden */
  18912. _processLateAnimationBindingsForMatrices(holder: {
  18913. totalWeight: number;
  18914. animations: RuntimeAnimation[];
  18915. originalValue: Matrix;
  18916. }): any;
  18917. /** @hidden */
  18918. _processLateAnimationBindingsForQuaternions(holder: {
  18919. totalWeight: number;
  18920. animations: RuntimeAnimation[];
  18921. originalValue: Quaternion;
  18922. }, refQuaternion: Quaternion): Quaternion;
  18923. /** @hidden */
  18924. _processLateAnimationBindings(): void;
  18925. /**
  18926. * Will start the animation sequence of a given target
  18927. * @param target defines the target
  18928. * @param from defines from which frame should animation start
  18929. * @param to defines until which frame should animation run.
  18930. * @param weight defines the weight to apply to the animation (1.0 by default)
  18931. * @param loop defines if the animation loops
  18932. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18933. * @param onAnimationEnd defines the function to be executed when the animation ends
  18934. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18935. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18936. * @param onAnimationLoop defines the callback to call when an animation loops
  18937. * @returns the animatable object created for this animation
  18938. */
  18939. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18940. /**
  18941. * Will start the animation sequence of a given target
  18942. * @param target defines the target
  18943. * @param from defines from which frame should animation start
  18944. * @param to defines until which frame should animation run.
  18945. * @param loop defines if the animation loops
  18946. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18947. * @param onAnimationEnd defines the function to be executed when the animation ends
  18948. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18949. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18950. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18951. * @param onAnimationLoop defines the callback to call when an animation loops
  18952. * @returns the animatable object created for this animation
  18953. */
  18954. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18955. /**
  18956. * Will start the animation sequence of a given target and its hierarchy
  18957. * @param target defines the target
  18958. * @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.
  18959. * @param from defines from which frame should animation start
  18960. * @param to defines until which frame should animation run.
  18961. * @param loop defines if the animation loops
  18962. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18963. * @param onAnimationEnd defines the function to be executed when the animation ends
  18964. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18965. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18966. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18967. * @param onAnimationLoop defines the callback to call when an animation loops
  18968. * @returns the list of created animatables
  18969. */
  18970. 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[];
  18971. /**
  18972. * Begin a new animation on a given node
  18973. * @param target defines the target where the animation will take place
  18974. * @param animations defines the list of animations to start
  18975. * @param from defines the initial value
  18976. * @param to defines the final value
  18977. * @param loop defines if you want animation to loop (off by default)
  18978. * @param speedRatio defines the speed ratio to apply to all animations
  18979. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18980. * @param onAnimationLoop defines the callback to call when an animation loops
  18981. * @returns the list of created animatables
  18982. */
  18983. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18984. /**
  18985. * Begin a new animation on a given node and its hierarchy
  18986. * @param target defines the root node where the animation will take place
  18987. * @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.
  18988. * @param animations defines the list of animations to start
  18989. * @param from defines the initial value
  18990. * @param to defines the final value
  18991. * @param loop defines if you want animation to loop (off by default)
  18992. * @param speedRatio defines the speed ratio to apply to all animations
  18993. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18994. * @param onAnimationLoop defines the callback to call when an animation loops
  18995. * @returns the list of animatables created for all nodes
  18996. */
  18997. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18998. /**
  18999. * Gets the animatable associated with a specific target
  19000. * @param target defines the target of the animatable
  19001. * @returns the required animatable if found
  19002. */
  19003. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19004. /**
  19005. * Gets all animatables associated with a given target
  19006. * @param target defines the target to look animatables for
  19007. * @returns an array of Animatables
  19008. */
  19009. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19010. /**
  19011. * Will stop the animation of the given target
  19012. * @param target - the target
  19013. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19014. * @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)
  19015. */
  19016. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19017. /**
  19018. * Stops and removes all animations that have been applied to the scene
  19019. */
  19020. stopAllAnimations(): void;
  19021. }
  19022. }
  19023. module "babylonjs/Bones/bone" {
  19024. interface Bone {
  19025. /**
  19026. * Copy an animation range from another bone
  19027. * @param source defines the source bone
  19028. * @param rangeName defines the range name to copy
  19029. * @param frameOffset defines the frame offset
  19030. * @param rescaleAsRequired defines if rescaling must be applied if required
  19031. * @param skelDimensionsRatio defines the scaling ratio
  19032. * @returns true if operation was successful
  19033. */
  19034. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19035. }
  19036. }
  19037. }
  19038. declare module "babylonjs/Bones/skeleton" {
  19039. import { Bone } from "babylonjs/Bones/bone";
  19040. import { IAnimatable } from "babylonjs/Misc/tools";
  19041. import { Observable } from "babylonjs/Misc/observable";
  19042. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19043. import { Scene } from "babylonjs/scene";
  19044. import { Nullable } from "babylonjs/types";
  19045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19046. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19047. import { Animatable } from "babylonjs/Animations/animatable";
  19048. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19049. import { Animation } from "babylonjs/Animations/animation";
  19050. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19051. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19052. /**
  19053. * Class used to handle skinning animations
  19054. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19055. */
  19056. export class Skeleton implements IAnimatable {
  19057. /** defines the skeleton name */
  19058. name: string;
  19059. /** defines the skeleton Id */
  19060. id: string;
  19061. /**
  19062. * Defines the list of child bones
  19063. */
  19064. bones: Bone[];
  19065. /**
  19066. * Defines an estimate of the dimension of the skeleton at rest
  19067. */
  19068. dimensionsAtRest: Vector3;
  19069. /**
  19070. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19071. */
  19072. needInitialSkinMatrix: boolean;
  19073. /**
  19074. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19075. */
  19076. overrideMesh: Nullable<AbstractMesh>;
  19077. /**
  19078. * Gets the list of animations attached to this skeleton
  19079. */
  19080. animations: Array<Animation>;
  19081. private _scene;
  19082. private _isDirty;
  19083. private _transformMatrices;
  19084. private _transformMatrixTexture;
  19085. private _meshesWithPoseMatrix;
  19086. private _animatables;
  19087. private _identity;
  19088. private _synchronizedWithMesh;
  19089. private _ranges;
  19090. private _lastAbsoluteTransformsUpdateId;
  19091. private _canUseTextureForBones;
  19092. private _uniqueId;
  19093. /** @hidden */
  19094. _numBonesWithLinkedTransformNode: number;
  19095. /**
  19096. * Specifies if the skeleton should be serialized
  19097. */
  19098. doNotSerialize: boolean;
  19099. private _useTextureToStoreBoneMatrices;
  19100. /**
  19101. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19102. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19103. */
  19104. useTextureToStoreBoneMatrices: boolean;
  19105. private _animationPropertiesOverride;
  19106. /**
  19107. * Gets or sets the animation properties override
  19108. */
  19109. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19110. /**
  19111. * List of inspectable custom properties (used by the Inspector)
  19112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19113. */
  19114. inspectableCustomProperties: IInspectable[];
  19115. /**
  19116. * An observable triggered before computing the skeleton's matrices
  19117. */
  19118. onBeforeComputeObservable: Observable<Skeleton>;
  19119. /**
  19120. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19121. */
  19122. readonly isUsingTextureForMatrices: boolean;
  19123. /**
  19124. * Gets the unique ID of this skeleton
  19125. */
  19126. readonly uniqueId: number;
  19127. /**
  19128. * Creates a new skeleton
  19129. * @param name defines the skeleton name
  19130. * @param id defines the skeleton Id
  19131. * @param scene defines the hosting scene
  19132. */
  19133. constructor(
  19134. /** defines the skeleton name */
  19135. name: string,
  19136. /** defines the skeleton Id */
  19137. id: string, scene: Scene);
  19138. /**
  19139. * Gets the current object class name.
  19140. * @return the class name
  19141. */
  19142. getClassName(): string;
  19143. /**
  19144. * Returns an array containing the root bones
  19145. * @returns an array containing the root bones
  19146. */
  19147. getChildren(): Array<Bone>;
  19148. /**
  19149. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19150. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19151. * @returns a Float32Array containing matrices data
  19152. */
  19153. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19154. /**
  19155. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19156. * @returns a raw texture containing the data
  19157. */
  19158. getTransformMatrixTexture(): Nullable<RawTexture>;
  19159. /**
  19160. * Gets the current hosting scene
  19161. * @returns a scene object
  19162. */
  19163. getScene(): Scene;
  19164. /**
  19165. * Gets a string representing the current skeleton data
  19166. * @param fullDetails defines a boolean indicating if we want a verbose version
  19167. * @returns a string representing the current skeleton data
  19168. */
  19169. toString(fullDetails?: boolean): string;
  19170. /**
  19171. * Get bone's index searching by name
  19172. * @param name defines bone's name to search for
  19173. * @return the indice of the bone. Returns -1 if not found
  19174. */
  19175. getBoneIndexByName(name: string): number;
  19176. /**
  19177. * Creater a new animation range
  19178. * @param name defines the name of the range
  19179. * @param from defines the start key
  19180. * @param to defines the end key
  19181. */
  19182. createAnimationRange(name: string, from: number, to: number): void;
  19183. /**
  19184. * Delete a specific animation range
  19185. * @param name defines the name of the range
  19186. * @param deleteFrames defines if frames must be removed as well
  19187. */
  19188. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19189. /**
  19190. * Gets a specific animation range
  19191. * @param name defines the name of the range to look for
  19192. * @returns the requested animation range or null if not found
  19193. */
  19194. getAnimationRange(name: string): Nullable<AnimationRange>;
  19195. /**
  19196. * Gets the list of all animation ranges defined on this skeleton
  19197. * @returns an array
  19198. */
  19199. getAnimationRanges(): Nullable<AnimationRange>[];
  19200. /**
  19201. * Copy animation range from a source skeleton.
  19202. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19203. * @param source defines the source skeleton
  19204. * @param name defines the name of the range to copy
  19205. * @param rescaleAsRequired defines if rescaling must be applied if required
  19206. * @returns true if operation was successful
  19207. */
  19208. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19209. /**
  19210. * Forces the skeleton to go to rest pose
  19211. */
  19212. returnToRest(): void;
  19213. private _getHighestAnimationFrame;
  19214. /**
  19215. * Begin a specific animation range
  19216. * @param name defines the name of the range to start
  19217. * @param loop defines if looping must be turned on (false by default)
  19218. * @param speedRatio defines the speed ratio to apply (1 by default)
  19219. * @param onAnimationEnd defines a callback which will be called when animation will end
  19220. * @returns a new animatable
  19221. */
  19222. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19223. /** @hidden */
  19224. _markAsDirty(): void;
  19225. /** @hidden */
  19226. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19227. /** @hidden */
  19228. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19229. private _computeTransformMatrices;
  19230. /**
  19231. * Build all resources required to render a skeleton
  19232. */
  19233. prepare(): void;
  19234. /**
  19235. * Gets the list of animatables currently running for this skeleton
  19236. * @returns an array of animatables
  19237. */
  19238. getAnimatables(): IAnimatable[];
  19239. /**
  19240. * Clone the current skeleton
  19241. * @param name defines the name of the new skeleton
  19242. * @param id defines the id of the enw skeleton
  19243. * @returns the new skeleton
  19244. */
  19245. clone(name: string, id: string): Skeleton;
  19246. /**
  19247. * Enable animation blending for this skeleton
  19248. * @param blendingSpeed defines the blending speed to apply
  19249. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19250. */
  19251. enableBlending(blendingSpeed?: number): void;
  19252. /**
  19253. * Releases all resources associated with the current skeleton
  19254. */
  19255. dispose(): void;
  19256. /**
  19257. * Serialize the skeleton in a JSON object
  19258. * @returns a JSON object
  19259. */
  19260. serialize(): any;
  19261. /**
  19262. * Creates a new skeleton from serialized data
  19263. * @param parsedSkeleton defines the serialized data
  19264. * @param scene defines the hosting scene
  19265. * @returns a new skeleton
  19266. */
  19267. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19268. /**
  19269. * Compute all node absolute transforms
  19270. * @param forceUpdate defines if computation must be done even if cache is up to date
  19271. */
  19272. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19273. /**
  19274. * Gets the root pose matrix
  19275. * @returns a matrix
  19276. */
  19277. getPoseMatrix(): Nullable<Matrix>;
  19278. /**
  19279. * Sorts bones per internal index
  19280. */
  19281. sortBones(): void;
  19282. private _sortBones;
  19283. }
  19284. }
  19285. declare module "babylonjs/Morph/morphTarget" {
  19286. import { IAnimatable } from "babylonjs/Misc/tools";
  19287. import { Observable } from "babylonjs/Misc/observable";
  19288. import { Nullable, FloatArray } from "babylonjs/types";
  19289. import { Scene } from "babylonjs/scene";
  19290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19291. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19292. /**
  19293. * Defines a target to use with MorphTargetManager
  19294. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19295. */
  19296. export class MorphTarget implements IAnimatable {
  19297. /** defines the name of the target */
  19298. name: string;
  19299. /**
  19300. * Gets or sets the list of animations
  19301. */
  19302. animations: import("babylonjs/Animations/animation").Animation[];
  19303. private _scene;
  19304. private _positions;
  19305. private _normals;
  19306. private _tangents;
  19307. private _influence;
  19308. /**
  19309. * Observable raised when the influence changes
  19310. */
  19311. onInfluenceChanged: Observable<boolean>;
  19312. /** @hidden */
  19313. _onDataLayoutChanged: Observable<void>;
  19314. /**
  19315. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19316. */
  19317. influence: number;
  19318. /**
  19319. * Gets or sets the id of the morph Target
  19320. */
  19321. id: string;
  19322. private _animationPropertiesOverride;
  19323. /**
  19324. * Gets or sets the animation properties override
  19325. */
  19326. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19327. /**
  19328. * Creates a new MorphTarget
  19329. * @param name defines the name of the target
  19330. * @param influence defines the influence to use
  19331. * @param scene defines the scene the morphtarget belongs to
  19332. */
  19333. constructor(
  19334. /** defines the name of the target */
  19335. name: string, influence?: number, scene?: Nullable<Scene>);
  19336. /**
  19337. * Gets a boolean defining if the target contains position data
  19338. */
  19339. readonly hasPositions: boolean;
  19340. /**
  19341. * Gets a boolean defining if the target contains normal data
  19342. */
  19343. readonly hasNormals: boolean;
  19344. /**
  19345. * Gets a boolean defining if the target contains tangent data
  19346. */
  19347. readonly hasTangents: boolean;
  19348. /**
  19349. * Affects position data to this target
  19350. * @param data defines the position data to use
  19351. */
  19352. setPositions(data: Nullable<FloatArray>): void;
  19353. /**
  19354. * Gets the position data stored in this target
  19355. * @returns a FloatArray containing the position data (or null if not present)
  19356. */
  19357. getPositions(): Nullable<FloatArray>;
  19358. /**
  19359. * Affects normal data to this target
  19360. * @param data defines the normal data to use
  19361. */
  19362. setNormals(data: Nullable<FloatArray>): void;
  19363. /**
  19364. * Gets the normal data stored in this target
  19365. * @returns a FloatArray containing the normal data (or null if not present)
  19366. */
  19367. getNormals(): Nullable<FloatArray>;
  19368. /**
  19369. * Affects tangent data to this target
  19370. * @param data defines the tangent data to use
  19371. */
  19372. setTangents(data: Nullable<FloatArray>): void;
  19373. /**
  19374. * Gets the tangent data stored in this target
  19375. * @returns a FloatArray containing the tangent data (or null if not present)
  19376. */
  19377. getTangents(): Nullable<FloatArray>;
  19378. /**
  19379. * Serializes the current target into a Serialization object
  19380. * @returns the serialized object
  19381. */
  19382. serialize(): any;
  19383. /**
  19384. * Returns the string "MorphTarget"
  19385. * @returns "MorphTarget"
  19386. */
  19387. getClassName(): string;
  19388. /**
  19389. * Creates a new target from serialized data
  19390. * @param serializationObject defines the serialized data to use
  19391. * @returns a new MorphTarget
  19392. */
  19393. static Parse(serializationObject: any): MorphTarget;
  19394. /**
  19395. * Creates a MorphTarget from mesh data
  19396. * @param mesh defines the source mesh
  19397. * @param name defines the name to use for the new target
  19398. * @param influence defines the influence to attach to the target
  19399. * @returns a new MorphTarget
  19400. */
  19401. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19402. }
  19403. }
  19404. declare module "babylonjs/Morph/morphTargetManager" {
  19405. import { Nullable } from "babylonjs/types";
  19406. import { Scene } from "babylonjs/scene";
  19407. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19408. /**
  19409. * This class is used to deform meshes using morphing between different targets
  19410. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19411. */
  19412. export class MorphTargetManager {
  19413. private _targets;
  19414. private _targetInfluenceChangedObservers;
  19415. private _targetDataLayoutChangedObservers;
  19416. private _activeTargets;
  19417. private _scene;
  19418. private _influences;
  19419. private _supportsNormals;
  19420. private _supportsTangents;
  19421. private _vertexCount;
  19422. private _uniqueId;
  19423. private _tempInfluences;
  19424. /**
  19425. * Creates a new MorphTargetManager
  19426. * @param scene defines the current scene
  19427. */
  19428. constructor(scene?: Nullable<Scene>);
  19429. /**
  19430. * Gets the unique ID of this manager
  19431. */
  19432. readonly uniqueId: number;
  19433. /**
  19434. * Gets the number of vertices handled by this manager
  19435. */
  19436. readonly vertexCount: number;
  19437. /**
  19438. * Gets a boolean indicating if this manager supports morphing of normals
  19439. */
  19440. readonly supportsNormals: boolean;
  19441. /**
  19442. * Gets a boolean indicating if this manager supports morphing of tangents
  19443. */
  19444. readonly supportsTangents: boolean;
  19445. /**
  19446. * Gets the number of targets stored in this manager
  19447. */
  19448. readonly numTargets: number;
  19449. /**
  19450. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19451. */
  19452. readonly numInfluencers: number;
  19453. /**
  19454. * Gets the list of influences (one per target)
  19455. */
  19456. readonly influences: Float32Array;
  19457. /**
  19458. * Gets the active target at specified index. An active target is a target with an influence > 0
  19459. * @param index defines the index to check
  19460. * @returns the requested target
  19461. */
  19462. getActiveTarget(index: number): MorphTarget;
  19463. /**
  19464. * Gets the target at specified index
  19465. * @param index defines the index to check
  19466. * @returns the requested target
  19467. */
  19468. getTarget(index: number): MorphTarget;
  19469. /**
  19470. * Add a new target to this manager
  19471. * @param target defines the target to add
  19472. */
  19473. addTarget(target: MorphTarget): void;
  19474. /**
  19475. * Removes a target from the manager
  19476. * @param target defines the target to remove
  19477. */
  19478. removeTarget(target: MorphTarget): void;
  19479. /**
  19480. * Serializes the current manager into a Serialization object
  19481. * @returns the serialized object
  19482. */
  19483. serialize(): any;
  19484. private _syncActiveTargets;
  19485. /**
  19486. * Syncrhonize the targets with all the meshes using this morph target manager
  19487. */
  19488. synchronize(): void;
  19489. /**
  19490. * Creates a new MorphTargetManager from serialized data
  19491. * @param serializationObject defines the serialized data
  19492. * @param scene defines the hosting scene
  19493. * @returns the new MorphTargetManager
  19494. */
  19495. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19496. }
  19497. }
  19498. declare module "babylonjs/Meshes/groundMesh" {
  19499. import { Scene } from "babylonjs/scene";
  19500. import { Vector3 } from "babylonjs/Maths/math";
  19501. import { Mesh } from "babylonjs/Meshes/mesh";
  19502. /**
  19503. * Mesh representing the gorund
  19504. */
  19505. export class GroundMesh extends Mesh {
  19506. /** If octree should be generated */
  19507. generateOctree: boolean;
  19508. private _heightQuads;
  19509. /** @hidden */
  19510. _subdivisionsX: number;
  19511. /** @hidden */
  19512. _subdivisionsY: number;
  19513. /** @hidden */
  19514. _width: number;
  19515. /** @hidden */
  19516. _height: number;
  19517. /** @hidden */
  19518. _minX: number;
  19519. /** @hidden */
  19520. _maxX: number;
  19521. /** @hidden */
  19522. _minZ: number;
  19523. /** @hidden */
  19524. _maxZ: number;
  19525. constructor(name: string, scene: Scene);
  19526. /**
  19527. * "GroundMesh"
  19528. * @returns "GroundMesh"
  19529. */
  19530. getClassName(): string;
  19531. /**
  19532. * The minimum of x and y subdivisions
  19533. */
  19534. readonly subdivisions: number;
  19535. /**
  19536. * X subdivisions
  19537. */
  19538. readonly subdivisionsX: number;
  19539. /**
  19540. * Y subdivisions
  19541. */
  19542. readonly subdivisionsY: number;
  19543. /**
  19544. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19545. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19546. * @param chunksCount the number of subdivisions for x and y
  19547. * @param octreeBlocksSize (Default: 32)
  19548. */
  19549. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19550. /**
  19551. * Returns a height (y) value in the Worl system :
  19552. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19553. * @param x x coordinate
  19554. * @param z z coordinate
  19555. * @returns the ground y position if (x, z) are outside the ground surface.
  19556. */
  19557. getHeightAtCoordinates(x: number, z: number): number;
  19558. /**
  19559. * Returns a normalized vector (Vector3) orthogonal to the ground
  19560. * at the ground coordinates (x, z) expressed in the World system.
  19561. * @param x x coordinate
  19562. * @param z z coordinate
  19563. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19564. */
  19565. getNormalAtCoordinates(x: number, z: number): Vector3;
  19566. /**
  19567. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19568. * at the ground coordinates (x, z) expressed in the World system.
  19569. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19570. * @param x x coordinate
  19571. * @param z z coordinate
  19572. * @param ref vector to store the result
  19573. * @returns the GroundMesh.
  19574. */
  19575. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19576. /**
  19577. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19578. * if the ground has been updated.
  19579. * This can be used in the render loop.
  19580. * @returns the GroundMesh.
  19581. */
  19582. updateCoordinateHeights(): GroundMesh;
  19583. private _getFacetAt;
  19584. private _initHeightQuads;
  19585. private _computeHeightQuads;
  19586. /**
  19587. * Serializes this ground mesh
  19588. * @param serializationObject object to write serialization to
  19589. */
  19590. serialize(serializationObject: any): void;
  19591. /**
  19592. * Parses a serialized ground mesh
  19593. * @param parsedMesh the serialized mesh
  19594. * @param scene the scene to create the ground mesh in
  19595. * @returns the created ground mesh
  19596. */
  19597. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19598. }
  19599. }
  19600. declare module "babylonjs/Physics/physicsJoint" {
  19601. import { Vector3 } from "babylonjs/Maths/math";
  19602. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19603. /**
  19604. * Interface for Physics-Joint data
  19605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19606. */
  19607. export interface PhysicsJointData {
  19608. /**
  19609. * The main pivot of the joint
  19610. */
  19611. mainPivot?: Vector3;
  19612. /**
  19613. * The connected pivot of the joint
  19614. */
  19615. connectedPivot?: Vector3;
  19616. /**
  19617. * The main axis of the joint
  19618. */
  19619. mainAxis?: Vector3;
  19620. /**
  19621. * The connected axis of the joint
  19622. */
  19623. connectedAxis?: Vector3;
  19624. /**
  19625. * The collision of the joint
  19626. */
  19627. collision?: boolean;
  19628. /**
  19629. * Native Oimo/Cannon/Energy data
  19630. */
  19631. nativeParams?: any;
  19632. }
  19633. /**
  19634. * This is a holder class for the physics joint created by the physics plugin
  19635. * It holds a set of functions to control the underlying joint
  19636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19637. */
  19638. export class PhysicsJoint {
  19639. /**
  19640. * The type of the physics joint
  19641. */
  19642. type: number;
  19643. /**
  19644. * The data for the physics joint
  19645. */
  19646. jointData: PhysicsJointData;
  19647. private _physicsJoint;
  19648. protected _physicsPlugin: IPhysicsEnginePlugin;
  19649. /**
  19650. * Initializes the physics joint
  19651. * @param type The type of the physics joint
  19652. * @param jointData The data for the physics joint
  19653. */
  19654. constructor(
  19655. /**
  19656. * The type of the physics joint
  19657. */
  19658. type: number,
  19659. /**
  19660. * The data for the physics joint
  19661. */
  19662. jointData: PhysicsJointData);
  19663. /**
  19664. * Gets the physics joint
  19665. */
  19666. /**
  19667. * Sets the physics joint
  19668. */
  19669. physicsJoint: any;
  19670. /**
  19671. * Sets the physics plugin
  19672. */
  19673. physicsPlugin: IPhysicsEnginePlugin;
  19674. /**
  19675. * Execute a function that is physics-plugin specific.
  19676. * @param {Function} func the function that will be executed.
  19677. * It accepts two parameters: the physics world and the physics joint
  19678. */
  19679. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19680. /**
  19681. * Distance-Joint type
  19682. */
  19683. static DistanceJoint: number;
  19684. /**
  19685. * Hinge-Joint type
  19686. */
  19687. static HingeJoint: number;
  19688. /**
  19689. * Ball-and-Socket joint type
  19690. */
  19691. static BallAndSocketJoint: number;
  19692. /**
  19693. * Wheel-Joint type
  19694. */
  19695. static WheelJoint: number;
  19696. /**
  19697. * Slider-Joint type
  19698. */
  19699. static SliderJoint: number;
  19700. /**
  19701. * Prismatic-Joint type
  19702. */
  19703. static PrismaticJoint: number;
  19704. /**
  19705. * Universal-Joint type
  19706. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19707. */
  19708. static UniversalJoint: number;
  19709. /**
  19710. * Hinge-Joint 2 type
  19711. */
  19712. static Hinge2Joint: number;
  19713. /**
  19714. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19715. */
  19716. static PointToPointJoint: number;
  19717. /**
  19718. * Spring-Joint type
  19719. */
  19720. static SpringJoint: number;
  19721. /**
  19722. * Lock-Joint type
  19723. */
  19724. static LockJoint: number;
  19725. }
  19726. /**
  19727. * A class representing a physics distance joint
  19728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19729. */
  19730. export class DistanceJoint extends PhysicsJoint {
  19731. /**
  19732. *
  19733. * @param jointData The data for the Distance-Joint
  19734. */
  19735. constructor(jointData: DistanceJointData);
  19736. /**
  19737. * Update the predefined distance.
  19738. * @param maxDistance The maximum preferred distance
  19739. * @param minDistance The minimum preferred distance
  19740. */
  19741. updateDistance(maxDistance: number, minDistance?: number): void;
  19742. }
  19743. /**
  19744. * Represents a Motor-Enabled Joint
  19745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19746. */
  19747. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19748. /**
  19749. * Initializes the Motor-Enabled Joint
  19750. * @param type The type of the joint
  19751. * @param jointData The physica joint data for the joint
  19752. */
  19753. constructor(type: number, jointData: PhysicsJointData);
  19754. /**
  19755. * Set the motor values.
  19756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19757. * @param force the force to apply
  19758. * @param maxForce max force for this motor.
  19759. */
  19760. setMotor(force?: number, maxForce?: number): void;
  19761. /**
  19762. * Set the motor's limits.
  19763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19764. * @param upperLimit The upper limit of the motor
  19765. * @param lowerLimit The lower limit of the motor
  19766. */
  19767. setLimit(upperLimit: number, lowerLimit?: number): void;
  19768. }
  19769. /**
  19770. * This class represents a single physics Hinge-Joint
  19771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19772. */
  19773. export class HingeJoint extends MotorEnabledJoint {
  19774. /**
  19775. * Initializes the Hinge-Joint
  19776. * @param jointData The joint data for the Hinge-Joint
  19777. */
  19778. constructor(jointData: PhysicsJointData);
  19779. /**
  19780. * Set the motor values.
  19781. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19782. * @param {number} force the force to apply
  19783. * @param {number} maxForce max force for this motor.
  19784. */
  19785. setMotor(force?: number, maxForce?: number): void;
  19786. /**
  19787. * Set the motor's limits.
  19788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19789. * @param upperLimit The upper limit of the motor
  19790. * @param lowerLimit The lower limit of the motor
  19791. */
  19792. setLimit(upperLimit: number, lowerLimit?: number): void;
  19793. }
  19794. /**
  19795. * This class represents a dual hinge physics joint (same as wheel joint)
  19796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19797. */
  19798. export class Hinge2Joint extends MotorEnabledJoint {
  19799. /**
  19800. * Initializes the Hinge2-Joint
  19801. * @param jointData The joint data for the Hinge2-Joint
  19802. */
  19803. constructor(jointData: PhysicsJointData);
  19804. /**
  19805. * Set the motor values.
  19806. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19807. * @param {number} targetSpeed the speed the motor is to reach
  19808. * @param {number} maxForce max force for this motor.
  19809. * @param {motorIndex} the motor's index, 0 or 1.
  19810. */
  19811. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19812. /**
  19813. * Set the motor limits.
  19814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19815. * @param {number} upperLimit the upper limit
  19816. * @param {number} lowerLimit lower limit
  19817. * @param {motorIndex} the motor's index, 0 or 1.
  19818. */
  19819. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19820. }
  19821. /**
  19822. * Interface for a motor enabled joint
  19823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19824. */
  19825. export interface IMotorEnabledJoint {
  19826. /**
  19827. * Physics joint
  19828. */
  19829. physicsJoint: any;
  19830. /**
  19831. * Sets the motor of the motor-enabled joint
  19832. * @param force The force of the motor
  19833. * @param maxForce The maximum force of the motor
  19834. * @param motorIndex The index of the motor
  19835. */
  19836. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19837. /**
  19838. * Sets the limit of the motor
  19839. * @param upperLimit The upper limit of the motor
  19840. * @param lowerLimit The lower limit of the motor
  19841. * @param motorIndex The index of the motor
  19842. */
  19843. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19844. }
  19845. /**
  19846. * Joint data for a Distance-Joint
  19847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19848. */
  19849. export interface DistanceJointData extends PhysicsJointData {
  19850. /**
  19851. * Max distance the 2 joint objects can be apart
  19852. */
  19853. maxDistance: number;
  19854. }
  19855. /**
  19856. * Joint data from a spring joint
  19857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19858. */
  19859. export interface SpringJointData extends PhysicsJointData {
  19860. /**
  19861. * Length of the spring
  19862. */
  19863. length: number;
  19864. /**
  19865. * Stiffness of the spring
  19866. */
  19867. stiffness: number;
  19868. /**
  19869. * Damping of the spring
  19870. */
  19871. damping: number;
  19872. /** this callback will be called when applying the force to the impostors. */
  19873. forceApplicationCallback: () => void;
  19874. }
  19875. }
  19876. declare module "babylonjs/Physics/physicsRaycastResult" {
  19877. import { Vector3 } from "babylonjs/Maths/math";
  19878. /**
  19879. * Holds the data for the raycast result
  19880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19881. */
  19882. export class PhysicsRaycastResult {
  19883. private _hasHit;
  19884. private _hitDistance;
  19885. private _hitNormalWorld;
  19886. private _hitPointWorld;
  19887. private _rayFromWorld;
  19888. private _rayToWorld;
  19889. /**
  19890. * Gets if there was a hit
  19891. */
  19892. readonly hasHit: boolean;
  19893. /**
  19894. * Gets the distance from the hit
  19895. */
  19896. readonly hitDistance: number;
  19897. /**
  19898. * Gets the hit normal/direction in the world
  19899. */
  19900. readonly hitNormalWorld: Vector3;
  19901. /**
  19902. * Gets the hit point in the world
  19903. */
  19904. readonly hitPointWorld: Vector3;
  19905. /**
  19906. * Gets the ray "start point" of the ray in the world
  19907. */
  19908. readonly rayFromWorld: Vector3;
  19909. /**
  19910. * Gets the ray "end point" of the ray in the world
  19911. */
  19912. readonly rayToWorld: Vector3;
  19913. /**
  19914. * Sets the hit data (normal & point in world space)
  19915. * @param hitNormalWorld defines the normal in world space
  19916. * @param hitPointWorld defines the point in world space
  19917. */
  19918. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19919. /**
  19920. * Sets the distance from the start point to the hit point
  19921. * @param distance
  19922. */
  19923. setHitDistance(distance: number): void;
  19924. /**
  19925. * Calculates the distance manually
  19926. */
  19927. calculateHitDistance(): void;
  19928. /**
  19929. * Resets all the values to default
  19930. * @param from The from point on world space
  19931. * @param to The to point on world space
  19932. */
  19933. reset(from?: Vector3, to?: Vector3): void;
  19934. }
  19935. /**
  19936. * Interface for the size containing width and height
  19937. */
  19938. interface IXYZ {
  19939. /**
  19940. * X
  19941. */
  19942. x: number;
  19943. /**
  19944. * Y
  19945. */
  19946. y: number;
  19947. /**
  19948. * Z
  19949. */
  19950. z: number;
  19951. }
  19952. }
  19953. declare module "babylonjs/Physics/IPhysicsEngine" {
  19954. import { Nullable } from "babylonjs/types";
  19955. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19957. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19958. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19959. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  19960. /**
  19961. * Interface used to describe a physics joint
  19962. */
  19963. export interface PhysicsImpostorJoint {
  19964. /** Defines the main impostor to which the joint is linked */
  19965. mainImpostor: PhysicsImpostor;
  19966. /** Defines the impostor that is connected to the main impostor using this joint */
  19967. connectedImpostor: PhysicsImpostor;
  19968. /** Defines the joint itself */
  19969. joint: PhysicsJoint;
  19970. }
  19971. /** @hidden */
  19972. export interface IPhysicsEnginePlugin {
  19973. world: any;
  19974. name: string;
  19975. setGravity(gravity: Vector3): void;
  19976. setTimeStep(timeStep: number): void;
  19977. getTimeStep(): number;
  19978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19979. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19980. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19981. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19982. removePhysicsBody(impostor: PhysicsImpostor): void;
  19983. generateJoint(joint: PhysicsImpostorJoint): void;
  19984. removeJoint(joint: PhysicsImpostorJoint): void;
  19985. isSupported(): boolean;
  19986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19988. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19993. getBodyMass(impostor: PhysicsImpostor): number;
  19994. getBodyFriction(impostor: PhysicsImpostor): number;
  19995. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19996. getBodyRestitution(impostor: PhysicsImpostor): number;
  19997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19998. getBodyPressure?(impostor: PhysicsImpostor): number;
  19999. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20000. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20001. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20002. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20003. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20004. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20005. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20006. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20007. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20008. sleepBody(impostor: PhysicsImpostor): void;
  20009. wakeUpBody(impostor: PhysicsImpostor): void;
  20010. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20011. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20012. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20013. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20014. getRadius(impostor: PhysicsImpostor): number;
  20015. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20016. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20017. dispose(): void;
  20018. }
  20019. /**
  20020. * Interface used to define a physics engine
  20021. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20022. */
  20023. export interface IPhysicsEngine {
  20024. /**
  20025. * Gets the gravity vector used by the simulation
  20026. */
  20027. gravity: Vector3;
  20028. /**
  20029. * Sets the gravity vector used by the simulation
  20030. * @param gravity defines the gravity vector to use
  20031. */
  20032. setGravity(gravity: Vector3): void;
  20033. /**
  20034. * Set the time step of the physics engine.
  20035. * Default is 1/60.
  20036. * To slow it down, enter 1/600 for example.
  20037. * To speed it up, 1/30
  20038. * @param newTimeStep the new timestep to apply to this world.
  20039. */
  20040. setTimeStep(newTimeStep: number): void;
  20041. /**
  20042. * Get the time step of the physics engine.
  20043. * @returns the current time step
  20044. */
  20045. getTimeStep(): number;
  20046. /**
  20047. * Release all resources
  20048. */
  20049. dispose(): void;
  20050. /**
  20051. * Gets the name of the current physics plugin
  20052. * @returns the name of the plugin
  20053. */
  20054. getPhysicsPluginName(): string;
  20055. /**
  20056. * Adding a new impostor for the impostor tracking.
  20057. * This will be done by the impostor itself.
  20058. * @param impostor the impostor to add
  20059. */
  20060. addImpostor(impostor: PhysicsImpostor): void;
  20061. /**
  20062. * Remove an impostor from the engine.
  20063. * This impostor and its mesh will not longer be updated by the physics engine.
  20064. * @param impostor the impostor to remove
  20065. */
  20066. removeImpostor(impostor: PhysicsImpostor): void;
  20067. /**
  20068. * Add a joint to the physics engine
  20069. * @param mainImpostor defines the main impostor to which the joint is added.
  20070. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20071. * @param joint defines the joint that will connect both impostors.
  20072. */
  20073. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20074. /**
  20075. * Removes a joint from the simulation
  20076. * @param mainImpostor defines the impostor used with the joint
  20077. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20078. * @param joint defines the joint to remove
  20079. */
  20080. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20081. /**
  20082. * Gets the current plugin used to run the simulation
  20083. * @returns current plugin
  20084. */
  20085. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20086. /**
  20087. * Gets the list of physic impostors
  20088. * @returns an array of PhysicsImpostor
  20089. */
  20090. getImpostors(): Array<PhysicsImpostor>;
  20091. /**
  20092. * Gets the impostor for a physics enabled object
  20093. * @param object defines the object impersonated by the impostor
  20094. * @returns the PhysicsImpostor or null if not found
  20095. */
  20096. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20097. /**
  20098. * Gets the impostor for a physics body object
  20099. * @param body defines physics body used by the impostor
  20100. * @returns the PhysicsImpostor or null if not found
  20101. */
  20102. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20103. /**
  20104. * Does a raycast in the physics world
  20105. * @param from when should the ray start?
  20106. * @param to when should the ray end?
  20107. * @returns PhysicsRaycastResult
  20108. */
  20109. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20110. /**
  20111. * Called by the scene. No need to call it.
  20112. * @param delta defines the timespam between frames
  20113. */
  20114. _step(delta: number): void;
  20115. }
  20116. }
  20117. declare module "babylonjs/Physics/physicsImpostor" {
  20118. import { Nullable, IndicesArray } from "babylonjs/types";
  20119. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20120. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20122. import { Scene } from "babylonjs/scene";
  20123. import { Bone } from "babylonjs/Bones/bone";
  20124. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20125. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20126. /**
  20127. * The interface for the physics imposter parameters
  20128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20129. */
  20130. export interface PhysicsImpostorParameters {
  20131. /**
  20132. * The mass of the physics imposter
  20133. */
  20134. mass: number;
  20135. /**
  20136. * The friction of the physics imposter
  20137. */
  20138. friction?: number;
  20139. /**
  20140. * The coefficient of restitution of the physics imposter
  20141. */
  20142. restitution?: number;
  20143. /**
  20144. * The native options of the physics imposter
  20145. */
  20146. nativeOptions?: any;
  20147. /**
  20148. * Specifies if the parent should be ignored
  20149. */
  20150. ignoreParent?: boolean;
  20151. /**
  20152. * Specifies if bi-directional transformations should be disabled
  20153. */
  20154. disableBidirectionalTransformation?: boolean;
  20155. /**
  20156. * The pressure inside the physics imposter, soft object only
  20157. */
  20158. pressure?: number;
  20159. /**
  20160. * The stiffness the physics imposter, soft object only
  20161. */
  20162. stiffness?: number;
  20163. /**
  20164. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20165. */
  20166. velocityIterations?: number;
  20167. /**
  20168. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20169. */
  20170. positionIterations?: number;
  20171. /**
  20172. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20173. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20174. * Add to fix multiple points
  20175. */
  20176. fixedPoints?: number;
  20177. /**
  20178. * The collision margin around a soft object
  20179. */
  20180. margin?: number;
  20181. /**
  20182. * The collision margin around a soft object
  20183. */
  20184. damping?: number;
  20185. /**
  20186. * The path for a rope based on an extrusion
  20187. */
  20188. path?: any;
  20189. /**
  20190. * The shape of an extrusion used for a rope based on an extrusion
  20191. */
  20192. shape?: any;
  20193. }
  20194. /**
  20195. * Interface for a physics-enabled object
  20196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20197. */
  20198. export interface IPhysicsEnabledObject {
  20199. /**
  20200. * The position of the physics-enabled object
  20201. */
  20202. position: Vector3;
  20203. /**
  20204. * The rotation of the physics-enabled object
  20205. */
  20206. rotationQuaternion: Nullable<Quaternion>;
  20207. /**
  20208. * The scale of the physics-enabled object
  20209. */
  20210. scaling: Vector3;
  20211. /**
  20212. * The rotation of the physics-enabled object
  20213. */
  20214. rotation?: Vector3;
  20215. /**
  20216. * The parent of the physics-enabled object
  20217. */
  20218. parent?: any;
  20219. /**
  20220. * The bounding info of the physics-enabled object
  20221. * @returns The bounding info of the physics-enabled object
  20222. */
  20223. getBoundingInfo(): BoundingInfo;
  20224. /**
  20225. * Computes the world matrix
  20226. * @param force Specifies if the world matrix should be computed by force
  20227. * @returns A world matrix
  20228. */
  20229. computeWorldMatrix(force: boolean): Matrix;
  20230. /**
  20231. * Gets the world matrix
  20232. * @returns A world matrix
  20233. */
  20234. getWorldMatrix?(): Matrix;
  20235. /**
  20236. * Gets the child meshes
  20237. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20238. * @returns An array of abstract meshes
  20239. */
  20240. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20241. /**
  20242. * Gets the vertex data
  20243. * @param kind The type of vertex data
  20244. * @returns A nullable array of numbers, or a float32 array
  20245. */
  20246. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20247. /**
  20248. * Gets the indices from the mesh
  20249. * @returns A nullable array of index arrays
  20250. */
  20251. getIndices?(): Nullable<IndicesArray>;
  20252. /**
  20253. * Gets the scene from the mesh
  20254. * @returns the indices array or null
  20255. */
  20256. getScene?(): Scene;
  20257. /**
  20258. * Gets the absolute position from the mesh
  20259. * @returns the absolute position
  20260. */
  20261. getAbsolutePosition(): Vector3;
  20262. /**
  20263. * Gets the absolute pivot point from the mesh
  20264. * @returns the absolute pivot point
  20265. */
  20266. getAbsolutePivotPoint(): Vector3;
  20267. /**
  20268. * Rotates the mesh
  20269. * @param axis The axis of rotation
  20270. * @param amount The amount of rotation
  20271. * @param space The space of the rotation
  20272. * @returns The rotation transform node
  20273. */
  20274. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20275. /**
  20276. * Translates the mesh
  20277. * @param axis The axis of translation
  20278. * @param distance The distance of translation
  20279. * @param space The space of the translation
  20280. * @returns The transform node
  20281. */
  20282. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20283. /**
  20284. * Sets the absolute position of the mesh
  20285. * @param absolutePosition The absolute position of the mesh
  20286. * @returns The transform node
  20287. */
  20288. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20289. /**
  20290. * Gets the class name of the mesh
  20291. * @returns The class name
  20292. */
  20293. getClassName(): string;
  20294. }
  20295. /**
  20296. * Represents a physics imposter
  20297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20298. */
  20299. export class PhysicsImpostor {
  20300. /**
  20301. * The physics-enabled object used as the physics imposter
  20302. */
  20303. object: IPhysicsEnabledObject;
  20304. /**
  20305. * The type of the physics imposter
  20306. */
  20307. type: number;
  20308. private _options;
  20309. private _scene?;
  20310. /**
  20311. * The default object size of the imposter
  20312. */
  20313. static DEFAULT_OBJECT_SIZE: Vector3;
  20314. /**
  20315. * The identity quaternion of the imposter
  20316. */
  20317. static IDENTITY_QUATERNION: Quaternion;
  20318. /** @hidden */
  20319. _pluginData: any;
  20320. private _physicsEngine;
  20321. private _physicsBody;
  20322. private _bodyUpdateRequired;
  20323. private _onBeforePhysicsStepCallbacks;
  20324. private _onAfterPhysicsStepCallbacks;
  20325. /** @hidden */
  20326. _onPhysicsCollideCallbacks: Array<{
  20327. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20328. otherImpostors: Array<PhysicsImpostor>;
  20329. }>;
  20330. private _deltaPosition;
  20331. private _deltaRotation;
  20332. private _deltaRotationConjugated;
  20333. /** hidden */
  20334. _isFromLine: boolean;
  20335. private _parent;
  20336. private _isDisposed;
  20337. private static _tmpVecs;
  20338. private static _tmpQuat;
  20339. /**
  20340. * Specifies if the physics imposter is disposed
  20341. */
  20342. readonly isDisposed: boolean;
  20343. /**
  20344. * Gets the mass of the physics imposter
  20345. */
  20346. mass: number;
  20347. /**
  20348. * Gets the coefficient of friction
  20349. */
  20350. /**
  20351. * Sets the coefficient of friction
  20352. */
  20353. friction: number;
  20354. /**
  20355. * Gets the coefficient of restitution
  20356. */
  20357. /**
  20358. * Sets the coefficient of restitution
  20359. */
  20360. restitution: number;
  20361. /**
  20362. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20363. */
  20364. /**
  20365. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20366. */
  20367. pressure: number;
  20368. /**
  20369. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20370. */
  20371. /**
  20372. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20373. */
  20374. stiffness: number;
  20375. /**
  20376. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20377. */
  20378. /**
  20379. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20380. */
  20381. velocityIterations: number;
  20382. /**
  20383. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20384. */
  20385. /**
  20386. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20387. */
  20388. positionIterations: number;
  20389. /**
  20390. * The unique id of the physics imposter
  20391. * set by the physics engine when adding this impostor to the array
  20392. */
  20393. uniqueId: number;
  20394. /**
  20395. * @hidden
  20396. */
  20397. soft: boolean;
  20398. /**
  20399. * @hidden
  20400. */
  20401. segments: number;
  20402. private _joints;
  20403. /**
  20404. * Initializes the physics imposter
  20405. * @param object The physics-enabled object used as the physics imposter
  20406. * @param type The type of the physics imposter
  20407. * @param _options The options for the physics imposter
  20408. * @param _scene The Babylon scene
  20409. */
  20410. constructor(
  20411. /**
  20412. * The physics-enabled object used as the physics imposter
  20413. */
  20414. object: IPhysicsEnabledObject,
  20415. /**
  20416. * The type of the physics imposter
  20417. */
  20418. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20419. /**
  20420. * This function will completly initialize this impostor.
  20421. * It will create a new body - but only if this mesh has no parent.
  20422. * If it has, this impostor will not be used other than to define the impostor
  20423. * of the child mesh.
  20424. * @hidden
  20425. */
  20426. _init(): void;
  20427. private _getPhysicsParent;
  20428. /**
  20429. * Should a new body be generated.
  20430. * @returns boolean specifying if body initialization is required
  20431. */
  20432. isBodyInitRequired(): boolean;
  20433. /**
  20434. * Sets the updated scaling
  20435. * @param updated Specifies if the scaling is updated
  20436. */
  20437. setScalingUpdated(): void;
  20438. /**
  20439. * Force a regeneration of this or the parent's impostor's body.
  20440. * Use under cautious - This will remove all joints already implemented.
  20441. */
  20442. forceUpdate(): void;
  20443. /**
  20444. * Gets the body that holds this impostor. Either its own, or its parent.
  20445. */
  20446. /**
  20447. * Set the physics body. Used mainly by the physics engine/plugin
  20448. */
  20449. physicsBody: any;
  20450. /**
  20451. * Get the parent of the physics imposter
  20452. * @returns Physics imposter or null
  20453. */
  20454. /**
  20455. * Sets the parent of the physics imposter
  20456. */
  20457. parent: Nullable<PhysicsImpostor>;
  20458. /**
  20459. * Resets the update flags
  20460. */
  20461. resetUpdateFlags(): void;
  20462. /**
  20463. * Gets the object extend size
  20464. * @returns the object extend size
  20465. */
  20466. getObjectExtendSize(): Vector3;
  20467. /**
  20468. * Gets the object center
  20469. * @returns The object center
  20470. */
  20471. getObjectCenter(): Vector3;
  20472. /**
  20473. * Get a specific parametes from the options parameter
  20474. * @param paramName The object parameter name
  20475. * @returns The object parameter
  20476. */
  20477. getParam(paramName: string): any;
  20478. /**
  20479. * Sets a specific parameter in the options given to the physics plugin
  20480. * @param paramName The parameter name
  20481. * @param value The value of the parameter
  20482. */
  20483. setParam(paramName: string, value: number): void;
  20484. /**
  20485. * Specifically change the body's mass option. Won't recreate the physics body object
  20486. * @param mass The mass of the physics imposter
  20487. */
  20488. setMass(mass: number): void;
  20489. /**
  20490. * Gets the linear velocity
  20491. * @returns linear velocity or null
  20492. */
  20493. getLinearVelocity(): Nullable<Vector3>;
  20494. /**
  20495. * Sets the linear velocity
  20496. * @param velocity linear velocity or null
  20497. */
  20498. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20499. /**
  20500. * Gets the angular velocity
  20501. * @returns angular velocity or null
  20502. */
  20503. getAngularVelocity(): Nullable<Vector3>;
  20504. /**
  20505. * Sets the angular velocity
  20506. * @param velocity The velocity or null
  20507. */
  20508. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20509. /**
  20510. * Execute a function with the physics plugin native code
  20511. * Provide a function the will have two variables - the world object and the physics body object
  20512. * @param func The function to execute with the physics plugin native code
  20513. */
  20514. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20515. /**
  20516. * Register a function that will be executed before the physics world is stepping forward
  20517. * @param func The function to execute before the physics world is stepped forward
  20518. */
  20519. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20520. /**
  20521. * Unregister a function that will be executed before the physics world is stepping forward
  20522. * @param func The function to execute before the physics world is stepped forward
  20523. */
  20524. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20525. /**
  20526. * Register a function that will be executed after the physics step
  20527. * @param func The function to execute after physics step
  20528. */
  20529. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20530. /**
  20531. * Unregisters a function that will be executed after the physics step
  20532. * @param func The function to execute after physics step
  20533. */
  20534. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20535. /**
  20536. * register a function that will be executed when this impostor collides against a different body
  20537. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20538. * @param func Callback that is executed on collision
  20539. */
  20540. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20541. /**
  20542. * Unregisters the physics imposter on contact
  20543. * @param collideAgainst The physics object to collide against
  20544. * @param func Callback to execute on collision
  20545. */
  20546. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20547. private _tmpQuat;
  20548. private _tmpQuat2;
  20549. /**
  20550. * Get the parent rotation
  20551. * @returns The parent rotation
  20552. */
  20553. getParentsRotation(): Quaternion;
  20554. /**
  20555. * this function is executed by the physics engine.
  20556. */
  20557. beforeStep: () => void;
  20558. /**
  20559. * this function is executed by the physics engine
  20560. */
  20561. afterStep: () => void;
  20562. /**
  20563. * Legacy collision detection event support
  20564. */
  20565. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20566. /**
  20567. * event and body object due to cannon's event-based architecture.
  20568. */
  20569. onCollide: (e: {
  20570. body: any;
  20571. }) => void;
  20572. /**
  20573. * Apply a force
  20574. * @param force The force to apply
  20575. * @param contactPoint The contact point for the force
  20576. * @returns The physics imposter
  20577. */
  20578. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20579. /**
  20580. * Apply an impulse
  20581. * @param force The impulse force
  20582. * @param contactPoint The contact point for the impulse force
  20583. * @returns The physics imposter
  20584. */
  20585. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20586. /**
  20587. * A help function to create a joint
  20588. * @param otherImpostor A physics imposter used to create a joint
  20589. * @param jointType The type of joint
  20590. * @param jointData The data for the joint
  20591. * @returns The physics imposter
  20592. */
  20593. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20594. /**
  20595. * Add a joint to this impostor with a different impostor
  20596. * @param otherImpostor A physics imposter used to add a joint
  20597. * @param joint The joint to add
  20598. * @returns The physics imposter
  20599. */
  20600. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20601. /**
  20602. * Add an anchor to a cloth impostor
  20603. * @param otherImpostor rigid impostor to anchor to
  20604. * @param width ratio across width from 0 to 1
  20605. * @param height ratio up height from 0 to 1
  20606. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20607. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20608. * @returns impostor the soft imposter
  20609. */
  20610. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20611. /**
  20612. * Add a hook to a rope impostor
  20613. * @param otherImpostor rigid impostor to anchor to
  20614. * @param length ratio across rope from 0 to 1
  20615. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20616. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20617. * @returns impostor the rope imposter
  20618. */
  20619. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20620. /**
  20621. * Will keep this body still, in a sleep mode.
  20622. * @returns the physics imposter
  20623. */
  20624. sleep(): PhysicsImpostor;
  20625. /**
  20626. * Wake the body up.
  20627. * @returns The physics imposter
  20628. */
  20629. wakeUp(): PhysicsImpostor;
  20630. /**
  20631. * Clones the physics imposter
  20632. * @param newObject The physics imposter clones to this physics-enabled object
  20633. * @returns A nullable physics imposter
  20634. */
  20635. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20636. /**
  20637. * Disposes the physics imposter
  20638. */
  20639. dispose(): void;
  20640. /**
  20641. * Sets the delta position
  20642. * @param position The delta position amount
  20643. */
  20644. setDeltaPosition(position: Vector3): void;
  20645. /**
  20646. * Sets the delta rotation
  20647. * @param rotation The delta rotation amount
  20648. */
  20649. setDeltaRotation(rotation: Quaternion): void;
  20650. /**
  20651. * Gets the box size of the physics imposter and stores the result in the input parameter
  20652. * @param result Stores the box size
  20653. * @returns The physics imposter
  20654. */
  20655. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20656. /**
  20657. * Gets the radius of the physics imposter
  20658. * @returns Radius of the physics imposter
  20659. */
  20660. getRadius(): number;
  20661. /**
  20662. * Sync a bone with this impostor
  20663. * @param bone The bone to sync to the impostor.
  20664. * @param boneMesh The mesh that the bone is influencing.
  20665. * @param jointPivot The pivot of the joint / bone in local space.
  20666. * @param distToJoint Optional distance from the impostor to the joint.
  20667. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20668. */
  20669. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20670. /**
  20671. * Sync impostor to a bone
  20672. * @param bone The bone that the impostor will be synced to.
  20673. * @param boneMesh The mesh that the bone is influencing.
  20674. * @param jointPivot The pivot of the joint / bone in local space.
  20675. * @param distToJoint Optional distance from the impostor to the joint.
  20676. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20677. * @param boneAxis Optional vector3 axis the bone is aligned with
  20678. */
  20679. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20680. /**
  20681. * No-Imposter type
  20682. */
  20683. static NoImpostor: number;
  20684. /**
  20685. * Sphere-Imposter type
  20686. */
  20687. static SphereImpostor: number;
  20688. /**
  20689. * Box-Imposter type
  20690. */
  20691. static BoxImpostor: number;
  20692. /**
  20693. * Plane-Imposter type
  20694. */
  20695. static PlaneImpostor: number;
  20696. /**
  20697. * Mesh-imposter type
  20698. */
  20699. static MeshImpostor: number;
  20700. /**
  20701. * Cylinder-Imposter type
  20702. */
  20703. static CylinderImpostor: number;
  20704. /**
  20705. * Particle-Imposter type
  20706. */
  20707. static ParticleImpostor: number;
  20708. /**
  20709. * Heightmap-Imposter type
  20710. */
  20711. static HeightmapImpostor: number;
  20712. /**
  20713. * ConvexHull-Impostor type (Ammo.js plugin only)
  20714. */
  20715. static ConvexHullImpostor: number;
  20716. /**
  20717. * Rope-Imposter type
  20718. */
  20719. static RopeImpostor: number;
  20720. /**
  20721. * Cloth-Imposter type
  20722. */
  20723. static ClothImpostor: number;
  20724. /**
  20725. * Softbody-Imposter type
  20726. */
  20727. static SoftbodyImpostor: number;
  20728. }
  20729. }
  20730. declare module "babylonjs/Meshes/mesh" {
  20731. import { Observable } from "babylonjs/Misc/observable";
  20732. import { IAnimatable } from "babylonjs/Misc/tools";
  20733. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20734. import { Camera } from "babylonjs/Cameras/camera";
  20735. import { Scene } from "babylonjs/scene";
  20736. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20737. import { Engine } from "babylonjs/Engines/engine";
  20738. import { Node } from "babylonjs/node";
  20739. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20740. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20741. import { Buffer } from "babylonjs/Meshes/buffer";
  20742. import { Geometry } from "babylonjs/Meshes/geometry";
  20743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20744. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20745. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20746. import { Effect } from "babylonjs/Materials/effect";
  20747. import { Material } from "babylonjs/Materials/material";
  20748. import { Skeleton } from "babylonjs/Bones/skeleton";
  20749. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20750. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20751. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20752. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20753. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20754. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20755. /**
  20756. * Class used to represent a specific level of detail of a mesh
  20757. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20758. */
  20759. export class MeshLODLevel {
  20760. /** Defines the distance where this level should star being displayed */
  20761. distance: number;
  20762. /** Defines the mesh to use to render this level */
  20763. mesh: Nullable<Mesh>;
  20764. /**
  20765. * Creates a new LOD level
  20766. * @param distance defines the distance where this level should star being displayed
  20767. * @param mesh defines the mesh to use to render this level
  20768. */
  20769. constructor(
  20770. /** Defines the distance where this level should star being displayed */
  20771. distance: number,
  20772. /** Defines the mesh to use to render this level */
  20773. mesh: Nullable<Mesh>);
  20774. }
  20775. /**
  20776. * @hidden
  20777. **/
  20778. export class _CreationDataStorage {
  20779. closePath?: boolean;
  20780. closeArray?: boolean;
  20781. idx: number[];
  20782. dashSize: number;
  20783. gapSize: number;
  20784. path3D: Path3D;
  20785. pathArray: Vector3[][];
  20786. arc: number;
  20787. radius: number;
  20788. cap: number;
  20789. tessellation: number;
  20790. }
  20791. /**
  20792. * @hidden
  20793. **/
  20794. class _InstanceDataStorage {
  20795. visibleInstances: any;
  20796. renderIdForInstances: number[];
  20797. batchCache: _InstancesBatch;
  20798. instancesBufferSize: number;
  20799. instancesBuffer: Nullable<Buffer>;
  20800. instancesData: Float32Array;
  20801. overridenInstanceCount: number;
  20802. }
  20803. /**
  20804. * @hidden
  20805. **/
  20806. export class _InstancesBatch {
  20807. mustReturn: boolean;
  20808. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20809. renderSelf: boolean[];
  20810. }
  20811. /**
  20812. * Class used to represent renderable models
  20813. */
  20814. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20815. /**
  20816. * Mesh side orientation : usually the external or front surface
  20817. */
  20818. static readonly FRONTSIDE: number;
  20819. /**
  20820. * Mesh side orientation : usually the internal or back surface
  20821. */
  20822. static readonly BACKSIDE: number;
  20823. /**
  20824. * Mesh side orientation : both internal and external or front and back surfaces
  20825. */
  20826. static readonly DOUBLESIDE: number;
  20827. /**
  20828. * Mesh side orientation : by default, `FRONTSIDE`
  20829. */
  20830. static readonly DEFAULTSIDE: number;
  20831. /**
  20832. * Mesh cap setting : no cap
  20833. */
  20834. static readonly NO_CAP: number;
  20835. /**
  20836. * Mesh cap setting : one cap at the beginning of the mesh
  20837. */
  20838. static readonly CAP_START: number;
  20839. /**
  20840. * Mesh cap setting : one cap at the end of the mesh
  20841. */
  20842. static readonly CAP_END: number;
  20843. /**
  20844. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20845. */
  20846. static readonly CAP_ALL: number;
  20847. /**
  20848. * Gets the default side orientation.
  20849. * @param orientation the orientation to value to attempt to get
  20850. * @returns the default orientation
  20851. * @hidden
  20852. */
  20853. static _GetDefaultSideOrientation(orientation?: number): number;
  20854. private _onBeforeRenderObservable;
  20855. private _onBeforeBindObservable;
  20856. private _onAfterRenderObservable;
  20857. private _onBeforeDrawObservable;
  20858. /**
  20859. * An event triggered before rendering the mesh
  20860. */
  20861. readonly onBeforeRenderObservable: Observable<Mesh>;
  20862. /**
  20863. * An event triggered before binding the mesh
  20864. */
  20865. readonly onBeforeBindObservable: Observable<Mesh>;
  20866. /**
  20867. * An event triggered after rendering the mesh
  20868. */
  20869. readonly onAfterRenderObservable: Observable<Mesh>;
  20870. /**
  20871. * An event triggered before drawing the mesh
  20872. */
  20873. readonly onBeforeDrawObservable: Observable<Mesh>;
  20874. private _onBeforeDrawObserver;
  20875. /**
  20876. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20877. */
  20878. onBeforeDraw: () => void;
  20879. /**
  20880. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20881. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20882. */
  20883. delayLoadState: number;
  20884. /**
  20885. * Gets the list of instances created from this mesh
  20886. * it is not supposed to be modified manually.
  20887. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20888. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20889. */
  20890. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20891. /**
  20892. * Gets the file containing delay loading data for this mesh
  20893. */
  20894. delayLoadingFile: string;
  20895. /** @hidden */
  20896. _binaryInfo: any;
  20897. private _LODLevels;
  20898. /**
  20899. * User defined function used to change how LOD level selection is done
  20900. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20901. */
  20902. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20903. private _morphTargetManager;
  20904. /**
  20905. * Gets or sets the morph target manager
  20906. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20907. */
  20908. morphTargetManager: Nullable<MorphTargetManager>;
  20909. /** @hidden */
  20910. _creationDataStorage: Nullable<_CreationDataStorage>;
  20911. /** @hidden */
  20912. _geometry: Nullable<Geometry>;
  20913. /** @hidden */
  20914. _delayInfo: Array<string>;
  20915. /** @hidden */
  20916. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20917. /** @hidden */
  20918. _instanceDataStorage: _InstanceDataStorage;
  20919. private _effectiveMaterial;
  20920. /** @hidden */
  20921. _shouldGenerateFlatShading: boolean;
  20922. private _preActivateId;
  20923. /** @hidden */
  20924. _originalBuilderSideOrientation: number;
  20925. /**
  20926. * Use this property to change the original side orientation defined at construction time
  20927. */
  20928. overrideMaterialSideOrientation: Nullable<number>;
  20929. private _areNormalsFrozen;
  20930. private _sourcePositions;
  20931. private _sourceNormals;
  20932. private _source;
  20933. private meshMap;
  20934. /**
  20935. * Gets the source mesh (the one used to clone this one from)
  20936. */
  20937. readonly source: Nullable<Mesh>;
  20938. /**
  20939. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20940. */
  20941. isUnIndexed: boolean;
  20942. /**
  20943. * @constructor
  20944. * @param name The value used by scene.getMeshByName() to do a lookup.
  20945. * @param scene The scene to add this mesh to.
  20946. * @param parent The parent of this mesh, if it has one
  20947. * @param source An optional Mesh from which geometry is shared, cloned.
  20948. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20949. * When false, achieved by calling a clone(), also passing False.
  20950. * This will make creation of children, recursive.
  20951. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20952. */
  20953. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20954. /**
  20955. * Gets the class name
  20956. * @returns the string "Mesh".
  20957. */
  20958. getClassName(): string;
  20959. /** @hidden */
  20960. readonly _isMesh: boolean;
  20961. /**
  20962. * Returns a description of this mesh
  20963. * @param fullDetails define if full details about this mesh must be used
  20964. * @returns a descriptive string representing this mesh
  20965. */
  20966. toString(fullDetails?: boolean): string;
  20967. /** @hidden */
  20968. _unBindEffect(): void;
  20969. /**
  20970. * Gets a boolean indicating if this mesh has LOD
  20971. */
  20972. readonly hasLODLevels: boolean;
  20973. /**
  20974. * Gets the list of MeshLODLevel associated with the current mesh
  20975. * @returns an array of MeshLODLevel
  20976. */
  20977. getLODLevels(): MeshLODLevel[];
  20978. private _sortLODLevels;
  20979. /**
  20980. * Add a mesh as LOD level triggered at the given distance.
  20981. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20982. * @param distance The distance from the center of the object to show this level
  20983. * @param mesh The mesh to be added as LOD level (can be null)
  20984. * @return This mesh (for chaining)
  20985. */
  20986. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20987. /**
  20988. * Returns the LOD level mesh at the passed distance or null if not found.
  20989. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20990. * @param distance The distance from the center of the object to show this level
  20991. * @returns a Mesh or `null`
  20992. */
  20993. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20994. /**
  20995. * Remove a mesh from the LOD array
  20996. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20997. * @param mesh defines the mesh to be removed
  20998. * @return This mesh (for chaining)
  20999. */
  21000. removeLODLevel(mesh: Mesh): Mesh;
  21001. /**
  21002. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21003. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21004. * @param camera defines the camera to use to compute distance
  21005. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21006. * @return This mesh (for chaining)
  21007. */
  21008. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21009. /**
  21010. * Gets the mesh internal Geometry object
  21011. */
  21012. readonly geometry: Nullable<Geometry>;
  21013. /**
  21014. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21015. * @returns the total number of vertices
  21016. */
  21017. getTotalVertices(): number;
  21018. /**
  21019. * Returns the content of an associated vertex buffer
  21020. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21021. * - VertexBuffer.PositionKind
  21022. * - VertexBuffer.UVKind
  21023. * - VertexBuffer.UV2Kind
  21024. * - VertexBuffer.UV3Kind
  21025. * - VertexBuffer.UV4Kind
  21026. * - VertexBuffer.UV5Kind
  21027. * - VertexBuffer.UV6Kind
  21028. * - VertexBuffer.ColorKind
  21029. * - VertexBuffer.MatricesIndicesKind
  21030. * - VertexBuffer.MatricesIndicesExtraKind
  21031. * - VertexBuffer.MatricesWeightsKind
  21032. * - VertexBuffer.MatricesWeightsExtraKind
  21033. * @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
  21034. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21035. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21036. */
  21037. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21038. /**
  21039. * Returns the mesh VertexBuffer object from the requested `kind`
  21040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21041. * - VertexBuffer.PositionKind
  21042. * - VertexBuffer.UVKind
  21043. * - VertexBuffer.UV2Kind
  21044. * - VertexBuffer.UV3Kind
  21045. * - VertexBuffer.UV4Kind
  21046. * - VertexBuffer.UV5Kind
  21047. * - VertexBuffer.UV6Kind
  21048. * - VertexBuffer.ColorKind
  21049. * - VertexBuffer.MatricesIndicesKind
  21050. * - VertexBuffer.MatricesIndicesExtraKind
  21051. * - VertexBuffer.MatricesWeightsKind
  21052. * - VertexBuffer.MatricesWeightsExtraKind
  21053. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21054. */
  21055. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21056. /**
  21057. * Tests if a specific vertex buffer is associated with this mesh
  21058. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21059. * - VertexBuffer.PositionKind
  21060. * - VertexBuffer.UVKind
  21061. * - VertexBuffer.UV2Kind
  21062. * - VertexBuffer.UV3Kind
  21063. * - VertexBuffer.UV4Kind
  21064. * - VertexBuffer.UV5Kind
  21065. * - VertexBuffer.UV6Kind
  21066. * - VertexBuffer.ColorKind
  21067. * - VertexBuffer.MatricesIndicesKind
  21068. * - VertexBuffer.MatricesIndicesExtraKind
  21069. * - VertexBuffer.MatricesWeightsKind
  21070. * - VertexBuffer.MatricesWeightsExtraKind
  21071. * @returns a boolean
  21072. */
  21073. isVerticesDataPresent(kind: string): boolean;
  21074. /**
  21075. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21076. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21077. * - VertexBuffer.PositionKind
  21078. * - VertexBuffer.UVKind
  21079. * - VertexBuffer.UV2Kind
  21080. * - VertexBuffer.UV3Kind
  21081. * - VertexBuffer.UV4Kind
  21082. * - VertexBuffer.UV5Kind
  21083. * - VertexBuffer.UV6Kind
  21084. * - VertexBuffer.ColorKind
  21085. * - VertexBuffer.MatricesIndicesKind
  21086. * - VertexBuffer.MatricesIndicesExtraKind
  21087. * - VertexBuffer.MatricesWeightsKind
  21088. * - VertexBuffer.MatricesWeightsExtraKind
  21089. * @returns a boolean
  21090. */
  21091. isVertexBufferUpdatable(kind: string): boolean;
  21092. /**
  21093. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21094. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21095. * - VertexBuffer.PositionKind
  21096. * - VertexBuffer.UVKind
  21097. * - VertexBuffer.UV2Kind
  21098. * - VertexBuffer.UV3Kind
  21099. * - VertexBuffer.UV4Kind
  21100. * - VertexBuffer.UV5Kind
  21101. * - VertexBuffer.UV6Kind
  21102. * - VertexBuffer.ColorKind
  21103. * - VertexBuffer.MatricesIndicesKind
  21104. * - VertexBuffer.MatricesIndicesExtraKind
  21105. * - VertexBuffer.MatricesWeightsKind
  21106. * - VertexBuffer.MatricesWeightsExtraKind
  21107. * @returns an array of strings
  21108. */
  21109. getVerticesDataKinds(): string[];
  21110. /**
  21111. * Returns a positive integer : the total number of indices in this mesh geometry.
  21112. * @returns the numner of indices or zero if the mesh has no geometry.
  21113. */
  21114. getTotalIndices(): number;
  21115. /**
  21116. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21117. * @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.
  21118. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21119. * @returns the indices array or an empty array if the mesh has no geometry
  21120. */
  21121. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21122. readonly isBlocked: boolean;
  21123. /**
  21124. * Determine if the current mesh is ready to be rendered
  21125. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21126. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21127. * @returns true if all associated assets are ready (material, textures, shaders)
  21128. */
  21129. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21130. /**
  21131. * 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.
  21132. */
  21133. readonly areNormalsFrozen: boolean;
  21134. /**
  21135. * 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.
  21136. * @returns the current mesh
  21137. */
  21138. freezeNormals(): Mesh;
  21139. /**
  21140. * 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
  21141. * @returns the current mesh
  21142. */
  21143. unfreezeNormals(): Mesh;
  21144. /**
  21145. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21146. */
  21147. overridenInstanceCount: number;
  21148. /** @hidden */
  21149. _preActivate(): Mesh;
  21150. /** @hidden */
  21151. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21152. /** @hidden */
  21153. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21154. /**
  21155. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21156. * This means the mesh underlying bounding box and sphere are recomputed.
  21157. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21158. * @returns the current mesh
  21159. */
  21160. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21161. /** @hidden */
  21162. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21163. /**
  21164. * This function will subdivide the mesh into multiple submeshes
  21165. * @param count defines the expected number of submeshes
  21166. */
  21167. subdivide(count: number): void;
  21168. /**
  21169. * Copy a FloatArray into a specific associated vertex buffer
  21170. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21171. * - VertexBuffer.PositionKind
  21172. * - VertexBuffer.UVKind
  21173. * - VertexBuffer.UV2Kind
  21174. * - VertexBuffer.UV3Kind
  21175. * - VertexBuffer.UV4Kind
  21176. * - VertexBuffer.UV5Kind
  21177. * - VertexBuffer.UV6Kind
  21178. * - VertexBuffer.ColorKind
  21179. * - VertexBuffer.MatricesIndicesKind
  21180. * - VertexBuffer.MatricesIndicesExtraKind
  21181. * - VertexBuffer.MatricesWeightsKind
  21182. * - VertexBuffer.MatricesWeightsExtraKind
  21183. * @param data defines the data source
  21184. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21185. * @param stride defines the data stride size (can be null)
  21186. * @returns the current mesh
  21187. */
  21188. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21189. /**
  21190. * Flags an associated vertex buffer as updatable
  21191. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21192. * - VertexBuffer.PositionKind
  21193. * - VertexBuffer.UVKind
  21194. * - VertexBuffer.UV2Kind
  21195. * - VertexBuffer.UV3Kind
  21196. * - VertexBuffer.UV4Kind
  21197. * - VertexBuffer.UV5Kind
  21198. * - VertexBuffer.UV6Kind
  21199. * - VertexBuffer.ColorKind
  21200. * - VertexBuffer.MatricesIndicesKind
  21201. * - VertexBuffer.MatricesIndicesExtraKind
  21202. * - VertexBuffer.MatricesWeightsKind
  21203. * - VertexBuffer.MatricesWeightsExtraKind
  21204. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21205. */
  21206. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21207. /**
  21208. * Sets the mesh global Vertex Buffer
  21209. * @param buffer defines the buffer to use
  21210. * @returns the current mesh
  21211. */
  21212. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21213. /**
  21214. * Update a specific associated vertex buffer
  21215. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21216. * - VertexBuffer.PositionKind
  21217. * - VertexBuffer.UVKind
  21218. * - VertexBuffer.UV2Kind
  21219. * - VertexBuffer.UV3Kind
  21220. * - VertexBuffer.UV4Kind
  21221. * - VertexBuffer.UV5Kind
  21222. * - VertexBuffer.UV6Kind
  21223. * - VertexBuffer.ColorKind
  21224. * - VertexBuffer.MatricesIndicesKind
  21225. * - VertexBuffer.MatricesIndicesExtraKind
  21226. * - VertexBuffer.MatricesWeightsKind
  21227. * - VertexBuffer.MatricesWeightsExtraKind
  21228. * @param data defines the data source
  21229. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21230. * @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)
  21231. * @returns the current mesh
  21232. */
  21233. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21234. /**
  21235. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21236. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21237. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21238. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21239. * @returns the current mesh
  21240. */
  21241. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21242. /**
  21243. * Creates a un-shared specific occurence of the geometry for the mesh.
  21244. * @returns the current mesh
  21245. */
  21246. makeGeometryUnique(): Mesh;
  21247. /**
  21248. * Set the index buffer of this mesh
  21249. * @param indices defines the source data
  21250. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21251. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21252. * @returns the current mesh
  21253. */
  21254. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21255. /**
  21256. * Update the current index buffer
  21257. * @param indices defines the source data
  21258. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21259. * @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)
  21260. * @returns the current mesh
  21261. */
  21262. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21263. /**
  21264. * Invert the geometry to move from a right handed system to a left handed one.
  21265. * @returns the current mesh
  21266. */
  21267. toLeftHanded(): Mesh;
  21268. /** @hidden */
  21269. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21270. /** @hidden */
  21271. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21272. /**
  21273. * Registers for this mesh a javascript function called just before the rendering process
  21274. * @param func defines the function to call before rendering this mesh
  21275. * @returns the current mesh
  21276. */
  21277. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21278. /**
  21279. * Disposes a previously registered javascript function called before the rendering
  21280. * @param func defines the function to remove
  21281. * @returns the current mesh
  21282. */
  21283. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21284. /**
  21285. * Registers for this mesh a javascript function called just after the rendering is complete
  21286. * @param func defines the function to call after rendering this mesh
  21287. * @returns the current mesh
  21288. */
  21289. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21290. /**
  21291. * Disposes a previously registered javascript function called after the rendering.
  21292. * @param func defines the function to remove
  21293. * @returns the current mesh
  21294. */
  21295. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21296. /** @hidden */
  21297. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21298. /** @hidden */
  21299. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21300. /** @hidden */
  21301. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21302. /**
  21303. * 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
  21304. * @param subMesh defines the subMesh to render
  21305. * @param enableAlphaMode defines if alpha mode can be changed
  21306. * @returns the current mesh
  21307. */
  21308. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21309. private _onBeforeDraw;
  21310. /**
  21311. * Renormalize the mesh and patch it up if there are no weights
  21312. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21313. * However in the case of zero weights then we set just a single influence to 1.
  21314. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21315. */
  21316. cleanMatrixWeights(): void;
  21317. private normalizeSkinFourWeights;
  21318. private normalizeSkinWeightsAndExtra;
  21319. /**
  21320. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21321. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21322. * the user know there was an issue with importing the mesh
  21323. * @returns a validation object with skinned, valid and report string
  21324. */
  21325. validateSkinning(): {
  21326. skinned: boolean;
  21327. valid: boolean;
  21328. report: string;
  21329. };
  21330. /** @hidden */
  21331. _checkDelayState(): Mesh;
  21332. private _queueLoad;
  21333. /**
  21334. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21335. * A mesh is in the frustum if its bounding box intersects the frustum
  21336. * @param frustumPlanes defines the frustum to test
  21337. * @returns true if the mesh is in the frustum planes
  21338. */
  21339. isInFrustum(frustumPlanes: Plane[]): boolean;
  21340. /**
  21341. * Sets the mesh material by the material or multiMaterial `id` property
  21342. * @param id is a string identifying the material or the multiMaterial
  21343. * @returns the current mesh
  21344. */
  21345. setMaterialByID(id: string): Mesh;
  21346. /**
  21347. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21348. * @returns an array of IAnimatable
  21349. */
  21350. getAnimatables(): IAnimatable[];
  21351. /**
  21352. * Modifies the mesh geometry according to the passed transformation matrix.
  21353. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21354. * The mesh normals are modified using the same transformation.
  21355. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21356. * @param transform defines the transform matrix to use
  21357. * @see http://doc.babylonjs.com/resources/baking_transformations
  21358. * @returns the current mesh
  21359. */
  21360. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21361. /**
  21362. * Modifies the mesh geometry according to its own current World Matrix.
  21363. * The mesh World Matrix is then reset.
  21364. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21365. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21366. * @see http://doc.babylonjs.com/resources/baking_transformations
  21367. * @returns the current mesh
  21368. */
  21369. bakeCurrentTransformIntoVertices(): Mesh;
  21370. /** @hidden */
  21371. readonly _positions: Nullable<Vector3[]>;
  21372. /** @hidden */
  21373. _resetPointsArrayCache(): Mesh;
  21374. /** @hidden */
  21375. _generatePointsArray(): boolean;
  21376. /**
  21377. * Returns a new Mesh object generated from the current mesh properties.
  21378. * This method must not get confused with createInstance()
  21379. * @param name is a string, the name given to the new mesh
  21380. * @param newParent can be any Node object (default `null`)
  21381. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21382. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21383. * @returns a new mesh
  21384. */
  21385. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21386. /**
  21387. * Releases resources associated with this mesh.
  21388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21390. */
  21391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21392. /**
  21393. * Modifies the mesh geometry according to a displacement map.
  21394. * 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.
  21395. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21396. * @param url is a string, the URL from the image file is to be downloaded.
  21397. * @param minHeight is the lower limit of the displacement.
  21398. * @param maxHeight is the upper limit of the displacement.
  21399. * @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.
  21400. * @param uvOffset is an optional vector2 used to offset UV.
  21401. * @param uvScale is an optional vector2 used to scale UV.
  21402. * @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.
  21403. * @returns the Mesh.
  21404. */
  21405. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21406. /**
  21407. * Modifies the mesh geometry according to a displacementMap buffer.
  21408. * 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.
  21409. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21410. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21411. * @param heightMapWidth is the width of the buffer image.
  21412. * @param heightMapHeight is the height of the buffer image.
  21413. * @param minHeight is the lower limit of the displacement.
  21414. * @param maxHeight is the upper limit of the displacement.
  21415. * @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.
  21416. * @param uvOffset is an optional vector2 used to offset UV.
  21417. * @param uvScale is an optional vector2 used to scale UV.
  21418. * @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.
  21419. * @returns the Mesh.
  21420. */
  21421. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21422. /**
  21423. * Modify the mesh to get a flat shading rendering.
  21424. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21425. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21426. * @returns current mesh
  21427. */
  21428. convertToFlatShadedMesh(): Mesh;
  21429. /**
  21430. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21431. * In other words, more vertices, no more indices and a single bigger VBO.
  21432. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21433. * @returns current mesh
  21434. */
  21435. convertToUnIndexedMesh(): Mesh;
  21436. /**
  21437. * Inverses facet orientations.
  21438. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21439. * @param flipNormals will also inverts the normals
  21440. * @returns current mesh
  21441. */
  21442. flipFaces(flipNormals?: boolean): Mesh;
  21443. /**
  21444. * Increase the number of facets and hence vertices in a mesh
  21445. * Vertex normals are interpolated from existing vertex normals
  21446. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21447. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21448. */
  21449. increaseVertices(numberPerEdge: number): void;
  21450. /**
  21451. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21452. * This will undo any application of covertToFlatShadedMesh
  21453. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21454. */
  21455. forceSharedVertices(): void;
  21456. /** @hidden */
  21457. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21458. /** @hidden */
  21459. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21460. /**
  21461. * Creates a new InstancedMesh object from the mesh model.
  21462. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21463. * @param name defines the name of the new instance
  21464. * @returns a new InstancedMesh
  21465. */
  21466. createInstance(name: string): InstancedMesh;
  21467. /**
  21468. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21469. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21470. * @returns the current mesh
  21471. */
  21472. synchronizeInstances(): Mesh;
  21473. /**
  21474. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21475. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21476. * This should be used together with the simplification to avoid disappearing triangles.
  21477. * @param successCallback an optional success callback to be called after the optimization finished.
  21478. * @returns the current mesh
  21479. */
  21480. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21481. /**
  21482. * Serialize current mesh
  21483. * @param serializationObject defines the object which will receive the serialization data
  21484. */
  21485. serialize(serializationObject: any): void;
  21486. /** @hidden */
  21487. _syncGeometryWithMorphTargetManager(): void;
  21488. /** @hidden */
  21489. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21490. /**
  21491. * Returns a new Mesh object parsed from the source provided.
  21492. * @param parsedMesh is the source
  21493. * @param scene defines the hosting scene
  21494. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21495. * @returns a new Mesh
  21496. */
  21497. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21498. /**
  21499. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21500. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21501. * @param name defines the name of the mesh to create
  21502. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21503. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21504. * @param closePath creates a seam between the first and the last points of each path of the path array
  21505. * @param offset is taken in account only if the `pathArray` is containing a single path
  21506. * @param scene defines the hosting scene
  21507. * @param updatable defines if the mesh must be flagged as updatable
  21508. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21509. * @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)
  21510. * @returns a new Mesh
  21511. */
  21512. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21513. /**
  21514. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21515. * @param name defines the name of the mesh to create
  21516. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21517. * @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
  21518. * @param scene defines the hosting scene
  21519. * @param updatable defines if the mesh must be flagged as updatable
  21520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21521. * @returns a new Mesh
  21522. */
  21523. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21524. /**
  21525. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21526. * @param name defines the name of the mesh to create
  21527. * @param size sets the size (float) of each box side (default 1)
  21528. * @param scene defines the hosting scene
  21529. * @param updatable defines if the mesh must be flagged as updatable
  21530. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21531. * @returns a new Mesh
  21532. */
  21533. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21534. /**
  21535. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21536. * @param name defines the name of the mesh to create
  21537. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21538. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21539. * @param scene defines the hosting scene
  21540. * @param updatable defines if the mesh must be flagged as updatable
  21541. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21542. * @returns a new Mesh
  21543. */
  21544. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21545. /**
  21546. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21547. * @param name defines the name of the mesh to create
  21548. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21549. * @param diameterTop set the top cap diameter (floats, default 1)
  21550. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21551. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21552. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21553. * @param scene defines the hosting scene
  21554. * @param updatable defines if the mesh must be flagged as updatable
  21555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21556. * @returns a new Mesh
  21557. */
  21558. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21559. /**
  21560. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21561. * @param name defines the name of the mesh to create
  21562. * @param diameter sets the diameter size (float) of the torus (default 1)
  21563. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21564. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21565. * @param scene defines the hosting scene
  21566. * @param updatable defines if the mesh must be flagged as updatable
  21567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21568. * @returns a new Mesh
  21569. */
  21570. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21571. /**
  21572. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21573. * @param name defines the name of the mesh to create
  21574. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21575. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21576. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21577. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21578. * @param p the number of windings on X axis (positive integers, default 2)
  21579. * @param q the number of windings on Y axis (positive integers, default 3)
  21580. * @param scene defines the hosting scene
  21581. * @param updatable defines if the mesh must be flagged as updatable
  21582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21583. * @returns a new Mesh
  21584. */
  21585. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21586. /**
  21587. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21588. * @param name defines the name of the mesh to create
  21589. * @param points is an array successive Vector3
  21590. * @param scene defines the hosting scene
  21591. * @param updatable defines if the mesh must be flagged as updatable
  21592. * @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).
  21593. * @returns a new Mesh
  21594. */
  21595. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21596. /**
  21597. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21598. * @param name defines the name of the mesh to create
  21599. * @param points is an array successive Vector3
  21600. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21601. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21602. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21603. * @param scene defines the hosting scene
  21604. * @param updatable defines if the mesh must be flagged as updatable
  21605. * @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)
  21606. * @returns a new Mesh
  21607. */
  21608. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21609. /**
  21610. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21611. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21612. * 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.
  21613. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21614. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21615. * Remember you can only change the shape positions, not their number when updating a polygon.
  21616. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21617. * @param name defines the name of the mesh to create
  21618. * @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
  21619. * @param scene defines the hosting scene
  21620. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21621. * @param updatable defines if the mesh must be flagged as updatable
  21622. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21623. * @param earcutInjection can be used to inject your own earcut reference
  21624. * @returns a new Mesh
  21625. */
  21626. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21627. /**
  21628. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21630. * @param name defines the name of the mesh to create
  21631. * @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
  21632. * @param depth defines the height of extrusion
  21633. * @param scene defines the hosting scene
  21634. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21635. * @param updatable defines if the mesh must be flagged as updatable
  21636. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21637. * @param earcutInjection can be used to inject your own earcut reference
  21638. * @returns a new Mesh
  21639. */
  21640. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21641. /**
  21642. * Creates an extruded shape mesh.
  21643. * 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
  21644. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21645. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21646. * @param name defines the name of the mesh to create
  21647. * @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
  21648. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21649. * @param scale is the value to scale the shape
  21650. * @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
  21651. * @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
  21652. * @param scene defines the hosting scene
  21653. * @param updatable defines if the mesh must be flagged as updatable
  21654. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21655. * @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)
  21656. * @returns a new Mesh
  21657. */
  21658. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21659. /**
  21660. * Creates an custom extruded shape mesh.
  21661. * The custom extrusion is a parametric shape.
  21662. * It has no predefined shape. Its final shape will depend on the input parameters.
  21663. * Please consider using the same method from the MeshBuilder class instead
  21664. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21665. * @param name defines the name of the mesh to create
  21666. * @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
  21667. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21668. * @param scaleFunction is a custom Javascript function called on each path point
  21669. * @param rotationFunction is a custom Javascript function called on each path point
  21670. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21671. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21672. * @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
  21673. * @param scene defines the hosting scene
  21674. * @param updatable defines if the mesh must be flagged as updatable
  21675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21676. * @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)
  21677. * @returns a new Mesh
  21678. */
  21679. 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;
  21680. /**
  21681. * Creates lathe mesh.
  21682. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21683. * Please consider using the same method from the MeshBuilder class instead
  21684. * @param name defines the name of the mesh to create
  21685. * @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
  21686. * @param radius is the radius value of the lathe
  21687. * @param tessellation is the side number of the lathe.
  21688. * @param scene defines the hosting scene
  21689. * @param updatable defines if the mesh must be flagged as updatable
  21690. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21691. * @returns a new Mesh
  21692. */
  21693. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21694. /**
  21695. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21696. * @param name defines the name of the mesh to create
  21697. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21698. * @param scene defines the hosting scene
  21699. * @param updatable defines if the mesh must be flagged as updatable
  21700. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21701. * @returns a new Mesh
  21702. */
  21703. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21704. /**
  21705. * Creates a ground mesh.
  21706. * Please consider using the same method from the MeshBuilder class instead
  21707. * @param name defines the name of the mesh to create
  21708. * @param width set the width of the ground
  21709. * @param height set the height of the ground
  21710. * @param subdivisions sets the number of subdivisions per side
  21711. * @param scene defines the hosting scene
  21712. * @param updatable defines if the mesh must be flagged as updatable
  21713. * @returns a new Mesh
  21714. */
  21715. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21716. /**
  21717. * Creates a tiled ground mesh.
  21718. * Please consider using the same method from the MeshBuilder class instead
  21719. * @param name defines the name of the mesh to create
  21720. * @param xmin set the ground minimum X coordinate
  21721. * @param zmin set the ground minimum Y coordinate
  21722. * @param xmax set the ground maximum X coordinate
  21723. * @param zmax set the ground maximum Z coordinate
  21724. * @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
  21725. * @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
  21726. * @param scene defines the hosting scene
  21727. * @param updatable defines if the mesh must be flagged as updatable
  21728. * @returns a new Mesh
  21729. */
  21730. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21731. w: number;
  21732. h: number;
  21733. }, precision: {
  21734. w: number;
  21735. h: number;
  21736. }, scene: Scene, updatable?: boolean): Mesh;
  21737. /**
  21738. * Creates a ground mesh from a height map.
  21739. * Please consider using the same method from the MeshBuilder class instead
  21740. * @see http://doc.babylonjs.com/babylon101/height_map
  21741. * @param name defines the name of the mesh to create
  21742. * @param url sets the URL of the height map image resource
  21743. * @param width set the ground width size
  21744. * @param height set the ground height size
  21745. * @param subdivisions sets the number of subdivision per side
  21746. * @param minHeight is the minimum altitude on the ground
  21747. * @param maxHeight is the maximum altitude on the ground
  21748. * @param scene defines the hosting scene
  21749. * @param updatable defines if the mesh must be flagged as updatable
  21750. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21751. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21752. * @returns a new Mesh
  21753. */
  21754. 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;
  21755. /**
  21756. * Creates a tube mesh.
  21757. * The tube is a parametric shape.
  21758. * It has no predefined shape. Its final shape will depend on the input parameters.
  21759. * Please consider using the same method from the MeshBuilder class instead
  21760. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21761. * @param name defines the name of the mesh to create
  21762. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21763. * @param radius sets the tube radius size
  21764. * @param tessellation is the number of sides on the tubular surface
  21765. * @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
  21766. * @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
  21767. * @param scene defines the hosting scene
  21768. * @param updatable defines if the mesh must be flagged as updatable
  21769. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21770. * @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)
  21771. * @returns a new Mesh
  21772. */
  21773. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21774. (i: number, distance: number): number;
  21775. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21776. /**
  21777. * Creates a polyhedron mesh.
  21778. * Please consider using the same method from the MeshBuilder class instead.
  21779. * * 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
  21780. * * The parameter `size` (positive float, default 1) sets the polygon size
  21781. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21782. * * 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`
  21783. * * 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
  21784. * * 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)`)
  21785. * * 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
  21786. * * 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
  21787. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21788. * * If you create a double-sided mesh, you can choose what parts of 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
  21789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21790. * @param name defines the name of the mesh to create
  21791. * @param options defines the options used to create the mesh
  21792. * @param scene defines the hosting scene
  21793. * @returns a new Mesh
  21794. */
  21795. static CreatePolyhedron(name: string, options: {
  21796. type?: number;
  21797. size?: number;
  21798. sizeX?: number;
  21799. sizeY?: number;
  21800. sizeZ?: number;
  21801. custom?: any;
  21802. faceUV?: Vector4[];
  21803. faceColors?: Color4[];
  21804. updatable?: boolean;
  21805. sideOrientation?: number;
  21806. }, scene: Scene): Mesh;
  21807. /**
  21808. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21809. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21810. * * 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`)
  21811. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21812. * * 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
  21813. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21814. * * If you create a double-sided mesh, you can choose what parts of 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
  21815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21816. * @param name defines the name of the mesh
  21817. * @param options defines the options used to create the mesh
  21818. * @param scene defines the hosting scene
  21819. * @returns a new Mesh
  21820. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21821. */
  21822. static CreateIcoSphere(name: string, options: {
  21823. radius?: number;
  21824. flat?: boolean;
  21825. subdivisions?: number;
  21826. sideOrientation?: number;
  21827. updatable?: boolean;
  21828. }, scene: Scene): Mesh;
  21829. /**
  21830. * Creates a decal mesh.
  21831. * Please consider using the same method from the MeshBuilder class instead.
  21832. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21833. * @param name defines the name of the mesh
  21834. * @param sourceMesh defines the mesh receiving the decal
  21835. * @param position sets the position of the decal in world coordinates
  21836. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21837. * @param size sets the decal scaling
  21838. * @param angle sets the angle to rotate the decal
  21839. * @returns a new Mesh
  21840. */
  21841. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21842. /**
  21843. * Prepare internal position array for software CPU skinning
  21844. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21845. */
  21846. setPositionsForCPUSkinning(): Float32Array;
  21847. /**
  21848. * Prepare internal normal array for software CPU skinning
  21849. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21850. */
  21851. setNormalsForCPUSkinning(): Float32Array;
  21852. /**
  21853. * Updates the vertex buffer by applying transformation from the bones
  21854. * @param skeleton defines the skeleton to apply to current mesh
  21855. * @returns the current mesh
  21856. */
  21857. applySkeleton(skeleton: Skeleton): Mesh;
  21858. /**
  21859. * 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
  21860. * @param meshes defines the list of meshes to scan
  21861. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21862. */
  21863. static MinMax(meshes: AbstractMesh[]): {
  21864. min: Vector3;
  21865. max: Vector3;
  21866. };
  21867. /**
  21868. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21869. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21870. * @returns a vector3
  21871. */
  21872. static Center(meshesOrMinMaxVector: {
  21873. min: Vector3;
  21874. max: Vector3;
  21875. } | AbstractMesh[]): Vector3;
  21876. /**
  21877. * Merge the array of meshes into a single mesh for performance reasons.
  21878. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21879. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21880. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21881. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21882. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21883. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21884. * @returns a new mesh
  21885. */
  21886. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21887. /** @hidden */
  21888. addInstance(instance: InstancedMesh): void;
  21889. /** @hidden */
  21890. removeInstance(instance: InstancedMesh): void;
  21891. }
  21892. }
  21893. declare module "babylonjs/Materials/material" {
  21894. import { IAnimatable } from "babylonjs/Misc/tools";
  21895. import { SmartArray } from "babylonjs/Misc/smartArray";
  21896. import { Observable } from "babylonjs/Misc/observable";
  21897. import { Nullable } from "babylonjs/types";
  21898. import { Scene } from "babylonjs/scene";
  21899. import { Matrix } from "babylonjs/Maths/math";
  21900. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21902. import { Mesh } from "babylonjs/Meshes/mesh";
  21903. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21904. import { Effect } from "babylonjs/Materials/effect";
  21905. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21906. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21907. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21908. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21909. import { Animation } from "babylonjs/Animations/animation";
  21910. /**
  21911. * Base class for the main features of a material in Babylon.js
  21912. */
  21913. export class Material implements IAnimatable {
  21914. /**
  21915. * Returns the triangle fill mode
  21916. */
  21917. static readonly TriangleFillMode: number;
  21918. /**
  21919. * Returns the wireframe mode
  21920. */
  21921. static readonly WireFrameFillMode: number;
  21922. /**
  21923. * Returns the point fill mode
  21924. */
  21925. static readonly PointFillMode: number;
  21926. /**
  21927. * Returns the point list draw mode
  21928. */
  21929. static readonly PointListDrawMode: number;
  21930. /**
  21931. * Returns the line list draw mode
  21932. */
  21933. static readonly LineListDrawMode: number;
  21934. /**
  21935. * Returns the line loop draw mode
  21936. */
  21937. static readonly LineLoopDrawMode: number;
  21938. /**
  21939. * Returns the line strip draw mode
  21940. */
  21941. static readonly LineStripDrawMode: number;
  21942. /**
  21943. * Returns the triangle strip draw mode
  21944. */
  21945. static readonly TriangleStripDrawMode: number;
  21946. /**
  21947. * Returns the triangle fan draw mode
  21948. */
  21949. static readonly TriangleFanDrawMode: number;
  21950. /**
  21951. * Stores the clock-wise side orientation
  21952. */
  21953. static readonly ClockWiseSideOrientation: number;
  21954. /**
  21955. * Stores the counter clock-wise side orientation
  21956. */
  21957. static readonly CounterClockWiseSideOrientation: number;
  21958. /**
  21959. * The dirty texture flag value
  21960. */
  21961. static readonly TextureDirtyFlag: number;
  21962. /**
  21963. * The dirty light flag value
  21964. */
  21965. static readonly LightDirtyFlag: number;
  21966. /**
  21967. * The dirty fresnel flag value
  21968. */
  21969. static readonly FresnelDirtyFlag: number;
  21970. /**
  21971. * The dirty attribute flag value
  21972. */
  21973. static readonly AttributesDirtyFlag: number;
  21974. /**
  21975. * The dirty misc flag value
  21976. */
  21977. static readonly MiscDirtyFlag: number;
  21978. /**
  21979. * The all dirty flag value
  21980. */
  21981. static readonly AllDirtyFlag: number;
  21982. /**
  21983. * The ID of the material
  21984. */
  21985. id: string;
  21986. /**
  21987. * Gets or sets the unique id of the material
  21988. */
  21989. uniqueId: number;
  21990. /**
  21991. * The name of the material
  21992. */
  21993. name: string;
  21994. /**
  21995. * Gets or sets user defined metadata
  21996. */
  21997. metadata: any;
  21998. /**
  21999. * For internal use only. Please do not use.
  22000. */
  22001. reservedDataStore: any;
  22002. /**
  22003. * Specifies if the ready state should be checked on each call
  22004. */
  22005. checkReadyOnEveryCall: boolean;
  22006. /**
  22007. * Specifies if the ready state should be checked once
  22008. */
  22009. checkReadyOnlyOnce: boolean;
  22010. /**
  22011. * The state of the material
  22012. */
  22013. state: string;
  22014. /**
  22015. * The alpha value of the material
  22016. */
  22017. protected _alpha: number;
  22018. /**
  22019. * List of inspectable custom properties (used by the Inspector)
  22020. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22021. */
  22022. inspectableCustomProperties: IInspectable[];
  22023. /**
  22024. * Sets the alpha value of the material
  22025. */
  22026. /**
  22027. * Gets the alpha value of the material
  22028. */
  22029. alpha: number;
  22030. /**
  22031. * Specifies if back face culling is enabled
  22032. */
  22033. protected _backFaceCulling: boolean;
  22034. /**
  22035. * Sets the back-face culling state
  22036. */
  22037. /**
  22038. * Gets the back-face culling state
  22039. */
  22040. backFaceCulling: boolean;
  22041. /**
  22042. * Stores the value for side orientation
  22043. */
  22044. sideOrientation: number;
  22045. /**
  22046. * Callback triggered when the material is compiled
  22047. */
  22048. onCompiled: (effect: Effect) => void;
  22049. /**
  22050. * Callback triggered when an error occurs
  22051. */
  22052. onError: (effect: Effect, errors: string) => void;
  22053. /**
  22054. * Callback triggered to get the render target textures
  22055. */
  22056. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22057. /**
  22058. * Gets a boolean indicating that current material needs to register RTT
  22059. */
  22060. readonly hasRenderTargetTextures: boolean;
  22061. /**
  22062. * Specifies if the material should be serialized
  22063. */
  22064. doNotSerialize: boolean;
  22065. /**
  22066. * @hidden
  22067. */
  22068. _storeEffectOnSubMeshes: boolean;
  22069. /**
  22070. * Stores the animations for the material
  22071. */
  22072. animations: Array<Animation>;
  22073. /**
  22074. * An event triggered when the material is disposed
  22075. */
  22076. onDisposeObservable: Observable<Material>;
  22077. /**
  22078. * An observer which watches for dispose events
  22079. */
  22080. private _onDisposeObserver;
  22081. private _onUnBindObservable;
  22082. /**
  22083. * Called during a dispose event
  22084. */
  22085. onDispose: () => void;
  22086. private _onBindObservable;
  22087. /**
  22088. * An event triggered when the material is bound
  22089. */
  22090. readonly onBindObservable: Observable<AbstractMesh>;
  22091. /**
  22092. * An observer which watches for bind events
  22093. */
  22094. private _onBindObserver;
  22095. /**
  22096. * Called during a bind event
  22097. */
  22098. onBind: (Mesh: AbstractMesh) => void;
  22099. /**
  22100. * An event triggered when the material is unbound
  22101. */
  22102. readonly onUnBindObservable: Observable<Material>;
  22103. /**
  22104. * Stores the value of the alpha mode
  22105. */
  22106. private _alphaMode;
  22107. /**
  22108. * Sets the value of the alpha mode.
  22109. *
  22110. * | Value | Type | Description |
  22111. * | --- | --- | --- |
  22112. * | 0 | ALPHA_DISABLE | |
  22113. * | 1 | ALPHA_ADD | |
  22114. * | 2 | ALPHA_COMBINE | |
  22115. * | 3 | ALPHA_SUBTRACT | |
  22116. * | 4 | ALPHA_MULTIPLY | |
  22117. * | 5 | ALPHA_MAXIMIZED | |
  22118. * | 6 | ALPHA_ONEONE | |
  22119. * | 7 | ALPHA_PREMULTIPLIED | |
  22120. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22121. * | 9 | ALPHA_INTERPOLATE | |
  22122. * | 10 | ALPHA_SCREENMODE | |
  22123. *
  22124. */
  22125. /**
  22126. * Gets the value of the alpha mode
  22127. */
  22128. alphaMode: number;
  22129. /**
  22130. * Stores the state of the need depth pre-pass value
  22131. */
  22132. private _needDepthPrePass;
  22133. /**
  22134. * Sets the need depth pre-pass value
  22135. */
  22136. /**
  22137. * Gets the depth pre-pass value
  22138. */
  22139. needDepthPrePass: boolean;
  22140. /**
  22141. * Specifies if depth writing should be disabled
  22142. */
  22143. disableDepthWrite: boolean;
  22144. /**
  22145. * Specifies if depth writing should be forced
  22146. */
  22147. forceDepthWrite: boolean;
  22148. /**
  22149. * Specifies if there should be a separate pass for culling
  22150. */
  22151. separateCullingPass: boolean;
  22152. /**
  22153. * Stores the state specifing if fog should be enabled
  22154. */
  22155. private _fogEnabled;
  22156. /**
  22157. * Sets the state for enabling fog
  22158. */
  22159. /**
  22160. * Gets the value of the fog enabled state
  22161. */
  22162. fogEnabled: boolean;
  22163. /**
  22164. * Stores the size of points
  22165. */
  22166. pointSize: number;
  22167. /**
  22168. * Stores the z offset value
  22169. */
  22170. zOffset: number;
  22171. /**
  22172. * Gets a value specifying if wireframe mode is enabled
  22173. */
  22174. /**
  22175. * Sets the state of wireframe mode
  22176. */
  22177. wireframe: boolean;
  22178. /**
  22179. * Gets the value specifying if point clouds are enabled
  22180. */
  22181. /**
  22182. * Sets the state of point cloud mode
  22183. */
  22184. pointsCloud: boolean;
  22185. /**
  22186. * Gets the material fill mode
  22187. */
  22188. /**
  22189. * Sets the material fill mode
  22190. */
  22191. fillMode: number;
  22192. /**
  22193. * @hidden
  22194. * Stores the effects for the material
  22195. */
  22196. _effect: Nullable<Effect>;
  22197. /**
  22198. * @hidden
  22199. * Specifies if the material was previously ready
  22200. */
  22201. _wasPreviouslyReady: boolean;
  22202. /**
  22203. * Specifies if uniform buffers should be used
  22204. */
  22205. private _useUBO;
  22206. /**
  22207. * Stores a reference to the scene
  22208. */
  22209. private _scene;
  22210. /**
  22211. * Stores the fill mode state
  22212. */
  22213. private _fillMode;
  22214. /**
  22215. * Specifies if the depth write state should be cached
  22216. */
  22217. private _cachedDepthWriteState;
  22218. /**
  22219. * Stores the uniform buffer
  22220. */
  22221. protected _uniformBuffer: UniformBuffer;
  22222. /** @hidden */
  22223. _indexInSceneMaterialArray: number;
  22224. /** @hidden */
  22225. meshMap: Nullable<{
  22226. [id: string]: AbstractMesh | undefined;
  22227. }>;
  22228. /**
  22229. * Creates a material instance
  22230. * @param name defines the name of the material
  22231. * @param scene defines the scene to reference
  22232. * @param doNotAdd specifies if the material should be added to the scene
  22233. */
  22234. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22235. /**
  22236. * Returns a string representation of the current material
  22237. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22238. * @returns a string with material information
  22239. */
  22240. toString(fullDetails?: boolean): string;
  22241. /**
  22242. * Gets the class name of the material
  22243. * @returns a string with the class name of the material
  22244. */
  22245. getClassName(): string;
  22246. /**
  22247. * Specifies if updates for the material been locked
  22248. */
  22249. readonly isFrozen: boolean;
  22250. /**
  22251. * Locks updates for the material
  22252. */
  22253. freeze(): void;
  22254. /**
  22255. * Unlocks updates for the material
  22256. */
  22257. unfreeze(): void;
  22258. /**
  22259. * Specifies if the material is ready to be used
  22260. * @param mesh defines the mesh to check
  22261. * @param useInstances specifies if instances should be used
  22262. * @returns a boolean indicating if the material is ready to be used
  22263. */
  22264. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22265. /**
  22266. * Specifies that the submesh is ready to be used
  22267. * @param mesh defines the mesh to check
  22268. * @param subMesh defines which submesh to check
  22269. * @param useInstances specifies that instances should be used
  22270. * @returns a boolean indicating that the submesh is ready or not
  22271. */
  22272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22273. /**
  22274. * Returns the material effect
  22275. * @returns the effect associated with the material
  22276. */
  22277. getEffect(): Nullable<Effect>;
  22278. /**
  22279. * Returns the current scene
  22280. * @returns a Scene
  22281. */
  22282. getScene(): Scene;
  22283. /**
  22284. * Specifies if the material will require alpha blending
  22285. * @returns a boolean specifying if alpha blending is needed
  22286. */
  22287. needAlphaBlending(): boolean;
  22288. /**
  22289. * Specifies if the mesh will require alpha blending
  22290. * @param mesh defines the mesh to check
  22291. * @returns a boolean specifying if alpha blending is needed for the mesh
  22292. */
  22293. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22294. /**
  22295. * Specifies if this material should be rendered in alpha test mode
  22296. * @returns a boolean specifying if an alpha test is needed.
  22297. */
  22298. needAlphaTesting(): boolean;
  22299. /**
  22300. * Gets the texture used for the alpha test
  22301. * @returns the texture to use for alpha testing
  22302. */
  22303. getAlphaTestTexture(): Nullable<BaseTexture>;
  22304. /**
  22305. * Marks the material to indicate that it needs to be re-calculated
  22306. */
  22307. markDirty(): void;
  22308. /** @hidden */
  22309. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22310. /**
  22311. * Binds the material to the mesh
  22312. * @param world defines the world transformation matrix
  22313. * @param mesh defines the mesh to bind the material to
  22314. */
  22315. bind(world: Matrix, mesh?: Mesh): void;
  22316. /**
  22317. * Binds the submesh to the material
  22318. * @param world defines the world transformation matrix
  22319. * @param mesh defines the mesh containing the submesh
  22320. * @param subMesh defines the submesh to bind the material to
  22321. */
  22322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22323. /**
  22324. * Binds the world matrix to the material
  22325. * @param world defines the world transformation matrix
  22326. */
  22327. bindOnlyWorldMatrix(world: Matrix): void;
  22328. /**
  22329. * Binds the scene's uniform buffer to the effect.
  22330. * @param effect defines the effect to bind to the scene uniform buffer
  22331. * @param sceneUbo defines the uniform buffer storing scene data
  22332. */
  22333. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22334. /**
  22335. * Binds the view matrix to the effect
  22336. * @param effect defines the effect to bind the view matrix to
  22337. */
  22338. bindView(effect: Effect): void;
  22339. /**
  22340. * Binds the view projection matrix to the effect
  22341. * @param effect defines the effect to bind the view projection matrix to
  22342. */
  22343. bindViewProjection(effect: Effect): void;
  22344. /**
  22345. * Specifies if material alpha testing should be turned on for the mesh
  22346. * @param mesh defines the mesh to check
  22347. */
  22348. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22349. /**
  22350. * Processes to execute after binding the material to a mesh
  22351. * @param mesh defines the rendered mesh
  22352. */
  22353. protected _afterBind(mesh?: Mesh): void;
  22354. /**
  22355. * Unbinds the material from the mesh
  22356. */
  22357. unbind(): void;
  22358. /**
  22359. * Gets the active textures from the material
  22360. * @returns an array of textures
  22361. */
  22362. getActiveTextures(): BaseTexture[];
  22363. /**
  22364. * Specifies if the material uses a texture
  22365. * @param texture defines the texture to check against the material
  22366. * @returns a boolean specifying if the material uses the texture
  22367. */
  22368. hasTexture(texture: BaseTexture): boolean;
  22369. /**
  22370. * Makes a duplicate of the material, and gives it a new name
  22371. * @param name defines the new name for the duplicated material
  22372. * @returns the cloned material
  22373. */
  22374. clone(name: string): Nullable<Material>;
  22375. /**
  22376. * Gets the meshes bound to the material
  22377. * @returns an array of meshes bound to the material
  22378. */
  22379. getBindedMeshes(): AbstractMesh[];
  22380. /**
  22381. * Force shader compilation
  22382. * @param mesh defines the mesh associated with this material
  22383. * @param onCompiled defines a function to execute once the material is compiled
  22384. * @param options defines the options to configure the compilation
  22385. */
  22386. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22387. clipPlane: boolean;
  22388. }>): void;
  22389. /**
  22390. * Force shader compilation
  22391. * @param mesh defines the mesh that will use this material
  22392. * @param options defines additional options for compiling the shaders
  22393. * @returns a promise that resolves when the compilation completes
  22394. */
  22395. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22396. clipPlane: boolean;
  22397. }>): Promise<void>;
  22398. private static readonly _ImageProcessingDirtyCallBack;
  22399. private static readonly _TextureDirtyCallBack;
  22400. private static readonly _FresnelDirtyCallBack;
  22401. private static readonly _MiscDirtyCallBack;
  22402. private static readonly _LightsDirtyCallBack;
  22403. private static readonly _AttributeDirtyCallBack;
  22404. private static _FresnelAndMiscDirtyCallBack;
  22405. private static _TextureAndMiscDirtyCallBack;
  22406. private static readonly _DirtyCallbackArray;
  22407. private static readonly _RunDirtyCallBacks;
  22408. /**
  22409. * Marks a define in the material to indicate that it needs to be re-computed
  22410. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22411. */
  22412. markAsDirty(flag: number): void;
  22413. /**
  22414. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22415. * @param func defines a function which checks material defines against the submeshes
  22416. */
  22417. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22418. /**
  22419. * Indicates that image processing needs to be re-calculated for all submeshes
  22420. */
  22421. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22422. /**
  22423. * Indicates that textures need to be re-calculated for all submeshes
  22424. */
  22425. protected _markAllSubMeshesAsTexturesDirty(): void;
  22426. /**
  22427. * Indicates that fresnel needs to be re-calculated for all submeshes
  22428. */
  22429. protected _markAllSubMeshesAsFresnelDirty(): void;
  22430. /**
  22431. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22432. */
  22433. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22434. /**
  22435. * Indicates that lights need to be re-calculated for all submeshes
  22436. */
  22437. protected _markAllSubMeshesAsLightsDirty(): void;
  22438. /**
  22439. * Indicates that attributes need to be re-calculated for all submeshes
  22440. */
  22441. protected _markAllSubMeshesAsAttributesDirty(): void;
  22442. /**
  22443. * Indicates that misc needs to be re-calculated for all submeshes
  22444. */
  22445. protected _markAllSubMeshesAsMiscDirty(): void;
  22446. /**
  22447. * Indicates that textures and misc need to be re-calculated for all submeshes
  22448. */
  22449. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22450. /**
  22451. * Disposes the material
  22452. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22453. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22454. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22455. */
  22456. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22457. /** @hidden */
  22458. private releaseVertexArrayObject;
  22459. /**
  22460. * Serializes this material
  22461. * @returns the serialized material object
  22462. */
  22463. serialize(): any;
  22464. /**
  22465. * Creates a material from parsed material data
  22466. * @param parsedMaterial defines parsed material data
  22467. * @param scene defines the hosting scene
  22468. * @param rootUrl defines the root URL to use to load textures
  22469. * @returns a new material
  22470. */
  22471. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22472. }
  22473. }
  22474. declare module "babylonjs/Meshes/subMesh" {
  22475. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22476. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22477. import { Engine } from "babylonjs/Engines/engine";
  22478. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22479. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22480. import { Effect } from "babylonjs/Materials/effect";
  22481. import { Collider } from "babylonjs/Collisions/collider";
  22482. import { Material } from "babylonjs/Materials/material";
  22483. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22485. import { Mesh } from "babylonjs/Meshes/mesh";
  22486. import { Ray } from "babylonjs/Culling/ray";
  22487. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22488. /**
  22489. * Base class for submeshes
  22490. */
  22491. export class BaseSubMesh {
  22492. /** @hidden */
  22493. _materialDefines: Nullable<MaterialDefines>;
  22494. /** @hidden */
  22495. _materialEffect: Nullable<Effect>;
  22496. /**
  22497. * Gets associated effect
  22498. */
  22499. readonly effect: Nullable<Effect>;
  22500. /**
  22501. * Sets associated effect (effect used to render this submesh)
  22502. * @param effect defines the effect to associate with
  22503. * @param defines defines the set of defines used to compile this effect
  22504. */
  22505. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22506. }
  22507. /**
  22508. * Defines a subdivision inside a mesh
  22509. */
  22510. export class SubMesh extends BaseSubMesh implements ICullable {
  22511. /** the material index to use */
  22512. materialIndex: number;
  22513. /** vertex index start */
  22514. verticesStart: number;
  22515. /** vertices count */
  22516. verticesCount: number;
  22517. /** index start */
  22518. indexStart: number;
  22519. /** indices count */
  22520. indexCount: number;
  22521. /** @hidden */
  22522. _linesIndexCount: number;
  22523. private _mesh;
  22524. private _renderingMesh;
  22525. private _boundingInfo;
  22526. private _linesIndexBuffer;
  22527. /** @hidden */
  22528. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22529. /** @hidden */
  22530. _trianglePlanes: Plane[];
  22531. /** @hidden */
  22532. _lastColliderTransformMatrix: Matrix;
  22533. /** @hidden */
  22534. _renderId: number;
  22535. /** @hidden */
  22536. _alphaIndex: number;
  22537. /** @hidden */
  22538. _distanceToCamera: number;
  22539. /** @hidden */
  22540. _id: number;
  22541. private _currentMaterial;
  22542. /**
  22543. * Add a new submesh to a mesh
  22544. * @param materialIndex defines the material index to use
  22545. * @param verticesStart defines vertex index start
  22546. * @param verticesCount defines vertices count
  22547. * @param indexStart defines index start
  22548. * @param indexCount defines indices count
  22549. * @param mesh defines the parent mesh
  22550. * @param renderingMesh defines an optional rendering mesh
  22551. * @param createBoundingBox defines if bounding box should be created for this submesh
  22552. * @returns the new submesh
  22553. */
  22554. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22555. /**
  22556. * Creates a new submesh
  22557. * @param materialIndex defines the material index to use
  22558. * @param verticesStart defines vertex index start
  22559. * @param verticesCount defines vertices count
  22560. * @param indexStart defines index start
  22561. * @param indexCount defines indices count
  22562. * @param mesh defines the parent mesh
  22563. * @param renderingMesh defines an optional rendering mesh
  22564. * @param createBoundingBox defines if bounding box should be created for this submesh
  22565. */
  22566. constructor(
  22567. /** the material index to use */
  22568. materialIndex: number,
  22569. /** vertex index start */
  22570. verticesStart: number,
  22571. /** vertices count */
  22572. verticesCount: number,
  22573. /** index start */
  22574. indexStart: number,
  22575. /** indices count */
  22576. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22577. /**
  22578. * Returns true if this submesh covers the entire parent mesh
  22579. * @ignorenaming
  22580. */
  22581. readonly IsGlobal: boolean;
  22582. /**
  22583. * Returns the submesh BoudingInfo object
  22584. * @returns current bounding info (or mesh's one if the submesh is global)
  22585. */
  22586. getBoundingInfo(): BoundingInfo;
  22587. /**
  22588. * Sets the submesh BoundingInfo
  22589. * @param boundingInfo defines the new bounding info to use
  22590. * @returns the SubMesh
  22591. */
  22592. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22593. /**
  22594. * Returns the mesh of the current submesh
  22595. * @return the parent mesh
  22596. */
  22597. getMesh(): AbstractMesh;
  22598. /**
  22599. * Returns the rendering mesh of the submesh
  22600. * @returns the rendering mesh (could be different from parent mesh)
  22601. */
  22602. getRenderingMesh(): Mesh;
  22603. /**
  22604. * Returns the submesh material
  22605. * @returns null or the current material
  22606. */
  22607. getMaterial(): Nullable<Material>;
  22608. /**
  22609. * Sets a new updated BoundingInfo object to the submesh
  22610. * @returns the SubMesh
  22611. */
  22612. refreshBoundingInfo(): SubMesh;
  22613. /** @hidden */
  22614. _checkCollision(collider: Collider): boolean;
  22615. /**
  22616. * Updates the submesh BoundingInfo
  22617. * @param world defines the world matrix to use to update the bounding info
  22618. * @returns the submesh
  22619. */
  22620. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22621. /**
  22622. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22623. * @param frustumPlanes defines the frustum planes
  22624. * @returns true if the submesh is intersecting with the frustum
  22625. */
  22626. isInFrustum(frustumPlanes: Plane[]): boolean;
  22627. /**
  22628. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22629. * @param frustumPlanes defines the frustum planes
  22630. * @returns true if the submesh is inside the frustum
  22631. */
  22632. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22633. /**
  22634. * Renders the submesh
  22635. * @param enableAlphaMode defines if alpha needs to be used
  22636. * @returns the submesh
  22637. */
  22638. render(enableAlphaMode: boolean): SubMesh;
  22639. /**
  22640. * @hidden
  22641. */
  22642. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22643. /**
  22644. * Checks if the submesh intersects with a ray
  22645. * @param ray defines the ray to test
  22646. * @returns true is the passed ray intersects the submesh bounding box
  22647. */
  22648. canIntersects(ray: Ray): boolean;
  22649. /**
  22650. * Intersects current submesh with a ray
  22651. * @param ray defines the ray to test
  22652. * @param positions defines mesh's positions array
  22653. * @param indices defines mesh's indices array
  22654. * @param fastCheck defines if only bounding info should be used
  22655. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22656. * @returns intersection info or null if no intersection
  22657. */
  22658. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22659. /** @hidden */
  22660. private _intersectLines;
  22661. /** @hidden */
  22662. private _intersectTriangles;
  22663. /** @hidden */
  22664. _rebuild(): void;
  22665. /**
  22666. * Creates a new submesh from the passed mesh
  22667. * @param newMesh defines the new hosting mesh
  22668. * @param newRenderingMesh defines an optional rendering mesh
  22669. * @returns the new submesh
  22670. */
  22671. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22672. /**
  22673. * Release associated resources
  22674. */
  22675. dispose(): void;
  22676. /**
  22677. * Gets the class name
  22678. * @returns the string "SubMesh".
  22679. */
  22680. getClassName(): string;
  22681. /**
  22682. * Creates a new submesh from indices data
  22683. * @param materialIndex the index of the main mesh material
  22684. * @param startIndex the index where to start the copy in the mesh indices array
  22685. * @param indexCount the number of indices to copy then from the startIndex
  22686. * @param mesh the main mesh to create the submesh from
  22687. * @param renderingMesh the optional rendering mesh
  22688. * @returns a new submesh
  22689. */
  22690. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22691. }
  22692. }
  22693. declare module "babylonjs/Meshes/geometry" {
  22694. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22695. import { Scene } from "babylonjs/scene";
  22696. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22697. import { Engine } from "babylonjs/Engines/engine";
  22698. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22699. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22700. import { Effect } from "babylonjs/Materials/effect";
  22701. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22702. import { Mesh } from "babylonjs/Meshes/mesh";
  22703. /**
  22704. * Class used to store geometry data (vertex buffers + index buffer)
  22705. */
  22706. export class Geometry implements IGetSetVerticesData {
  22707. /**
  22708. * Gets or sets the ID of the geometry
  22709. */
  22710. id: string;
  22711. /**
  22712. * Gets or sets the unique ID of the geometry
  22713. */
  22714. uniqueId: number;
  22715. /**
  22716. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22717. */
  22718. delayLoadState: number;
  22719. /**
  22720. * Gets the file containing the data to load when running in delay load state
  22721. */
  22722. delayLoadingFile: Nullable<string>;
  22723. /**
  22724. * Callback called when the geometry is updated
  22725. */
  22726. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22727. private _scene;
  22728. private _engine;
  22729. private _meshes;
  22730. private _totalVertices;
  22731. /** @hidden */
  22732. _indices: IndicesArray;
  22733. /** @hidden */
  22734. _vertexBuffers: {
  22735. [key: string]: VertexBuffer;
  22736. };
  22737. private _isDisposed;
  22738. private _extend;
  22739. private _boundingBias;
  22740. /** @hidden */
  22741. _delayInfo: Array<string>;
  22742. private _indexBuffer;
  22743. private _indexBufferIsUpdatable;
  22744. /** @hidden */
  22745. _boundingInfo: Nullable<BoundingInfo>;
  22746. /** @hidden */
  22747. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22748. /** @hidden */
  22749. _softwareSkinningFrameId: number;
  22750. private _vertexArrayObjects;
  22751. private _updatable;
  22752. /** @hidden */
  22753. _positions: Nullable<Vector3[]>;
  22754. /**
  22755. * 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
  22756. */
  22757. /**
  22758. * 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
  22759. */
  22760. boundingBias: Vector2;
  22761. /**
  22762. * Static function used to attach a new empty geometry to a mesh
  22763. * @param mesh defines the mesh to attach the geometry to
  22764. * @returns the new Geometry
  22765. */
  22766. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22767. /**
  22768. * Creates a new geometry
  22769. * @param id defines the unique ID
  22770. * @param scene defines the hosting scene
  22771. * @param vertexData defines the VertexData used to get geometry data
  22772. * @param updatable defines if geometry must be updatable (false by default)
  22773. * @param mesh defines the mesh that will be associated with the geometry
  22774. */
  22775. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22776. /**
  22777. * Gets the current extend of the geometry
  22778. */
  22779. readonly extend: {
  22780. minimum: Vector3;
  22781. maximum: Vector3;
  22782. };
  22783. /**
  22784. * Gets the hosting scene
  22785. * @returns the hosting Scene
  22786. */
  22787. getScene(): Scene;
  22788. /**
  22789. * Gets the hosting engine
  22790. * @returns the hosting Engine
  22791. */
  22792. getEngine(): Engine;
  22793. /**
  22794. * Defines if the geometry is ready to use
  22795. * @returns true if the geometry is ready to be used
  22796. */
  22797. isReady(): boolean;
  22798. /**
  22799. * Gets a value indicating that the geometry should not be serialized
  22800. */
  22801. readonly doNotSerialize: boolean;
  22802. /** @hidden */
  22803. _rebuild(): void;
  22804. /**
  22805. * Affects all geometry data in one call
  22806. * @param vertexData defines the geometry data
  22807. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22808. */
  22809. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22810. /**
  22811. * Set specific vertex data
  22812. * @param kind defines the data kind (Position, normal, etc...)
  22813. * @param data defines the vertex data to use
  22814. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22815. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22816. */
  22817. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22818. /**
  22819. * Removes a specific vertex data
  22820. * @param kind defines the data kind (Position, normal, etc...)
  22821. */
  22822. removeVerticesData(kind: string): void;
  22823. /**
  22824. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22825. * @param buffer defines the vertex buffer to use
  22826. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22827. */
  22828. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22829. /**
  22830. * Update a specific vertex buffer
  22831. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22832. * It will do nothing if the buffer is not updatable
  22833. * @param kind defines the data kind (Position, normal, etc...)
  22834. * @param data defines the data to use
  22835. * @param offset defines the offset in the target buffer where to store the data
  22836. * @param useBytes set to true if the offset is in bytes
  22837. */
  22838. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22839. /**
  22840. * Update a specific vertex buffer
  22841. * This function will create a new buffer if the current one is not updatable
  22842. * @param kind defines the data kind (Position, normal, etc...)
  22843. * @param data defines the data to use
  22844. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22845. */
  22846. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22847. private _updateBoundingInfo;
  22848. /** @hidden */
  22849. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22850. /**
  22851. * Gets total number of vertices
  22852. * @returns the total number of vertices
  22853. */
  22854. getTotalVertices(): number;
  22855. /**
  22856. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22857. * @param kind defines the data kind (Position, normal, etc...)
  22858. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22859. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22860. * @returns a float array containing vertex data
  22861. */
  22862. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22863. /**
  22864. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22865. * @param kind defines the data kind (Position, normal, etc...)
  22866. * @returns true if the vertex buffer with the specified kind is updatable
  22867. */
  22868. isVertexBufferUpdatable(kind: string): boolean;
  22869. /**
  22870. * Gets a specific vertex buffer
  22871. * @param kind defines the data kind (Position, normal, etc...)
  22872. * @returns a VertexBuffer
  22873. */
  22874. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22875. /**
  22876. * Returns all vertex buffers
  22877. * @return an object holding all vertex buffers indexed by kind
  22878. */
  22879. getVertexBuffers(): Nullable<{
  22880. [key: string]: VertexBuffer;
  22881. }>;
  22882. /**
  22883. * Gets a boolean indicating if specific vertex buffer is present
  22884. * @param kind defines the data kind (Position, normal, etc...)
  22885. * @returns true if data is present
  22886. */
  22887. isVerticesDataPresent(kind: string): boolean;
  22888. /**
  22889. * Gets a list of all attached data kinds (Position, normal, etc...)
  22890. * @returns a list of string containing all kinds
  22891. */
  22892. getVerticesDataKinds(): string[];
  22893. /**
  22894. * Update index buffer
  22895. * @param indices defines the indices to store in the index buffer
  22896. * @param offset defines the offset in the target buffer where to store the data
  22897. * @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)
  22898. */
  22899. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22900. /**
  22901. * Creates a new index buffer
  22902. * @param indices defines the indices to store in the index buffer
  22903. * @param totalVertices defines the total number of vertices (could be null)
  22904. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22905. */
  22906. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22907. /**
  22908. * Return the total number of indices
  22909. * @returns the total number of indices
  22910. */
  22911. getTotalIndices(): number;
  22912. /**
  22913. * Gets the index buffer array
  22914. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22916. * @returns the index buffer array
  22917. */
  22918. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22919. /**
  22920. * Gets the index buffer
  22921. * @return the index buffer
  22922. */
  22923. getIndexBuffer(): Nullable<WebGLBuffer>;
  22924. /** @hidden */
  22925. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22926. /**
  22927. * Release the associated resources for a specific mesh
  22928. * @param mesh defines the source mesh
  22929. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22930. */
  22931. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22932. /**
  22933. * Apply current geometry to a given mesh
  22934. * @param mesh defines the mesh to apply geometry to
  22935. */
  22936. applyToMesh(mesh: Mesh): void;
  22937. private _updateExtend;
  22938. private _applyToMesh;
  22939. private notifyUpdate;
  22940. /**
  22941. * Load the geometry if it was flagged as delay loaded
  22942. * @param scene defines the hosting scene
  22943. * @param onLoaded defines a callback called when the geometry is loaded
  22944. */
  22945. load(scene: Scene, onLoaded?: () => void): void;
  22946. private _queueLoad;
  22947. /**
  22948. * Invert the geometry to move from a right handed system to a left handed one.
  22949. */
  22950. toLeftHanded(): void;
  22951. /** @hidden */
  22952. _resetPointsArrayCache(): void;
  22953. /** @hidden */
  22954. _generatePointsArray(): boolean;
  22955. /**
  22956. * Gets a value indicating if the geometry is disposed
  22957. * @returns true if the geometry was disposed
  22958. */
  22959. isDisposed(): boolean;
  22960. private _disposeVertexArrayObjects;
  22961. /**
  22962. * Free all associated resources
  22963. */
  22964. dispose(): void;
  22965. /**
  22966. * Clone the current geometry into a new geometry
  22967. * @param id defines the unique ID of the new geometry
  22968. * @returns a new geometry object
  22969. */
  22970. copy(id: string): Geometry;
  22971. /**
  22972. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22973. * @return a JSON representation of the current geometry data (without the vertices data)
  22974. */
  22975. serialize(): any;
  22976. private toNumberArray;
  22977. /**
  22978. * Serialize all vertices data into a JSON oject
  22979. * @returns a JSON representation of the current geometry data
  22980. */
  22981. serializeVerticeData(): any;
  22982. /**
  22983. * Extracts a clone of a mesh geometry
  22984. * @param mesh defines the source mesh
  22985. * @param id defines the unique ID of the new geometry object
  22986. * @returns the new geometry object
  22987. */
  22988. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22989. /**
  22990. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22992. * Be aware Math.random() could cause collisions, but:
  22993. * "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"
  22994. * @returns a string containing a new GUID
  22995. */
  22996. static RandomId(): string;
  22997. /** @hidden */
  22998. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22999. private static _CleanMatricesWeights;
  23000. /**
  23001. * Create a new geometry from persisted data (Using .babylon file format)
  23002. * @param parsedVertexData defines the persisted data
  23003. * @param scene defines the hosting scene
  23004. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23005. * @returns the new geometry object
  23006. */
  23007. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23008. }
  23009. }
  23010. declare module "babylonjs/Meshes/mesh.vertexData" {
  23011. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23012. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23013. import { Geometry } from "babylonjs/Meshes/geometry";
  23014. import { Mesh } from "babylonjs/Meshes/mesh";
  23015. /**
  23016. * Define an interface for all classes that will get and set the data on vertices
  23017. */
  23018. export interface IGetSetVerticesData {
  23019. /**
  23020. * Gets a boolean indicating if specific vertex data is present
  23021. * @param kind defines the vertex data kind to use
  23022. * @returns true is data kind is present
  23023. */
  23024. isVerticesDataPresent(kind: string): boolean;
  23025. /**
  23026. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23027. * @param kind defines the data kind (Position, normal, etc...)
  23028. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23029. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23030. * @returns a float array containing vertex data
  23031. */
  23032. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23033. /**
  23034. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23035. * @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.
  23036. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23037. * @returns the indices array or an empty array if the mesh has no geometry
  23038. */
  23039. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23040. /**
  23041. * Set specific vertex data
  23042. * @param kind defines the data kind (Position, normal, etc...)
  23043. * @param data defines the vertex data to use
  23044. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23045. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23046. */
  23047. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23048. /**
  23049. * Update a specific associated vertex buffer
  23050. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23051. * - VertexBuffer.PositionKind
  23052. * - VertexBuffer.UVKind
  23053. * - VertexBuffer.UV2Kind
  23054. * - VertexBuffer.UV3Kind
  23055. * - VertexBuffer.UV4Kind
  23056. * - VertexBuffer.UV5Kind
  23057. * - VertexBuffer.UV6Kind
  23058. * - VertexBuffer.ColorKind
  23059. * - VertexBuffer.MatricesIndicesKind
  23060. * - VertexBuffer.MatricesIndicesExtraKind
  23061. * - VertexBuffer.MatricesWeightsKind
  23062. * - VertexBuffer.MatricesWeightsExtraKind
  23063. * @param data defines the data source
  23064. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23065. * @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)
  23066. */
  23067. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23068. /**
  23069. * Creates a new index buffer
  23070. * @param indices defines the indices to store in the index buffer
  23071. * @param totalVertices defines the total number of vertices (could be null)
  23072. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23073. */
  23074. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23075. }
  23076. /**
  23077. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23078. */
  23079. export class VertexData {
  23080. /**
  23081. * Mesh side orientation : usually the external or front surface
  23082. */
  23083. static readonly FRONTSIDE: number;
  23084. /**
  23085. * Mesh side orientation : usually the internal or back surface
  23086. */
  23087. static readonly BACKSIDE: number;
  23088. /**
  23089. * Mesh side orientation : both internal and external or front and back surfaces
  23090. */
  23091. static readonly DOUBLESIDE: number;
  23092. /**
  23093. * Mesh side orientation : by default, `FRONTSIDE`
  23094. */
  23095. static readonly DEFAULTSIDE: number;
  23096. /**
  23097. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23098. */
  23099. positions: Nullable<FloatArray>;
  23100. /**
  23101. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23102. */
  23103. normals: Nullable<FloatArray>;
  23104. /**
  23105. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23106. */
  23107. tangents: Nullable<FloatArray>;
  23108. /**
  23109. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23110. */
  23111. uvs: Nullable<FloatArray>;
  23112. /**
  23113. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23114. */
  23115. uvs2: Nullable<FloatArray>;
  23116. /**
  23117. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23118. */
  23119. uvs3: Nullable<FloatArray>;
  23120. /**
  23121. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23122. */
  23123. uvs4: Nullable<FloatArray>;
  23124. /**
  23125. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23126. */
  23127. uvs5: Nullable<FloatArray>;
  23128. /**
  23129. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23130. */
  23131. uvs6: Nullable<FloatArray>;
  23132. /**
  23133. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23134. */
  23135. colors: Nullable<FloatArray>;
  23136. /**
  23137. * 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).
  23138. */
  23139. matricesIndices: Nullable<FloatArray>;
  23140. /**
  23141. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23142. */
  23143. matricesWeights: Nullable<FloatArray>;
  23144. /**
  23145. * An array extending the number of possible indices
  23146. */
  23147. matricesIndicesExtra: Nullable<FloatArray>;
  23148. /**
  23149. * An array extending the number of possible weights when the number of indices is extended
  23150. */
  23151. matricesWeightsExtra: Nullable<FloatArray>;
  23152. /**
  23153. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23154. */
  23155. indices: Nullable<IndicesArray>;
  23156. /**
  23157. * Uses the passed data array to set the set the values for the specified kind of data
  23158. * @param data a linear array of floating numbers
  23159. * @param kind the type of data that is being set, eg positions, colors etc
  23160. */
  23161. set(data: FloatArray, kind: string): void;
  23162. /**
  23163. * Associates the vertexData to the passed Mesh.
  23164. * Sets it as updatable or not (default `false`)
  23165. * @param mesh the mesh the vertexData is applied to
  23166. * @param updatable when used and having the value true allows new data to update the vertexData
  23167. * @returns the VertexData
  23168. */
  23169. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23170. /**
  23171. * Associates the vertexData to the passed Geometry.
  23172. * Sets it as updatable or not (default `false`)
  23173. * @param geometry the geometry the vertexData is applied to
  23174. * @param updatable when used and having the value true allows new data to update the vertexData
  23175. * @returns VertexData
  23176. */
  23177. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23178. /**
  23179. * Updates the associated mesh
  23180. * @param mesh the mesh to be updated
  23181. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23182. * @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
  23183. * @returns VertexData
  23184. */
  23185. updateMesh(mesh: Mesh): VertexData;
  23186. /**
  23187. * Updates the associated geometry
  23188. * @param geometry the geometry to be updated
  23189. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23190. * @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
  23191. * @returns VertexData.
  23192. */
  23193. updateGeometry(geometry: Geometry): VertexData;
  23194. private _applyTo;
  23195. private _update;
  23196. /**
  23197. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23198. * @param matrix the transforming matrix
  23199. * @returns the VertexData
  23200. */
  23201. transform(matrix: Matrix): VertexData;
  23202. /**
  23203. * Merges the passed VertexData into the current one
  23204. * @param other the VertexData to be merged into the current one
  23205. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23206. * @returns the modified VertexData
  23207. */
  23208. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23209. private _mergeElement;
  23210. private _validate;
  23211. /**
  23212. * Serializes the VertexData
  23213. * @returns a serialized object
  23214. */
  23215. serialize(): any;
  23216. /**
  23217. * Extracts the vertexData from a mesh
  23218. * @param mesh the mesh from which to extract the VertexData
  23219. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23220. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23221. * @returns the object VertexData associated to the passed mesh
  23222. */
  23223. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23224. /**
  23225. * Extracts the vertexData from the geometry
  23226. * @param geometry the geometry from which to extract the VertexData
  23227. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23228. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23229. * @returns the object VertexData associated to the passed mesh
  23230. */
  23231. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23232. private static _ExtractFrom;
  23233. /**
  23234. * Creates the VertexData for a Ribbon
  23235. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23236. * * pathArray array of paths, each of which an array of successive Vector3
  23237. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23238. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23239. * * 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
  23240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23241. * * 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)
  23242. * * 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)
  23243. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23244. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23245. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23246. * @returns the VertexData of the ribbon
  23247. */
  23248. static CreateRibbon(options: {
  23249. pathArray: Vector3[][];
  23250. closeArray?: boolean;
  23251. closePath?: boolean;
  23252. offset?: number;
  23253. sideOrientation?: number;
  23254. frontUVs?: Vector4;
  23255. backUVs?: Vector4;
  23256. invertUV?: boolean;
  23257. uvs?: Vector2[];
  23258. colors?: Color4[];
  23259. }): VertexData;
  23260. /**
  23261. * Creates the VertexData for a box
  23262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23263. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23264. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23265. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23266. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23267. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23268. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23270. * * 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)
  23271. * * 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)
  23272. * @returns the VertexData of the box
  23273. */
  23274. static CreateBox(options: {
  23275. size?: number;
  23276. width?: number;
  23277. height?: number;
  23278. depth?: number;
  23279. faceUV?: Vector4[];
  23280. faceColors?: Color4[];
  23281. sideOrientation?: number;
  23282. frontUVs?: Vector4;
  23283. backUVs?: Vector4;
  23284. }): VertexData;
  23285. /**
  23286. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23287. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23288. * * segments sets the number of horizontal strips optional, default 32
  23289. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23290. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23291. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23292. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23293. * * 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
  23294. * * 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
  23295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23296. * * 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)
  23297. * * 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)
  23298. * @returns the VertexData of the ellipsoid
  23299. */
  23300. static CreateSphere(options: {
  23301. segments?: number;
  23302. diameter?: number;
  23303. diameterX?: number;
  23304. diameterY?: number;
  23305. diameterZ?: number;
  23306. arc?: number;
  23307. slice?: number;
  23308. sideOrientation?: number;
  23309. frontUVs?: Vector4;
  23310. backUVs?: Vector4;
  23311. }): VertexData;
  23312. /**
  23313. * Creates the VertexData for a cylinder, cone or prism
  23314. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23315. * * height sets the height (y direction) of the cylinder, optional, default 2
  23316. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23317. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23318. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23319. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23320. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23321. * * 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
  23322. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23323. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23324. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23325. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23327. * * 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)
  23328. * * 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)
  23329. * @returns the VertexData of the cylinder, cone or prism
  23330. */
  23331. static CreateCylinder(options: {
  23332. height?: number;
  23333. diameterTop?: number;
  23334. diameterBottom?: number;
  23335. diameter?: number;
  23336. tessellation?: number;
  23337. subdivisions?: number;
  23338. arc?: number;
  23339. faceColors?: Color4[];
  23340. faceUV?: Vector4[];
  23341. hasRings?: boolean;
  23342. enclose?: boolean;
  23343. sideOrientation?: number;
  23344. frontUVs?: Vector4;
  23345. backUVs?: Vector4;
  23346. }): VertexData;
  23347. /**
  23348. * Creates the VertexData for a torus
  23349. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23350. * * diameter the diameter of the torus, optional default 1
  23351. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23352. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23353. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23354. * * 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)
  23355. * * 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)
  23356. * @returns the VertexData of the torus
  23357. */
  23358. static CreateTorus(options: {
  23359. diameter?: number;
  23360. thickness?: number;
  23361. tessellation?: number;
  23362. sideOrientation?: number;
  23363. frontUVs?: Vector4;
  23364. backUVs?: Vector4;
  23365. }): VertexData;
  23366. /**
  23367. * Creates the VertexData of the LineSystem
  23368. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23369. * - lines an array of lines, each line being an array of successive Vector3
  23370. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23371. * @returns the VertexData of the LineSystem
  23372. */
  23373. static CreateLineSystem(options: {
  23374. lines: Vector3[][];
  23375. colors?: Nullable<Color4[][]>;
  23376. }): VertexData;
  23377. /**
  23378. * Create the VertexData for a DashedLines
  23379. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23380. * - points an array successive Vector3
  23381. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23382. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23383. * - dashNb the intended total number of dashes, optional, default 200
  23384. * @returns the VertexData for the DashedLines
  23385. */
  23386. static CreateDashedLines(options: {
  23387. points: Vector3[];
  23388. dashSize?: number;
  23389. gapSize?: number;
  23390. dashNb?: number;
  23391. }): VertexData;
  23392. /**
  23393. * Creates the VertexData for a Ground
  23394. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23395. * - width the width (x direction) of the ground, optional, default 1
  23396. * - height the height (z direction) of the ground, optional, default 1
  23397. * - subdivisions the number of subdivisions per side, optional, default 1
  23398. * @returns the VertexData of the Ground
  23399. */
  23400. static CreateGround(options: {
  23401. width?: number;
  23402. height?: number;
  23403. subdivisions?: number;
  23404. subdivisionsX?: number;
  23405. subdivisionsY?: number;
  23406. }): VertexData;
  23407. /**
  23408. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23409. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23410. * * xmin the ground minimum X coordinate, optional, default -1
  23411. * * zmin the ground minimum Z coordinate, optional, default -1
  23412. * * xmax the ground maximum X coordinate, optional, default 1
  23413. * * zmax the ground maximum Z coordinate, optional, default 1
  23414. * * 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}
  23415. * * 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}
  23416. * @returns the VertexData of the TiledGround
  23417. */
  23418. static CreateTiledGround(options: {
  23419. xmin: number;
  23420. zmin: number;
  23421. xmax: number;
  23422. zmax: number;
  23423. subdivisions?: {
  23424. w: number;
  23425. h: number;
  23426. };
  23427. precision?: {
  23428. w: number;
  23429. h: number;
  23430. };
  23431. }): VertexData;
  23432. /**
  23433. * Creates the VertexData of the Ground designed from a heightmap
  23434. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23435. * * width the width (x direction) of the ground
  23436. * * height the height (z direction) of the ground
  23437. * * subdivisions the number of subdivisions per side
  23438. * * minHeight the minimum altitude on the ground, optional, default 0
  23439. * * maxHeight the maximum altitude on the ground, optional default 1
  23440. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23441. * * buffer the array holding the image color data
  23442. * * bufferWidth the width of image
  23443. * * bufferHeight the height of image
  23444. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23445. * @returns the VertexData of the Ground designed from a heightmap
  23446. */
  23447. static CreateGroundFromHeightMap(options: {
  23448. width: number;
  23449. height: number;
  23450. subdivisions: number;
  23451. minHeight: number;
  23452. maxHeight: number;
  23453. colorFilter: Color3;
  23454. buffer: Uint8Array;
  23455. bufferWidth: number;
  23456. bufferHeight: number;
  23457. alphaFilter: number;
  23458. }): VertexData;
  23459. /**
  23460. * Creates the VertexData for a Plane
  23461. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23462. * * size sets the width and height of the plane to the value of size, optional default 1
  23463. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23464. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23465. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23466. * * 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)
  23467. * * 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)
  23468. * @returns the VertexData of the box
  23469. */
  23470. static CreatePlane(options: {
  23471. size?: number;
  23472. width?: number;
  23473. height?: number;
  23474. sideOrientation?: number;
  23475. frontUVs?: Vector4;
  23476. backUVs?: Vector4;
  23477. }): VertexData;
  23478. /**
  23479. * Creates the VertexData of the Disc or regular Polygon
  23480. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23481. * * radius the radius of the disc, optional default 0.5
  23482. * * tessellation the number of polygon sides, optional, default 64
  23483. * * 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
  23484. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23485. * * 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)
  23486. * * 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)
  23487. * @returns the VertexData of the box
  23488. */
  23489. static CreateDisc(options: {
  23490. radius?: number;
  23491. tessellation?: number;
  23492. arc?: number;
  23493. sideOrientation?: number;
  23494. frontUVs?: Vector4;
  23495. backUVs?: Vector4;
  23496. }): VertexData;
  23497. /**
  23498. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23499. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23500. * @param polygon a mesh built from polygonTriangulation.build()
  23501. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23502. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23503. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23504. * @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)
  23505. * @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)
  23506. * @returns the VertexData of the Polygon
  23507. */
  23508. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23509. /**
  23510. * Creates the VertexData of the IcoSphere
  23511. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23512. * * radius the radius of the IcoSphere, optional default 1
  23513. * * radiusX allows stretching in the x direction, optional, default radius
  23514. * * radiusY allows stretching in the y direction, optional, default radius
  23515. * * radiusZ allows stretching in the z direction, optional, default radius
  23516. * * flat when true creates a flat shaded mesh, optional, default true
  23517. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23518. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23519. * * 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)
  23520. * * 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)
  23521. * @returns the VertexData of the IcoSphere
  23522. */
  23523. static CreateIcoSphere(options: {
  23524. radius?: number;
  23525. radiusX?: number;
  23526. radiusY?: number;
  23527. radiusZ?: number;
  23528. flat?: boolean;
  23529. subdivisions?: number;
  23530. sideOrientation?: number;
  23531. frontUVs?: Vector4;
  23532. backUVs?: Vector4;
  23533. }): VertexData;
  23534. /**
  23535. * Creates the VertexData for a Polyhedron
  23536. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23537. * * type provided types are:
  23538. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23539. * * 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)
  23540. * * size the size of the IcoSphere, optional default 1
  23541. * * sizeX allows stretching in the x direction, optional, default size
  23542. * * sizeY allows stretching in the y direction, optional, default size
  23543. * * sizeZ allows stretching in the z direction, optional, default size
  23544. * * 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
  23545. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23546. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23547. * * flat when true creates a flat shaded mesh, optional, default true
  23548. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23550. * * 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)
  23551. * * 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)
  23552. * @returns the VertexData of the Polyhedron
  23553. */
  23554. static CreatePolyhedron(options: {
  23555. type?: number;
  23556. size?: number;
  23557. sizeX?: number;
  23558. sizeY?: number;
  23559. sizeZ?: number;
  23560. custom?: any;
  23561. faceUV?: Vector4[];
  23562. faceColors?: Color4[];
  23563. flat?: boolean;
  23564. sideOrientation?: number;
  23565. frontUVs?: Vector4;
  23566. backUVs?: Vector4;
  23567. }): VertexData;
  23568. /**
  23569. * Creates the VertexData for a TorusKnot
  23570. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23571. * * radius the radius of the torus knot, optional, default 2
  23572. * * tube the thickness of the tube, optional, default 0.5
  23573. * * radialSegments the number of sides on each tube segments, optional, default 32
  23574. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23575. * * p the number of windings around the z axis, optional, default 2
  23576. * * q the number of windings around the x axis, optional, default 3
  23577. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23578. * * 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)
  23579. * * 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)
  23580. * @returns the VertexData of the Torus Knot
  23581. */
  23582. static CreateTorusKnot(options: {
  23583. radius?: number;
  23584. tube?: number;
  23585. radialSegments?: number;
  23586. tubularSegments?: number;
  23587. p?: number;
  23588. q?: number;
  23589. sideOrientation?: number;
  23590. frontUVs?: Vector4;
  23591. backUVs?: Vector4;
  23592. }): VertexData;
  23593. /**
  23594. * Compute normals for given positions and indices
  23595. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23596. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23597. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23598. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23599. * * facetNormals : optional array of facet normals (vector3)
  23600. * * facetPositions : optional array of facet positions (vector3)
  23601. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23602. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23603. * * bInfo : optional bounding info, required for facetPartitioning computation
  23604. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23605. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23606. * * useRightHandedSystem: optional boolean to for right handed system computation
  23607. * * depthSort : optional boolean to enable the facet depth sort computation
  23608. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23609. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23610. */
  23611. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23612. facetNormals?: any;
  23613. facetPositions?: any;
  23614. facetPartitioning?: any;
  23615. ratio?: number;
  23616. bInfo?: any;
  23617. bbSize?: Vector3;
  23618. subDiv?: any;
  23619. useRightHandedSystem?: boolean;
  23620. depthSort?: boolean;
  23621. distanceTo?: Vector3;
  23622. depthSortedFacets?: any;
  23623. }): void;
  23624. /** @hidden */
  23625. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23626. /**
  23627. * Applies VertexData created from the imported parameters to the geometry
  23628. * @param parsedVertexData the parsed data from an imported file
  23629. * @param geometry the geometry to apply the VertexData to
  23630. */
  23631. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23632. }
  23633. }
  23634. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23635. import { Nullable } from "babylonjs/types";
  23636. import { Scene } from "babylonjs/scene";
  23637. import { Vector4 } from "babylonjs/Maths/math";
  23638. import { Mesh } from "babylonjs/Meshes/mesh";
  23639. /**
  23640. * Class containing static functions to help procedurally build meshes
  23641. */
  23642. export class DiscBuilder {
  23643. /**
  23644. * Creates a plane polygonal mesh. By default, this is a disc
  23645. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23646. * * 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
  23647. * * 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
  23648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23651. * @param name defines the name of the mesh
  23652. * @param options defines the options used to create the mesh
  23653. * @param scene defines the hosting scene
  23654. * @returns the plane polygonal mesh
  23655. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23656. */
  23657. static CreateDisc(name: string, options: {
  23658. radius?: number;
  23659. tessellation?: number;
  23660. arc?: number;
  23661. updatable?: boolean;
  23662. sideOrientation?: number;
  23663. frontUVs?: Vector4;
  23664. backUVs?: Vector4;
  23665. }, scene?: Nullable<Scene>): Mesh;
  23666. }
  23667. }
  23668. declare module "babylonjs/Particles/solidParticleSystem" {
  23669. import { Vector3 } from "babylonjs/Maths/math";
  23670. import { Mesh } from "babylonjs/Meshes/mesh";
  23671. import { Scene, IDisposable } from "babylonjs/scene";
  23672. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23673. /**
  23674. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23675. *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.
  23676. * The SPS is also a particle system. It provides some methods to manage the particles.
  23677. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23678. *
  23679. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23680. */
  23681. export class SolidParticleSystem implements IDisposable {
  23682. /**
  23683. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23684. * Example : var p = SPS.particles[i];
  23685. */
  23686. particles: SolidParticle[];
  23687. /**
  23688. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23689. */
  23690. nbParticles: number;
  23691. /**
  23692. * If the particles must ever face the camera (default false). Useful for planar particles.
  23693. */
  23694. billboard: boolean;
  23695. /**
  23696. * Recompute normals when adding a shape
  23697. */
  23698. recomputeNormals: boolean;
  23699. /**
  23700. * This a counter ofr your own usage. It's not set by any SPS functions.
  23701. */
  23702. counter: number;
  23703. /**
  23704. * The SPS name. This name is also given to the underlying mesh.
  23705. */
  23706. name: string;
  23707. /**
  23708. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23709. */
  23710. mesh: Mesh;
  23711. /**
  23712. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23713. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23714. */
  23715. vars: any;
  23716. /**
  23717. * This array is populated when the SPS is set as 'pickable'.
  23718. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23719. * Each element of this array is an object `{idx: int, faceId: int}`.
  23720. * `idx` is the picked particle index in the `SPS.particles` array
  23721. * `faceId` is the picked face index counted within this particle.
  23722. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23723. */
  23724. pickedParticles: {
  23725. idx: number;
  23726. faceId: number;
  23727. }[];
  23728. /**
  23729. * This array is populated when `enableDepthSort` is set to true.
  23730. * Each element of this array is an instance of the class DepthSortedParticle.
  23731. */
  23732. depthSortedParticles: DepthSortedParticle[];
  23733. /**
  23734. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23735. * @hidden
  23736. */
  23737. _bSphereOnly: boolean;
  23738. /**
  23739. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23740. * @hidden
  23741. */
  23742. _bSphereRadiusFactor: number;
  23743. private _scene;
  23744. private _positions;
  23745. private _indices;
  23746. private _normals;
  23747. private _colors;
  23748. private _uvs;
  23749. private _indices32;
  23750. private _positions32;
  23751. private _normals32;
  23752. private _fixedNormal32;
  23753. private _colors32;
  23754. private _uvs32;
  23755. private _index;
  23756. private _updatable;
  23757. private _pickable;
  23758. private _isVisibilityBoxLocked;
  23759. private _alwaysVisible;
  23760. private _depthSort;
  23761. private _shapeCounter;
  23762. private _copy;
  23763. private _color;
  23764. private _computeParticleColor;
  23765. private _computeParticleTexture;
  23766. private _computeParticleRotation;
  23767. private _computeParticleVertex;
  23768. private _computeBoundingBox;
  23769. private _depthSortParticles;
  23770. private _camera;
  23771. private _mustUnrotateFixedNormals;
  23772. private _particlesIntersect;
  23773. private _needs32Bits;
  23774. /**
  23775. * Creates a SPS (Solid Particle System) object.
  23776. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23777. * @param scene (Scene) is the scene in which the SPS is added.
  23778. * @param options defines the options of the sps e.g.
  23779. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23780. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23781. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23782. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23783. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23784. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23785. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23786. */
  23787. constructor(name: string, scene: Scene, options?: {
  23788. updatable?: boolean;
  23789. isPickable?: boolean;
  23790. enableDepthSort?: boolean;
  23791. particleIntersection?: boolean;
  23792. boundingSphereOnly?: boolean;
  23793. bSphereRadiusFactor?: number;
  23794. });
  23795. /**
  23796. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23797. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23798. * @returns the created mesh
  23799. */
  23800. buildMesh(): Mesh;
  23801. /**
  23802. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23803. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23804. * Thus the particles generated from `digest()` have their property `position` set yet.
  23805. * @param mesh ( Mesh ) is the mesh to be digested
  23806. * @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
  23807. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23808. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23809. * @returns the current SPS
  23810. */
  23811. digest(mesh: Mesh, options?: {
  23812. facetNb?: number;
  23813. number?: number;
  23814. delta?: number;
  23815. }): SolidParticleSystem;
  23816. private _unrotateFixedNormals;
  23817. private _resetCopy;
  23818. private _meshBuilder;
  23819. private _posToShape;
  23820. private _uvsToShapeUV;
  23821. private _addParticle;
  23822. /**
  23823. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23824. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23825. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23826. * @param nb (positive integer) the number of particles to be created from this model
  23827. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23828. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23829. * @returns the number of shapes in the system
  23830. */
  23831. addShape(mesh: Mesh, nb: number, options?: {
  23832. positionFunction?: any;
  23833. vertexFunction?: any;
  23834. }): number;
  23835. private _rebuildParticle;
  23836. /**
  23837. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23838. * @returns the SPS.
  23839. */
  23840. rebuildMesh(): SolidParticleSystem;
  23841. /**
  23842. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23843. * This method calls `updateParticle()` for each particle of the SPS.
  23844. * For an animated SPS, it is usually called within the render loop.
  23845. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23846. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23847. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23848. * @returns the SPS.
  23849. */
  23850. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23851. /**
  23852. * Disposes the SPS.
  23853. */
  23854. dispose(): void;
  23855. /**
  23856. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23857. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23858. * @returns the SPS.
  23859. */
  23860. refreshVisibleSize(): SolidParticleSystem;
  23861. /**
  23862. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23863. * @param size the size (float) of the visibility box
  23864. * note : this doesn't lock the SPS mesh bounding box.
  23865. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23866. */
  23867. setVisibilityBox(size: number): void;
  23868. /**
  23869. * Gets whether the SPS as always visible or not
  23870. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23871. */
  23872. /**
  23873. * Sets the SPS as always visible or not
  23874. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23875. */
  23876. isAlwaysVisible: boolean;
  23877. /**
  23878. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23879. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23880. */
  23881. /**
  23882. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23883. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23884. */
  23885. isVisibilityBoxLocked: boolean;
  23886. /**
  23887. * Tells to `setParticles()` to compute the particle rotations or not.
  23888. * Default value : true. The SPS is faster when it's set to false.
  23889. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23890. */
  23891. /**
  23892. * Gets if `setParticles()` computes the particle rotations or not.
  23893. * Default value : true. The SPS is faster when it's set to false.
  23894. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23895. */
  23896. computeParticleRotation: boolean;
  23897. /**
  23898. * Tells to `setParticles()` to compute the particle colors or not.
  23899. * Default value : true. The SPS is faster when it's set to false.
  23900. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23901. */
  23902. /**
  23903. * Gets if `setParticles()` computes the particle colors or not.
  23904. * Default value : true. The SPS is faster when it's set to false.
  23905. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23906. */
  23907. computeParticleColor: boolean;
  23908. /**
  23909. * Gets if `setParticles()` computes the particle textures or not.
  23910. * Default value : true. The SPS is faster when it's set to false.
  23911. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23912. */
  23913. computeParticleTexture: boolean;
  23914. /**
  23915. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23916. * Default value : false. The SPS is faster when it's set to false.
  23917. * Note : the particle custom vertex positions aren't stored values.
  23918. */
  23919. /**
  23920. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23921. * Default value : false. The SPS is faster when it's set to false.
  23922. * Note : the particle custom vertex positions aren't stored values.
  23923. */
  23924. computeParticleVertex: boolean;
  23925. /**
  23926. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23927. */
  23928. /**
  23929. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23930. */
  23931. computeBoundingBox: boolean;
  23932. /**
  23933. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23934. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23935. * Default : `true`
  23936. */
  23937. /**
  23938. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23939. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23940. * Default : `true`
  23941. */
  23942. depthSortParticles: boolean;
  23943. /**
  23944. * This function does nothing. It may be overwritten to set all the particle first values.
  23945. * The SPS doesn't call this function, you may have to call it by your own.
  23946. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23947. */
  23948. initParticles(): void;
  23949. /**
  23950. * This function does nothing. It may be overwritten to recycle a particle.
  23951. * The SPS doesn't call this function, you may have to call it by your own.
  23952. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23953. * @param particle The particle to recycle
  23954. * @returns the recycled particle
  23955. */
  23956. recycleParticle(particle: SolidParticle): SolidParticle;
  23957. /**
  23958. * Updates a particle : this function should be overwritten by the user.
  23959. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23960. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23961. * @example : just set a particle position or velocity and recycle conditions
  23962. * @param particle The particle to update
  23963. * @returns the updated particle
  23964. */
  23965. updateParticle(particle: SolidParticle): SolidParticle;
  23966. /**
  23967. * Updates a vertex of a particle : it can be overwritten by the user.
  23968. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23969. * @param particle the current particle
  23970. * @param vertex the current index of the current particle
  23971. * @param pt the index of the current vertex in the particle shape
  23972. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23973. * @example : just set a vertex particle position
  23974. * @returns the updated vertex
  23975. */
  23976. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23977. /**
  23978. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23979. * This does nothing and may be overwritten by the user.
  23980. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23981. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23982. * @param update the boolean update value actually passed to setParticles()
  23983. */
  23984. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23985. /**
  23986. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23987. * This will be passed three parameters.
  23988. * This does nothing and may be overwritten by the user.
  23989. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23990. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23991. * @param update the boolean update value actually passed to setParticles()
  23992. */
  23993. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23994. }
  23995. }
  23996. declare module "babylonjs/Particles/solidParticle" {
  23997. import { Nullable } from "babylonjs/types";
  23998. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23999. import { Mesh } from "babylonjs/Meshes/mesh";
  24000. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24001. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24002. /**
  24003. * Represents one particle of a solid particle system.
  24004. */
  24005. export class SolidParticle {
  24006. /**
  24007. * particle global index
  24008. */
  24009. idx: number;
  24010. /**
  24011. * The color of the particle
  24012. */
  24013. color: Nullable<Color4>;
  24014. /**
  24015. * The world space position of the particle.
  24016. */
  24017. position: Vector3;
  24018. /**
  24019. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24020. */
  24021. rotation: Vector3;
  24022. /**
  24023. * The world space rotation quaternion of the particle.
  24024. */
  24025. rotationQuaternion: Nullable<Quaternion>;
  24026. /**
  24027. * The scaling of the particle.
  24028. */
  24029. scaling: Vector3;
  24030. /**
  24031. * The uvs of the particle.
  24032. */
  24033. uvs: Vector4;
  24034. /**
  24035. * The current speed of the particle.
  24036. */
  24037. velocity: Vector3;
  24038. /**
  24039. * The pivot point in the particle local space.
  24040. */
  24041. pivot: Vector3;
  24042. /**
  24043. * Must the particle be translated from its pivot point in its local space ?
  24044. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24045. * Default : false
  24046. */
  24047. translateFromPivot: boolean;
  24048. /**
  24049. * Is the particle active or not ?
  24050. */
  24051. alive: boolean;
  24052. /**
  24053. * Is the particle visible or not ?
  24054. */
  24055. isVisible: boolean;
  24056. /**
  24057. * Index of this particle in the global "positions" array (Internal use)
  24058. * @hidden
  24059. */
  24060. _pos: number;
  24061. /**
  24062. * @hidden Index of this particle in the global "indices" array (Internal use)
  24063. */
  24064. _ind: number;
  24065. /**
  24066. * @hidden ModelShape of this particle (Internal use)
  24067. */
  24068. _model: ModelShape;
  24069. /**
  24070. * ModelShape id of this particle
  24071. */
  24072. shapeId: number;
  24073. /**
  24074. * Index of the particle in its shape id (Internal use)
  24075. */
  24076. idxInShape: number;
  24077. /**
  24078. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24079. */
  24080. _modelBoundingInfo: BoundingInfo;
  24081. /**
  24082. * @hidden Particle BoundingInfo object (Internal use)
  24083. */
  24084. _boundingInfo: BoundingInfo;
  24085. /**
  24086. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24087. */
  24088. _sps: SolidParticleSystem;
  24089. /**
  24090. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24091. */
  24092. _stillInvisible: boolean;
  24093. /**
  24094. * @hidden Last computed particle rotation matrix
  24095. */
  24096. _rotationMatrix: number[];
  24097. /**
  24098. * Parent particle Id, if any.
  24099. * Default null.
  24100. */
  24101. parentId: Nullable<number>;
  24102. /**
  24103. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24104. * The possible values are :
  24105. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24106. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24107. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24108. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24109. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24110. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24111. * */
  24112. cullingStrategy: number;
  24113. /**
  24114. * @hidden Internal global position in the SPS.
  24115. */
  24116. _globalPosition: Vector3;
  24117. /**
  24118. * Creates a Solid Particle object.
  24119. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24120. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24121. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24122. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24123. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24124. * @param shapeId (integer) is the model shape identifier in the SPS.
  24125. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24126. * @param sps defines the sps it is associated to
  24127. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24128. */
  24129. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24130. /**
  24131. * Legacy support, changed scale to scaling
  24132. */
  24133. /**
  24134. * Legacy support, changed scale to scaling
  24135. */
  24136. scale: Vector3;
  24137. /**
  24138. * Legacy support, changed quaternion to rotationQuaternion
  24139. */
  24140. /**
  24141. * Legacy support, changed quaternion to rotationQuaternion
  24142. */
  24143. quaternion: Nullable<Quaternion>;
  24144. /**
  24145. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24146. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24147. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24148. * @returns true if it intersects
  24149. */
  24150. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24151. /**
  24152. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24153. * A particle is in the frustum if its bounding box intersects the frustum
  24154. * @param frustumPlanes defines the frustum to test
  24155. * @returns true if the particle is in the frustum planes
  24156. */
  24157. isInFrustum(frustumPlanes: Plane[]): boolean;
  24158. /**
  24159. * get the rotation matrix of the particle
  24160. * @hidden
  24161. */
  24162. getRotationMatrix(m: Matrix): void;
  24163. }
  24164. /**
  24165. * Represents the shape of the model used by one particle of a solid particle system.
  24166. * SPS internal tool, don't use it manually.
  24167. */
  24168. export class ModelShape {
  24169. /**
  24170. * The shape id
  24171. * @hidden
  24172. */
  24173. shapeID: number;
  24174. /**
  24175. * flat array of model positions (internal use)
  24176. * @hidden
  24177. */
  24178. _shape: Vector3[];
  24179. /**
  24180. * flat array of model UVs (internal use)
  24181. * @hidden
  24182. */
  24183. _shapeUV: number[];
  24184. /**
  24185. * length of the shape in the model indices array (internal use)
  24186. * @hidden
  24187. */
  24188. _indicesLength: number;
  24189. /**
  24190. * Custom position function (internal use)
  24191. * @hidden
  24192. */
  24193. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24194. /**
  24195. * Custom vertex function (internal use)
  24196. * @hidden
  24197. */
  24198. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24199. /**
  24200. * 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.
  24201. * SPS internal tool, don't use it manually.
  24202. * @hidden
  24203. */
  24204. 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>);
  24205. }
  24206. /**
  24207. * Represents a Depth Sorted Particle in the solid particle system.
  24208. */
  24209. export class DepthSortedParticle {
  24210. /**
  24211. * Index of the particle in the "indices" array
  24212. */
  24213. ind: number;
  24214. /**
  24215. * Length of the particle shape in the "indices" array
  24216. */
  24217. indicesLength: number;
  24218. /**
  24219. * Squared distance from the particle to the camera
  24220. */
  24221. sqDistance: number;
  24222. }
  24223. }
  24224. declare module "babylonjs/Meshes/abstractMesh" {
  24225. import { Observable } from "babylonjs/Misc/observable";
  24226. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24227. import { Camera } from "babylonjs/Cameras/camera";
  24228. import { Scene, IDisposable } from "babylonjs/scene";
  24229. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24230. import { Node } from "babylonjs/node";
  24231. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24232. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24234. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24235. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24236. import { Material } from "babylonjs/Materials/material";
  24237. import { Light } from "babylonjs/Lights/light";
  24238. import { Skeleton } from "babylonjs/Bones/skeleton";
  24239. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24240. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24241. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24242. import { Ray } from "babylonjs/Culling/ray";
  24243. import { Collider } from "babylonjs/Collisions/collider";
  24244. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24245. /**
  24246. * Class used to store all common mesh properties
  24247. */
  24248. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24249. /** No occlusion */
  24250. static OCCLUSION_TYPE_NONE: number;
  24251. /** Occlusion set to optimisitic */
  24252. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24253. /** Occlusion set to strict */
  24254. static OCCLUSION_TYPE_STRICT: number;
  24255. /** Use an accurante occlusion algorithm */
  24256. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24257. /** Use a conservative occlusion algorithm */
  24258. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24259. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24260. * Test order :
  24261. * Is the bounding sphere outside the frustum ?
  24262. * If not, are the bounding box vertices outside the frustum ?
  24263. * It not, then the cullable object is in the frustum.
  24264. */
  24265. static readonly CULLINGSTRATEGY_STANDARD: number;
  24266. /** Culling strategy : Bounding Sphere Only.
  24267. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24268. * It's also less accurate than the standard because some not visible objects can still be selected.
  24269. * Test : is the bounding sphere outside the frustum ?
  24270. * If not, then the cullable object is in the frustum.
  24271. */
  24272. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24273. /** Culling strategy : Optimistic Inclusion.
  24274. * This in an inclusion test first, then the standard exclusion test.
  24275. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24276. * 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.
  24277. * Anyway, it's as accurate as the standard strategy.
  24278. * Test :
  24279. * Is the cullable object bounding sphere center in the frustum ?
  24280. * If not, apply the default culling strategy.
  24281. */
  24282. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24283. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24284. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24285. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24286. * 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.
  24287. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24288. * Test :
  24289. * Is the cullable object bounding sphere center in the frustum ?
  24290. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24291. */
  24292. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24293. /**
  24294. * No billboard
  24295. */
  24296. static readonly BILLBOARDMODE_NONE: number;
  24297. /** Billboard on X axis */
  24298. static readonly BILLBOARDMODE_X: number;
  24299. /** Billboard on Y axis */
  24300. static readonly BILLBOARDMODE_Y: number;
  24301. /** Billboard on Z axis */
  24302. static readonly BILLBOARDMODE_Z: number;
  24303. /** Billboard on all axes */
  24304. static readonly BILLBOARDMODE_ALL: number;
  24305. private _facetData;
  24306. /**
  24307. * The culling strategy to use to check whether the mesh must be rendered or not.
  24308. * This value can be changed at any time and will be used on the next render mesh selection.
  24309. * The possible values are :
  24310. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24311. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24313. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24314. * Please read each static variable documentation to get details about the culling process.
  24315. * */
  24316. cullingStrategy: number;
  24317. /**
  24318. * Gets the number of facets in the mesh
  24319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24320. */
  24321. readonly facetNb: number;
  24322. /**
  24323. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24325. */
  24326. partitioningSubdivisions: number;
  24327. /**
  24328. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24329. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24331. */
  24332. partitioningBBoxRatio: number;
  24333. /**
  24334. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24335. * Works only for updatable meshes.
  24336. * Doesn't work with multi-materials
  24337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24338. */
  24339. mustDepthSortFacets: boolean;
  24340. /**
  24341. * The location (Vector3) where the facet depth sort must be computed from.
  24342. * By default, the active camera position.
  24343. * Used only when facet depth sort is enabled
  24344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24345. */
  24346. facetDepthSortFrom: Vector3;
  24347. /**
  24348. * gets a boolean indicating if facetData is enabled
  24349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24350. */
  24351. readonly isFacetDataEnabled: boolean;
  24352. /** @hidden */
  24353. _updateNonUniformScalingState(value: boolean): boolean;
  24354. /**
  24355. * An event triggered when this mesh collides with another one
  24356. */
  24357. onCollideObservable: Observable<AbstractMesh>;
  24358. private _onCollideObserver;
  24359. /** Set a function to call when this mesh collides with another one */
  24360. onCollide: () => void;
  24361. /**
  24362. * An event triggered when the collision's position changes
  24363. */
  24364. onCollisionPositionChangeObservable: Observable<Vector3>;
  24365. private _onCollisionPositionChangeObserver;
  24366. /** Set a function to call when the collision's position changes */
  24367. onCollisionPositionChange: () => void;
  24368. /**
  24369. * An event triggered when material is changed
  24370. */
  24371. onMaterialChangedObservable: Observable<AbstractMesh>;
  24372. /**
  24373. * Gets or sets the orientation for POV movement & rotation
  24374. */
  24375. definedFacingForward: boolean;
  24376. /** @hidden */
  24377. _occlusionQuery: Nullable<WebGLQuery>;
  24378. private _visibility;
  24379. /**
  24380. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24381. */
  24382. /**
  24383. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24384. */
  24385. visibility: number;
  24386. /** Gets or sets the alpha index used to sort transparent meshes
  24387. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24388. */
  24389. alphaIndex: number;
  24390. /**
  24391. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24392. */
  24393. isVisible: boolean;
  24394. /**
  24395. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24396. */
  24397. isPickable: boolean;
  24398. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24399. showSubMeshesBoundingBox: boolean;
  24400. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24401. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24402. */
  24403. isBlocker: boolean;
  24404. /**
  24405. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24406. */
  24407. enablePointerMoveEvents: boolean;
  24408. /**
  24409. * Specifies the rendering group id for this mesh (0 by default)
  24410. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24411. */
  24412. renderingGroupId: number;
  24413. private _material;
  24414. /** Gets or sets current material */
  24415. material: Nullable<Material>;
  24416. private _receiveShadows;
  24417. /**
  24418. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24419. * @see http://doc.babylonjs.com/babylon101/shadows
  24420. */
  24421. receiveShadows: boolean;
  24422. /** Defines color to use when rendering outline */
  24423. outlineColor: Color3;
  24424. /** Define width to use when rendering outline */
  24425. outlineWidth: number;
  24426. /** Defines color to use when rendering overlay */
  24427. overlayColor: Color3;
  24428. /** Defines alpha to use when rendering overlay */
  24429. overlayAlpha: number;
  24430. private _hasVertexAlpha;
  24431. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24432. hasVertexAlpha: boolean;
  24433. private _useVertexColors;
  24434. /** 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) */
  24435. useVertexColors: boolean;
  24436. private _computeBonesUsingShaders;
  24437. /**
  24438. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24439. */
  24440. computeBonesUsingShaders: boolean;
  24441. private _numBoneInfluencers;
  24442. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24443. numBoneInfluencers: number;
  24444. private _applyFog;
  24445. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24446. applyFog: boolean;
  24447. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24448. useOctreeForRenderingSelection: boolean;
  24449. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24450. useOctreeForPicking: boolean;
  24451. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24452. useOctreeForCollisions: boolean;
  24453. private _layerMask;
  24454. /**
  24455. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24456. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24457. */
  24458. layerMask: number;
  24459. /**
  24460. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24461. */
  24462. alwaysSelectAsActiveMesh: boolean;
  24463. /**
  24464. * Gets or sets the current action manager
  24465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24466. */
  24467. actionManager: Nullable<AbstractActionManager>;
  24468. private _checkCollisions;
  24469. private _collisionMask;
  24470. private _collisionGroup;
  24471. /**
  24472. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24473. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24474. */
  24475. ellipsoid: Vector3;
  24476. /**
  24477. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24478. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24479. */
  24480. ellipsoidOffset: Vector3;
  24481. private _collider;
  24482. private _oldPositionForCollisions;
  24483. private _diffPositionForCollisions;
  24484. /**
  24485. * Gets or sets a collision mask used to mask collisions (default is -1).
  24486. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24487. */
  24488. collisionMask: number;
  24489. /**
  24490. * Gets or sets the current collision group mask (-1 by default).
  24491. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24492. */
  24493. collisionGroup: number;
  24494. /**
  24495. * Defines edge width used when edgesRenderer is enabled
  24496. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24497. */
  24498. edgesWidth: number;
  24499. /**
  24500. * Defines edge color used when edgesRenderer is enabled
  24501. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24502. */
  24503. edgesColor: Color4;
  24504. /** @hidden */
  24505. _edgesRenderer: Nullable<IEdgesRenderer>;
  24506. /** @hidden */
  24507. _masterMesh: Nullable<AbstractMesh>;
  24508. /** @hidden */
  24509. _boundingInfo: Nullable<BoundingInfo>;
  24510. /** @hidden */
  24511. _renderId: number;
  24512. /**
  24513. * Gets or sets the list of subMeshes
  24514. * @see http://doc.babylonjs.com/how_to/multi_materials
  24515. */
  24516. subMeshes: SubMesh[];
  24517. /** @hidden */
  24518. _intersectionsInProgress: AbstractMesh[];
  24519. /** @hidden */
  24520. _unIndexed: boolean;
  24521. /** @hidden */
  24522. _lightSources: Light[];
  24523. /** @hidden */
  24524. readonly _positions: Nullable<Vector3[]>;
  24525. /** @hidden */
  24526. _waitingActions: any;
  24527. /** @hidden */
  24528. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24529. private _skeleton;
  24530. /** @hidden */
  24531. _bonesTransformMatrices: Nullable<Float32Array>;
  24532. /**
  24533. * Gets or sets a skeleton to apply skining transformations
  24534. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24535. */
  24536. skeleton: Nullable<Skeleton>;
  24537. /**
  24538. * An event triggered when the mesh is rebuilt.
  24539. */
  24540. onRebuildObservable: Observable<AbstractMesh>;
  24541. /**
  24542. * Creates a new AbstractMesh
  24543. * @param name defines the name of the mesh
  24544. * @param scene defines the hosting scene
  24545. */
  24546. constructor(name: string, scene?: Nullable<Scene>);
  24547. /**
  24548. * Returns the string "AbstractMesh"
  24549. * @returns "AbstractMesh"
  24550. */
  24551. getClassName(): string;
  24552. /**
  24553. * Gets a string representation of the current mesh
  24554. * @param fullDetails defines a boolean indicating if full details must be included
  24555. * @returns a string representation of the current mesh
  24556. */
  24557. toString(fullDetails?: boolean): string;
  24558. /** @hidden */
  24559. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24560. /** @hidden */
  24561. _rebuild(): void;
  24562. /** @hidden */
  24563. _resyncLightSources(): void;
  24564. /** @hidden */
  24565. _resyncLighSource(light: Light): void;
  24566. /** @hidden */
  24567. _unBindEffect(): void;
  24568. /** @hidden */
  24569. _removeLightSource(light: Light): void;
  24570. private _markSubMeshesAsDirty;
  24571. /** @hidden */
  24572. _markSubMeshesAsLightDirty(): void;
  24573. /** @hidden */
  24574. _markSubMeshesAsAttributesDirty(): void;
  24575. /** @hidden */
  24576. _markSubMeshesAsMiscDirty(): void;
  24577. /**
  24578. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24579. */
  24580. scaling: Vector3;
  24581. /**
  24582. * Returns true if the mesh is blocked. Implemented by child classes
  24583. */
  24584. readonly isBlocked: boolean;
  24585. /**
  24586. * Returns the mesh itself by default. Implemented by child classes
  24587. * @param camera defines the camera to use to pick the right LOD level
  24588. * @returns the currentAbstractMesh
  24589. */
  24590. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24591. /**
  24592. * Returns 0 by default. Implemented by child classes
  24593. * @returns an integer
  24594. */
  24595. getTotalVertices(): number;
  24596. /**
  24597. * Returns a positive integer : the total number of indices in this mesh geometry.
  24598. * @returns the numner of indices or zero if the mesh has no geometry.
  24599. */
  24600. getTotalIndices(): number;
  24601. /**
  24602. * Returns null by default. Implemented by child classes
  24603. * @returns null
  24604. */
  24605. getIndices(): Nullable<IndicesArray>;
  24606. /**
  24607. * Returns the array of the requested vertex data kind. Implemented by child classes
  24608. * @param kind defines the vertex data kind to use
  24609. * @returns null
  24610. */
  24611. getVerticesData(kind: string): Nullable<FloatArray>;
  24612. /**
  24613. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24614. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24615. * Note that a new underlying VertexBuffer object is created each call.
  24616. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24617. * @param kind defines vertex data kind:
  24618. * * VertexBuffer.PositionKind
  24619. * * VertexBuffer.UVKind
  24620. * * VertexBuffer.UV2Kind
  24621. * * VertexBuffer.UV3Kind
  24622. * * VertexBuffer.UV4Kind
  24623. * * VertexBuffer.UV5Kind
  24624. * * VertexBuffer.UV6Kind
  24625. * * VertexBuffer.ColorKind
  24626. * * VertexBuffer.MatricesIndicesKind
  24627. * * VertexBuffer.MatricesIndicesExtraKind
  24628. * * VertexBuffer.MatricesWeightsKind
  24629. * * VertexBuffer.MatricesWeightsExtraKind
  24630. * @param data defines the data source
  24631. * @param updatable defines if the data must be flagged as updatable (or static)
  24632. * @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
  24633. * @returns the current mesh
  24634. */
  24635. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24636. /**
  24637. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24638. * If the mesh has no geometry, it is simply returned as it is.
  24639. * @param kind defines vertex data kind:
  24640. * * VertexBuffer.PositionKind
  24641. * * VertexBuffer.UVKind
  24642. * * VertexBuffer.UV2Kind
  24643. * * VertexBuffer.UV3Kind
  24644. * * VertexBuffer.UV4Kind
  24645. * * VertexBuffer.UV5Kind
  24646. * * VertexBuffer.UV6Kind
  24647. * * VertexBuffer.ColorKind
  24648. * * VertexBuffer.MatricesIndicesKind
  24649. * * VertexBuffer.MatricesIndicesExtraKind
  24650. * * VertexBuffer.MatricesWeightsKind
  24651. * * VertexBuffer.MatricesWeightsExtraKind
  24652. * @param data defines the data source
  24653. * @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
  24654. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24655. * @returns the current mesh
  24656. */
  24657. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24658. /**
  24659. * Sets the mesh indices,
  24660. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24661. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24662. * @param totalVertices Defines the total number of vertices
  24663. * @returns the current mesh
  24664. */
  24665. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24666. /**
  24667. * Gets a boolean indicating if specific vertex data is present
  24668. * @param kind defines the vertex data kind to use
  24669. * @returns true is data kind is present
  24670. */
  24671. isVerticesDataPresent(kind: string): boolean;
  24672. /**
  24673. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24674. * @returns a BoundingInfo
  24675. */
  24676. getBoundingInfo(): BoundingInfo;
  24677. /**
  24678. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24679. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24680. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24681. * @returns the current mesh
  24682. */
  24683. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24684. /**
  24685. * Overwrite the current bounding info
  24686. * @param boundingInfo defines the new bounding info
  24687. * @returns the current mesh
  24688. */
  24689. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24690. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24691. readonly useBones: boolean;
  24692. /** @hidden */
  24693. _preActivate(): void;
  24694. /** @hidden */
  24695. _preActivateForIntermediateRendering(renderId: number): void;
  24696. /** @hidden */
  24697. _activate(renderId: number): void;
  24698. /**
  24699. * Gets the current world matrix
  24700. * @returns a Matrix
  24701. */
  24702. getWorldMatrix(): Matrix;
  24703. /** @hidden */
  24704. _getWorldMatrixDeterminant(): number;
  24705. /**
  24706. * Perform relative position change from the point of view of behind the front of the mesh.
  24707. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24708. * Supports definition of mesh facing forward or backward
  24709. * @param amountRight defines the distance on the right axis
  24710. * @param amountUp defines the distance on the up axis
  24711. * @param amountForward defines the distance on the forward axis
  24712. * @returns the current mesh
  24713. */
  24714. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24715. /**
  24716. * Calculate relative position change from the point of view of behind the front of the mesh.
  24717. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24718. * Supports definition of mesh facing forward or backward
  24719. * @param amountRight defines the distance on the right axis
  24720. * @param amountUp defines the distance on the up axis
  24721. * @param amountForward defines the distance on the forward axis
  24722. * @returns the new displacement vector
  24723. */
  24724. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24725. /**
  24726. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24727. * Supports definition of mesh facing forward or backward
  24728. * @param flipBack defines the flip
  24729. * @param twirlClockwise defines the twirl
  24730. * @param tiltRight defines the tilt
  24731. * @returns the current mesh
  24732. */
  24733. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24734. /**
  24735. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24736. * Supports definition of mesh facing forward or backward.
  24737. * @param flipBack defines the flip
  24738. * @param twirlClockwise defines the twirl
  24739. * @param tiltRight defines the tilt
  24740. * @returns the new rotation vector
  24741. */
  24742. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24743. /**
  24744. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24745. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24746. * @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
  24747. * @returns the new bounding vectors
  24748. */
  24749. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24750. min: Vector3;
  24751. max: Vector3;
  24752. };
  24753. /**
  24754. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24755. * This means the mesh underlying bounding box and sphere are recomputed.
  24756. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24757. * @returns the current mesh
  24758. */
  24759. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24760. /** @hidden */
  24761. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24762. /** @hidden */
  24763. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24764. /** @hidden */
  24765. _updateBoundingInfo(): AbstractMesh;
  24766. /** @hidden */
  24767. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24768. /** @hidden */
  24769. protected _afterComputeWorldMatrix(): void;
  24770. /**
  24771. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24772. * A mesh is in the frustum if its bounding box intersects the frustum
  24773. * @param frustumPlanes defines the frustum to test
  24774. * @returns true if the mesh is in the frustum planes
  24775. */
  24776. isInFrustum(frustumPlanes: Plane[]): boolean;
  24777. /**
  24778. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24779. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24780. * @param frustumPlanes defines the frustum to test
  24781. * @returns true if the mesh is completely in the frustum planes
  24782. */
  24783. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24784. /**
  24785. * True if the mesh intersects another mesh or a SolidParticle object
  24786. * @param mesh defines a target mesh or SolidParticle to test
  24787. * @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)
  24788. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24789. * @returns true if there is an intersection
  24790. */
  24791. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24792. /**
  24793. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24794. * @param point defines the point to test
  24795. * @returns true if there is an intersection
  24796. */
  24797. intersectsPoint(point: Vector3): boolean;
  24798. /**
  24799. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24800. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24801. */
  24802. checkCollisions: boolean;
  24803. /**
  24804. * Gets Collider object used to compute collisions (not physics)
  24805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24806. */
  24807. readonly collider: Collider;
  24808. /**
  24809. * Move the mesh using collision engine
  24810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24811. * @param displacement defines the requested displacement vector
  24812. * @returns the current mesh
  24813. */
  24814. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24815. private _onCollisionPositionChange;
  24816. /** @hidden */
  24817. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24818. /** @hidden */
  24819. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24820. /** @hidden */
  24821. _checkCollision(collider: Collider): AbstractMesh;
  24822. /** @hidden */
  24823. _generatePointsArray(): boolean;
  24824. /**
  24825. * Checks if the passed Ray intersects with the mesh
  24826. * @param ray defines the ray to use
  24827. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24828. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24829. * @returns the picking info
  24830. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24831. */
  24832. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24833. /**
  24834. * Clones the current mesh
  24835. * @param name defines the mesh name
  24836. * @param newParent defines the new mesh parent
  24837. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24838. * @returns the new mesh
  24839. */
  24840. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24841. /**
  24842. * Disposes all the submeshes of the current meshnp
  24843. * @returns the current mesh
  24844. */
  24845. releaseSubMeshes(): AbstractMesh;
  24846. /**
  24847. * Releases resources associated with this abstract mesh.
  24848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24850. */
  24851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24852. /**
  24853. * Adds the passed mesh as a child to the current mesh
  24854. * @param mesh defines the child mesh
  24855. * @returns the current mesh
  24856. */
  24857. addChild(mesh: AbstractMesh): AbstractMesh;
  24858. /**
  24859. * Removes the passed mesh from the current mesh children list
  24860. * @param mesh defines the child mesh
  24861. * @returns the current mesh
  24862. */
  24863. removeChild(mesh: AbstractMesh): AbstractMesh;
  24864. /** @hidden */
  24865. private _initFacetData;
  24866. /**
  24867. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24868. * This method can be called within the render loop.
  24869. * 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
  24870. * @returns the current mesh
  24871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24872. */
  24873. updateFacetData(): AbstractMesh;
  24874. /**
  24875. * Returns the facetLocalNormals array.
  24876. * The normals are expressed in the mesh local spac
  24877. * @returns an array of Vector3
  24878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24879. */
  24880. getFacetLocalNormals(): Vector3[];
  24881. /**
  24882. * Returns the facetLocalPositions array.
  24883. * The facet positions are expressed in the mesh local space
  24884. * @returns an array of Vector3
  24885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24886. */
  24887. getFacetLocalPositions(): Vector3[];
  24888. /**
  24889. * Returns the facetLocalPartioning array
  24890. * @returns an array of array of numbers
  24891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24892. */
  24893. getFacetLocalPartitioning(): number[][];
  24894. /**
  24895. * Returns the i-th facet position in the world system.
  24896. * This method allocates a new Vector3 per call
  24897. * @param i defines the facet index
  24898. * @returns a new Vector3
  24899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24900. */
  24901. getFacetPosition(i: number): Vector3;
  24902. /**
  24903. * Sets the reference Vector3 with the i-th facet position in the world system
  24904. * @param i defines the facet index
  24905. * @param ref defines the target vector
  24906. * @returns the current mesh
  24907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24908. */
  24909. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24910. /**
  24911. * Returns the i-th facet normal in the world system.
  24912. * This method allocates a new Vector3 per call
  24913. * @param i defines the facet index
  24914. * @returns a new Vector3
  24915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24916. */
  24917. getFacetNormal(i: number): Vector3;
  24918. /**
  24919. * Sets the reference Vector3 with the i-th facet normal in the world system
  24920. * @param i defines the facet index
  24921. * @param ref defines the target vector
  24922. * @returns the current mesh
  24923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24924. */
  24925. getFacetNormalToRef(i: number, ref: Vector3): this;
  24926. /**
  24927. * 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)
  24928. * @param x defines x coordinate
  24929. * @param y defines y coordinate
  24930. * @param z defines z coordinate
  24931. * @returns the array of facet indexes
  24932. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24933. */
  24934. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24935. /**
  24936. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24937. * @param projected sets as the (x,y,z) world projection on the facet
  24938. * @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
  24939. * @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
  24940. * @param x defines x coordinate
  24941. * @param y defines y coordinate
  24942. * @param z defines z coordinate
  24943. * @returns the face index if found (or null instead)
  24944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24945. */
  24946. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24947. /**
  24948. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24949. * @param projected sets as the (x,y,z) local projection on the facet
  24950. * @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
  24951. * @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
  24952. * @param x defines x coordinate
  24953. * @param y defines y coordinate
  24954. * @param z defines z coordinate
  24955. * @returns the face index if found (or null instead)
  24956. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24957. */
  24958. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24959. /**
  24960. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24961. * @returns the parameters
  24962. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24963. */
  24964. getFacetDataParameters(): any;
  24965. /**
  24966. * Disables the feature FacetData and frees the related memory
  24967. * @returns the current mesh
  24968. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24969. */
  24970. disableFacetData(): AbstractMesh;
  24971. /**
  24972. * Updates the AbstractMesh indices array
  24973. * @param indices defines the data source
  24974. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24975. * @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)
  24976. * @returns the current mesh
  24977. */
  24978. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24979. /**
  24980. * Creates new normals data for the mesh
  24981. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24982. * @returns the current mesh
  24983. */
  24984. createNormals(updatable: boolean): AbstractMesh;
  24985. /**
  24986. * Align the mesh with a normal
  24987. * @param normal defines the normal to use
  24988. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24989. * @returns the current mesh
  24990. */
  24991. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24992. /** @hidden */
  24993. _checkOcclusionQuery(): boolean;
  24994. }
  24995. }
  24996. declare module "babylonjs/Actions/actionEvent" {
  24997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24998. import { Nullable } from "babylonjs/types";
  24999. import { Sprite } from "babylonjs/Sprites/sprite";
  25000. import { Scene } from "babylonjs/scene";
  25001. import { Vector2 } from "babylonjs/Maths/math";
  25002. /**
  25003. * Interface used to define ActionEvent
  25004. */
  25005. export interface IActionEvent {
  25006. /** The mesh or sprite that triggered the action */
  25007. source: any;
  25008. /** The X mouse cursor position at the time of the event */
  25009. pointerX: number;
  25010. /** The Y mouse cursor position at the time of the event */
  25011. pointerY: number;
  25012. /** The mesh that is currently pointed at (can be null) */
  25013. meshUnderPointer: Nullable<AbstractMesh>;
  25014. /** the original (browser) event that triggered the ActionEvent */
  25015. sourceEvent?: any;
  25016. /** additional data for the event */
  25017. additionalData?: any;
  25018. }
  25019. /**
  25020. * ActionEvent is the event being sent when an action is triggered.
  25021. */
  25022. export class ActionEvent implements IActionEvent {
  25023. /** The mesh or sprite that triggered the action */
  25024. source: any;
  25025. /** The X mouse cursor position at the time of the event */
  25026. pointerX: number;
  25027. /** The Y mouse cursor position at the time of the event */
  25028. pointerY: number;
  25029. /** The mesh that is currently pointed at (can be null) */
  25030. meshUnderPointer: Nullable<AbstractMesh>;
  25031. /** the original (browser) event that triggered the ActionEvent */
  25032. sourceEvent?: any;
  25033. /** additional data for the event */
  25034. additionalData?: any;
  25035. /**
  25036. * Creates a new ActionEvent
  25037. * @param source The mesh or sprite that triggered the action
  25038. * @param pointerX The X mouse cursor position at the time of the event
  25039. * @param pointerY The Y mouse cursor position at the time of the event
  25040. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25041. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25042. * @param additionalData additional data for the event
  25043. */
  25044. constructor(
  25045. /** The mesh or sprite that triggered the action */
  25046. source: any,
  25047. /** The X mouse cursor position at the time of the event */
  25048. pointerX: number,
  25049. /** The Y mouse cursor position at the time of the event */
  25050. pointerY: number,
  25051. /** The mesh that is currently pointed at (can be null) */
  25052. meshUnderPointer: Nullable<AbstractMesh>,
  25053. /** the original (browser) event that triggered the ActionEvent */
  25054. sourceEvent?: any,
  25055. /** additional data for the event */
  25056. additionalData?: any);
  25057. /**
  25058. * Helper function to auto-create an ActionEvent from a source mesh.
  25059. * @param source The source mesh that triggered the event
  25060. * @param evt The original (browser) event
  25061. * @param additionalData additional data for the event
  25062. * @returns the new ActionEvent
  25063. */
  25064. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25065. /**
  25066. * Helper function to auto-create an ActionEvent from a source sprite
  25067. * @param source The source sprite that triggered the event
  25068. * @param scene Scene associated with the sprite
  25069. * @param evt The original (browser) event
  25070. * @param additionalData additional data for the event
  25071. * @returns the new ActionEvent
  25072. */
  25073. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25074. /**
  25075. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25076. * @param scene the scene where the event occurred
  25077. * @param evt The original (browser) event
  25078. * @returns the new ActionEvent
  25079. */
  25080. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25081. /**
  25082. * Helper function to auto-create an ActionEvent from a primitive
  25083. * @param prim defines the target primitive
  25084. * @param pointerPos defines the pointer position
  25085. * @param evt The original (browser) event
  25086. * @param additionalData additional data for the event
  25087. * @returns the new ActionEvent
  25088. */
  25089. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25090. }
  25091. }
  25092. declare module "babylonjs/Actions/abstractActionManager" {
  25093. import { IDisposable } from "babylonjs/scene";
  25094. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25095. import { IAction } from "babylonjs/Actions/action";
  25096. import { Nullable } from "babylonjs/types";
  25097. /**
  25098. * Abstract class used to decouple action Manager from scene and meshes.
  25099. * Do not instantiate.
  25100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25101. */
  25102. export abstract class AbstractActionManager implements IDisposable {
  25103. /** Gets the list of active triggers */
  25104. static Triggers: {
  25105. [key: string]: number;
  25106. };
  25107. /** Gets the cursor to use when hovering items */
  25108. hoverCursor: string;
  25109. /** Gets the list of actions */
  25110. actions: IAction[];
  25111. /**
  25112. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25113. */
  25114. isRecursive: boolean;
  25115. /**
  25116. * Releases all associated resources
  25117. */
  25118. abstract dispose(): void;
  25119. /**
  25120. * Does this action manager has pointer triggers
  25121. */
  25122. abstract readonly hasPointerTriggers: boolean;
  25123. /**
  25124. * Does this action manager has pick triggers
  25125. */
  25126. abstract readonly hasPickTriggers: boolean;
  25127. /**
  25128. * Process a specific trigger
  25129. * @param trigger defines the trigger to process
  25130. * @param evt defines the event details to be processed
  25131. */
  25132. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25133. /**
  25134. * Does this action manager handles actions of any of the given triggers
  25135. * @param triggers defines the triggers to be tested
  25136. * @return a boolean indicating whether one (or more) of the triggers is handled
  25137. */
  25138. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25139. /**
  25140. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25141. * speed.
  25142. * @param triggerA defines the trigger to be tested
  25143. * @param triggerB defines the trigger to be tested
  25144. * @return a boolean indicating whether one (or more) of the triggers is handled
  25145. */
  25146. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25147. /**
  25148. * Does this action manager handles actions of a given trigger
  25149. * @param trigger defines the trigger to be tested
  25150. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25151. * @return whether the trigger is handled
  25152. */
  25153. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25154. /**
  25155. * Serialize this manager to a JSON object
  25156. * @param name defines the property name to store this manager
  25157. * @returns a JSON representation of this manager
  25158. */
  25159. abstract serialize(name: string): any;
  25160. /**
  25161. * Registers an action to this action manager
  25162. * @param action defines the action to be registered
  25163. * @return the action amended (prepared) after registration
  25164. */
  25165. abstract registerAction(action: IAction): Nullable<IAction>;
  25166. /**
  25167. * Unregisters an action to this action manager
  25168. * @param action defines the action to be unregistered
  25169. * @return a boolean indicating whether the action has been unregistered
  25170. */
  25171. abstract unregisterAction(action: IAction): Boolean;
  25172. /**
  25173. * Does exist one action manager with at least one trigger
  25174. **/
  25175. static readonly HasTriggers: boolean;
  25176. /**
  25177. * Does exist one action manager with at least one pick trigger
  25178. **/
  25179. static readonly HasPickTriggers: boolean;
  25180. /**
  25181. * Does exist one action manager that handles actions of a given trigger
  25182. * @param trigger defines the trigger to be tested
  25183. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25184. **/
  25185. static HasSpecificTrigger(trigger: number): boolean;
  25186. }
  25187. }
  25188. declare module "babylonjs/node" {
  25189. import { Scene } from "babylonjs/scene";
  25190. import { Nullable } from "babylonjs/types";
  25191. import { Matrix } from "babylonjs/Maths/math";
  25192. import { Engine } from "babylonjs/Engines/engine";
  25193. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25194. import { Observable } from "babylonjs/Misc/observable";
  25195. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25196. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25197. import { Animatable } from "babylonjs/Animations/animatable";
  25198. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25199. import { Animation } from "babylonjs/Animations/animation";
  25200. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25202. /**
  25203. * Defines how a node can be built from a string name.
  25204. */
  25205. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25206. /**
  25207. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25208. */
  25209. export class Node implements IBehaviorAware<Node> {
  25210. /** @hidden */
  25211. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25212. private static _NodeConstructors;
  25213. /**
  25214. * Add a new node constructor
  25215. * @param type defines the type name of the node to construct
  25216. * @param constructorFunc defines the constructor function
  25217. */
  25218. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25219. /**
  25220. * Returns a node constructor based on type name
  25221. * @param type defines the type name
  25222. * @param name defines the new node name
  25223. * @param scene defines the hosting scene
  25224. * @param options defines optional options to transmit to constructors
  25225. * @returns the new constructor or null
  25226. */
  25227. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25228. /**
  25229. * Gets or sets the name of the node
  25230. */
  25231. name: string;
  25232. /**
  25233. * Gets or sets the id of the node
  25234. */
  25235. id: string;
  25236. /**
  25237. * Gets or sets the unique id of the node
  25238. */
  25239. uniqueId: number;
  25240. /**
  25241. * Gets or sets a string used to store user defined state for the node
  25242. */
  25243. state: string;
  25244. /**
  25245. * Gets or sets an object used to store user defined information for the node
  25246. */
  25247. metadata: any;
  25248. /**
  25249. * For internal use only. Please do not use.
  25250. */
  25251. reservedDataStore: any;
  25252. /**
  25253. * List of inspectable custom properties (used by the Inspector)
  25254. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25255. */
  25256. inspectableCustomProperties: IInspectable[];
  25257. /**
  25258. * Gets or sets a boolean used to define if the node must be serialized
  25259. */
  25260. doNotSerialize: boolean;
  25261. /** @hidden */
  25262. _isDisposed: boolean;
  25263. /**
  25264. * Gets a list of Animations associated with the node
  25265. */
  25266. animations: import("babylonjs/Animations/animation").Animation[];
  25267. protected _ranges: {
  25268. [name: string]: Nullable<AnimationRange>;
  25269. };
  25270. /**
  25271. * Callback raised when the node is ready to be used
  25272. */
  25273. onReady: (node: Node) => void;
  25274. private _isEnabled;
  25275. private _isParentEnabled;
  25276. private _isReady;
  25277. /** @hidden */
  25278. _currentRenderId: number;
  25279. private _parentRenderId;
  25280. protected _childRenderId: number;
  25281. /** @hidden */
  25282. _waitingParentId: Nullable<string>;
  25283. /** @hidden */
  25284. _scene: Scene;
  25285. /** @hidden */
  25286. _cache: any;
  25287. private _parentNode;
  25288. private _children;
  25289. /** @hidden */
  25290. _worldMatrix: Matrix;
  25291. /** @hidden */
  25292. _worldMatrixDeterminant: number;
  25293. /** @hidden */
  25294. private _sceneRootNodesIndex;
  25295. /**
  25296. * Gets a boolean indicating if the node has been disposed
  25297. * @returns true if the node was disposed
  25298. */
  25299. isDisposed(): boolean;
  25300. /**
  25301. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25302. * @see https://doc.babylonjs.com/how_to/parenting
  25303. */
  25304. parent: Nullable<Node>;
  25305. private addToSceneRootNodes;
  25306. private removeFromSceneRootNodes;
  25307. private _animationPropertiesOverride;
  25308. /**
  25309. * Gets or sets the animation properties override
  25310. */
  25311. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25312. /**
  25313. * Gets a string idenfifying the name of the class
  25314. * @returns "Node" string
  25315. */
  25316. getClassName(): string;
  25317. /** @hidden */
  25318. readonly _isNode: boolean;
  25319. /**
  25320. * An event triggered when the mesh is disposed
  25321. */
  25322. onDisposeObservable: Observable<Node>;
  25323. private _onDisposeObserver;
  25324. /**
  25325. * Sets a callback that will be raised when the node will be disposed
  25326. */
  25327. onDispose: () => void;
  25328. /**
  25329. * Creates a new Node
  25330. * @param name the name and id to be given to this node
  25331. * @param scene the scene this node will be added to
  25332. * @param addToRootNodes the node will be added to scene.rootNodes
  25333. */
  25334. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25335. /**
  25336. * Gets the scene of the node
  25337. * @returns a scene
  25338. */
  25339. getScene(): Scene;
  25340. /**
  25341. * Gets the engine of the node
  25342. * @returns a Engine
  25343. */
  25344. getEngine(): Engine;
  25345. private _behaviors;
  25346. /**
  25347. * Attach a behavior to the node
  25348. * @see http://doc.babylonjs.com/features/behaviour
  25349. * @param behavior defines the behavior to attach
  25350. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25351. * @returns the current Node
  25352. */
  25353. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25354. /**
  25355. * Remove an attached behavior
  25356. * @see http://doc.babylonjs.com/features/behaviour
  25357. * @param behavior defines the behavior to attach
  25358. * @returns the current Node
  25359. */
  25360. removeBehavior(behavior: Behavior<Node>): Node;
  25361. /**
  25362. * Gets the list of attached behaviors
  25363. * @see http://doc.babylonjs.com/features/behaviour
  25364. */
  25365. readonly behaviors: Behavior<Node>[];
  25366. /**
  25367. * Gets an attached behavior by name
  25368. * @param name defines the name of the behavior to look for
  25369. * @see http://doc.babylonjs.com/features/behaviour
  25370. * @returns null if behavior was not found else the requested behavior
  25371. */
  25372. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25373. /**
  25374. * Returns the latest update of the World matrix
  25375. * @returns a Matrix
  25376. */
  25377. getWorldMatrix(): Matrix;
  25378. /** @hidden */
  25379. _getWorldMatrixDeterminant(): number;
  25380. /**
  25381. * Returns directly the latest state of the mesh World matrix.
  25382. * A Matrix is returned.
  25383. */
  25384. readonly worldMatrixFromCache: Matrix;
  25385. /** @hidden */
  25386. _initCache(): void;
  25387. /** @hidden */
  25388. updateCache(force?: boolean): void;
  25389. /** @hidden */
  25390. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25391. /** @hidden */
  25392. _updateCache(ignoreParentClass?: boolean): void;
  25393. /** @hidden */
  25394. _isSynchronized(): boolean;
  25395. /** @hidden */
  25396. _markSyncedWithParent(): void;
  25397. /** @hidden */
  25398. isSynchronizedWithParent(): boolean;
  25399. /** @hidden */
  25400. isSynchronized(): boolean;
  25401. /**
  25402. * Is this node ready to be used/rendered
  25403. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25404. * @return true if the node is ready
  25405. */
  25406. isReady(completeCheck?: boolean): boolean;
  25407. /**
  25408. * Is this node enabled?
  25409. * 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
  25410. * @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
  25411. * @return whether this node (and its parent) is enabled
  25412. */
  25413. isEnabled(checkAncestors?: boolean): boolean;
  25414. /** @hidden */
  25415. protected _syncParentEnabledState(): void;
  25416. /**
  25417. * Set the enabled state of this node
  25418. * @param value defines the new enabled state
  25419. */
  25420. setEnabled(value: boolean): void;
  25421. /**
  25422. * Is this node a descendant of the given node?
  25423. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25424. * @param ancestor defines the parent node to inspect
  25425. * @returns a boolean indicating if this node is a descendant of the given node
  25426. */
  25427. isDescendantOf(ancestor: Node): boolean;
  25428. /** @hidden */
  25429. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25430. /**
  25431. * Will return all nodes that have this node as ascendant
  25432. * @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
  25433. * @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
  25434. * @return all children nodes of all types
  25435. */
  25436. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25437. /**
  25438. * Get all child-meshes of this node
  25439. * @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)
  25440. * @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
  25441. * @returns an array of AbstractMesh
  25442. */
  25443. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25444. /**
  25445. * Get all direct children of this node
  25446. * @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
  25447. * @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)
  25448. * @returns an array of Node
  25449. */
  25450. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25451. /** @hidden */
  25452. _setReady(state: boolean): void;
  25453. /**
  25454. * Get an animation by name
  25455. * @param name defines the name of the animation to look for
  25456. * @returns null if not found else the requested animation
  25457. */
  25458. getAnimationByName(name: string): Nullable<Animation>;
  25459. /**
  25460. * Creates an animation range for this node
  25461. * @param name defines the name of the range
  25462. * @param from defines the starting key
  25463. * @param to defines the end key
  25464. */
  25465. createAnimationRange(name: string, from: number, to: number): void;
  25466. /**
  25467. * Delete a specific animation range
  25468. * @param name defines the name of the range to delete
  25469. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25470. */
  25471. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25472. /**
  25473. * Get an animation range by name
  25474. * @param name defines the name of the animation range to look for
  25475. * @returns null if not found else the requested animation range
  25476. */
  25477. getAnimationRange(name: string): Nullable<AnimationRange>;
  25478. /**
  25479. * Gets the list of all animation ranges defined on this node
  25480. * @returns an array
  25481. */
  25482. getAnimationRanges(): Nullable<AnimationRange>[];
  25483. /**
  25484. * Will start the animation sequence
  25485. * @param name defines the range frames for animation sequence
  25486. * @param loop defines if the animation should loop (false by default)
  25487. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25488. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25489. * @returns the object created for this animation. If range does not exist, it will return null
  25490. */
  25491. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25492. /**
  25493. * Serialize animation ranges into a JSON compatible object
  25494. * @returns serialization object
  25495. */
  25496. serializeAnimationRanges(): any;
  25497. /**
  25498. * Computes the world matrix of the node
  25499. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25500. * @returns the world matrix
  25501. */
  25502. computeWorldMatrix(force?: boolean): Matrix;
  25503. /**
  25504. * Releases resources associated with this node.
  25505. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25506. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25507. */
  25508. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25509. /**
  25510. * Parse animation range data from a serialization object and store them into a given node
  25511. * @param node defines where to store the animation ranges
  25512. * @param parsedNode defines the serialization object to read data from
  25513. * @param scene defines the hosting scene
  25514. */
  25515. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25516. }
  25517. }
  25518. declare module "babylonjs/Animations/animation" {
  25519. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25520. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25521. import { Nullable } from "babylonjs/types";
  25522. import { Scene } from "babylonjs/scene";
  25523. import { IAnimatable } from "babylonjs/Misc/tools";
  25524. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25525. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25526. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25527. import { Node } from "babylonjs/node";
  25528. import { Animatable } from "babylonjs/Animations/animatable";
  25529. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25530. /**
  25531. * Class used to store any kind of animation
  25532. */
  25533. export class Animation {
  25534. /**Name of the animation */
  25535. name: string;
  25536. /**Property to animate */
  25537. targetProperty: string;
  25538. /**The frames per second of the animation */
  25539. framePerSecond: number;
  25540. /**The data type of the animation */
  25541. dataType: number;
  25542. /**The loop mode of the animation */
  25543. loopMode?: number | undefined;
  25544. /**Specifies if blending should be enabled */
  25545. enableBlending?: boolean | undefined;
  25546. /**
  25547. * Use matrix interpolation instead of using direct key value when animating matrices
  25548. */
  25549. static AllowMatricesInterpolation: boolean;
  25550. /**
  25551. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25552. */
  25553. static AllowMatrixDecomposeForInterpolation: boolean;
  25554. /**
  25555. * Stores the key frames of the animation
  25556. */
  25557. private _keys;
  25558. /**
  25559. * Stores the easing function of the animation
  25560. */
  25561. private _easingFunction;
  25562. /**
  25563. * @hidden Internal use only
  25564. */
  25565. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25566. /**
  25567. * The set of event that will be linked to this animation
  25568. */
  25569. private _events;
  25570. /**
  25571. * Stores an array of target property paths
  25572. */
  25573. targetPropertyPath: string[];
  25574. /**
  25575. * Stores the blending speed of the animation
  25576. */
  25577. blendingSpeed: number;
  25578. /**
  25579. * Stores the animation ranges for the animation
  25580. */
  25581. private _ranges;
  25582. /**
  25583. * @hidden Internal use
  25584. */
  25585. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25586. /**
  25587. * Sets up an animation
  25588. * @param property The property to animate
  25589. * @param animationType The animation type to apply
  25590. * @param framePerSecond The frames per second of the animation
  25591. * @param easingFunction The easing function used in the animation
  25592. * @returns The created animation
  25593. */
  25594. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25595. /**
  25596. * Create and start an animation on a node
  25597. * @param name defines the name of the global animation that will be run on all nodes
  25598. * @param node defines the root node where the animation will take place
  25599. * @param targetProperty defines property to animate
  25600. * @param framePerSecond defines the number of frame per second yo use
  25601. * @param totalFrame defines the number of frames in total
  25602. * @param from defines the initial value
  25603. * @param to defines the final value
  25604. * @param loopMode defines which loop mode you want to use (off by default)
  25605. * @param easingFunction defines the easing function to use (linear by default)
  25606. * @param onAnimationEnd defines the callback to call when animation end
  25607. * @returns the animatable created for this animation
  25608. */
  25609. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25610. /**
  25611. * Create and start an animation on a node and its descendants
  25612. * @param name defines the name of the global animation that will be run on all nodes
  25613. * @param node defines the root node where the animation will take place
  25614. * @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
  25615. * @param targetProperty defines property to animate
  25616. * @param framePerSecond defines the number of frame per second to use
  25617. * @param totalFrame defines the number of frames in total
  25618. * @param from defines the initial value
  25619. * @param to defines the final value
  25620. * @param loopMode defines which loop mode you want to use (off by default)
  25621. * @param easingFunction defines the easing function to use (linear by default)
  25622. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25623. * @returns the list of animatables created for all nodes
  25624. * @example https://www.babylonjs-playground.com/#MH0VLI
  25625. */
  25626. 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[]>;
  25627. /**
  25628. * Creates a new animation, merges it with the existing animations and starts it
  25629. * @param name Name of the animation
  25630. * @param node Node which contains the scene that begins the animations
  25631. * @param targetProperty Specifies which property to animate
  25632. * @param framePerSecond The frames per second of the animation
  25633. * @param totalFrame The total number of frames
  25634. * @param from The frame at the beginning of the animation
  25635. * @param to The frame at the end of the animation
  25636. * @param loopMode Specifies the loop mode of the animation
  25637. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25638. * @param onAnimationEnd Callback to run once the animation is complete
  25639. * @returns Nullable animation
  25640. */
  25641. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25642. /**
  25643. * Transition property of an host to the target Value
  25644. * @param property The property to transition
  25645. * @param targetValue The target Value of the property
  25646. * @param host The object where the property to animate belongs
  25647. * @param scene Scene used to run the animation
  25648. * @param frameRate Framerate (in frame/s) to use
  25649. * @param transition The transition type we want to use
  25650. * @param duration The duration of the animation, in milliseconds
  25651. * @param onAnimationEnd Callback trigger at the end of the animation
  25652. * @returns Nullable animation
  25653. */
  25654. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25655. /**
  25656. * Return the array of runtime animations currently using this animation
  25657. */
  25658. readonly runtimeAnimations: RuntimeAnimation[];
  25659. /**
  25660. * Specifies if any of the runtime animations are currently running
  25661. */
  25662. readonly hasRunningRuntimeAnimations: boolean;
  25663. /**
  25664. * Initializes the animation
  25665. * @param name Name of the animation
  25666. * @param targetProperty Property to animate
  25667. * @param framePerSecond The frames per second of the animation
  25668. * @param dataType The data type of the animation
  25669. * @param loopMode The loop mode of the animation
  25670. * @param enableBlending Specifies if blending should be enabled
  25671. */
  25672. constructor(
  25673. /**Name of the animation */
  25674. name: string,
  25675. /**Property to animate */
  25676. targetProperty: string,
  25677. /**The frames per second of the animation */
  25678. framePerSecond: number,
  25679. /**The data type of the animation */
  25680. dataType: number,
  25681. /**The loop mode of the animation */
  25682. loopMode?: number | undefined,
  25683. /**Specifies if blending should be enabled */
  25684. enableBlending?: boolean | undefined);
  25685. /**
  25686. * Converts the animation to a string
  25687. * @param fullDetails support for multiple levels of logging within scene loading
  25688. * @returns String form of the animation
  25689. */
  25690. toString(fullDetails?: boolean): string;
  25691. /**
  25692. * Add an event to this animation
  25693. * @param event Event to add
  25694. */
  25695. addEvent(event: AnimationEvent): void;
  25696. /**
  25697. * Remove all events found at the given frame
  25698. * @param frame The frame to remove events from
  25699. */
  25700. removeEvents(frame: number): void;
  25701. /**
  25702. * Retrieves all the events from the animation
  25703. * @returns Events from the animation
  25704. */
  25705. getEvents(): AnimationEvent[];
  25706. /**
  25707. * Creates an animation range
  25708. * @param name Name of the animation range
  25709. * @param from Starting frame of the animation range
  25710. * @param to Ending frame of the animation
  25711. */
  25712. createRange(name: string, from: number, to: number): void;
  25713. /**
  25714. * Deletes an animation range by name
  25715. * @param name Name of the animation range to delete
  25716. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25717. */
  25718. deleteRange(name: string, deleteFrames?: boolean): void;
  25719. /**
  25720. * Gets the animation range by name, or null if not defined
  25721. * @param name Name of the animation range
  25722. * @returns Nullable animation range
  25723. */
  25724. getRange(name: string): Nullable<AnimationRange>;
  25725. /**
  25726. * Gets the key frames from the animation
  25727. * @returns The key frames of the animation
  25728. */
  25729. getKeys(): Array<IAnimationKey>;
  25730. /**
  25731. * Gets the highest frame rate of the animation
  25732. * @returns Highest frame rate of the animation
  25733. */
  25734. getHighestFrame(): number;
  25735. /**
  25736. * Gets the easing function of the animation
  25737. * @returns Easing function of the animation
  25738. */
  25739. getEasingFunction(): IEasingFunction;
  25740. /**
  25741. * Sets the easing function of the animation
  25742. * @param easingFunction A custom mathematical formula for animation
  25743. */
  25744. setEasingFunction(easingFunction: EasingFunction): void;
  25745. /**
  25746. * Interpolates a scalar linearly
  25747. * @param startValue Start value of the animation curve
  25748. * @param endValue End value of the animation curve
  25749. * @param gradient Scalar amount to interpolate
  25750. * @returns Interpolated scalar value
  25751. */
  25752. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25753. /**
  25754. * Interpolates a scalar cubically
  25755. * @param startValue Start value of the animation curve
  25756. * @param outTangent End tangent of the animation
  25757. * @param endValue End value of the animation curve
  25758. * @param inTangent Start tangent of the animation curve
  25759. * @param gradient Scalar amount to interpolate
  25760. * @returns Interpolated scalar value
  25761. */
  25762. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25763. /**
  25764. * Interpolates a quaternion using a spherical linear interpolation
  25765. * @param startValue Start value of the animation curve
  25766. * @param endValue End value of the animation curve
  25767. * @param gradient Scalar amount to interpolate
  25768. * @returns Interpolated quaternion value
  25769. */
  25770. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25771. /**
  25772. * Interpolates a quaternion cubically
  25773. * @param startValue Start value of the animation curve
  25774. * @param outTangent End tangent of the animation curve
  25775. * @param endValue End value of the animation curve
  25776. * @param inTangent Start tangent of the animation curve
  25777. * @param gradient Scalar amount to interpolate
  25778. * @returns Interpolated quaternion value
  25779. */
  25780. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25781. /**
  25782. * Interpolates a Vector3 linearl
  25783. * @param startValue Start value of the animation curve
  25784. * @param endValue End value of the animation curve
  25785. * @param gradient Scalar amount to interpolate
  25786. * @returns Interpolated scalar value
  25787. */
  25788. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25789. /**
  25790. * Interpolates a Vector3 cubically
  25791. * @param startValue Start value of the animation curve
  25792. * @param outTangent End tangent of the animation
  25793. * @param endValue End value of the animation curve
  25794. * @param inTangent Start tangent of the animation curve
  25795. * @param gradient Scalar amount to interpolate
  25796. * @returns InterpolatedVector3 value
  25797. */
  25798. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25799. /**
  25800. * Interpolates a Vector2 linearly
  25801. * @param startValue Start value of the animation curve
  25802. * @param endValue End value of the animation curve
  25803. * @param gradient Scalar amount to interpolate
  25804. * @returns Interpolated Vector2 value
  25805. */
  25806. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25807. /**
  25808. * Interpolates a Vector2 cubically
  25809. * @param startValue Start value of the animation curve
  25810. * @param outTangent End tangent of the animation
  25811. * @param endValue End value of the animation curve
  25812. * @param inTangent Start tangent of the animation curve
  25813. * @param gradient Scalar amount to interpolate
  25814. * @returns Interpolated Vector2 value
  25815. */
  25816. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25817. /**
  25818. * Interpolates a size linearly
  25819. * @param startValue Start value of the animation curve
  25820. * @param endValue End value of the animation curve
  25821. * @param gradient Scalar amount to interpolate
  25822. * @returns Interpolated Size value
  25823. */
  25824. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25825. /**
  25826. * Interpolates a Color3 linearly
  25827. * @param startValue Start value of the animation curve
  25828. * @param endValue End value of the animation curve
  25829. * @param gradient Scalar amount to interpolate
  25830. * @returns Interpolated Color3 value
  25831. */
  25832. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25833. /**
  25834. * @hidden Internal use only
  25835. */
  25836. _getKeyValue(value: any): any;
  25837. /**
  25838. * @hidden Internal use only
  25839. */
  25840. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25841. /**
  25842. * Defines the function to use to interpolate matrices
  25843. * @param startValue defines the start matrix
  25844. * @param endValue defines the end matrix
  25845. * @param gradient defines the gradient between both matrices
  25846. * @param result defines an optional target matrix where to store the interpolation
  25847. * @returns the interpolated matrix
  25848. */
  25849. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25850. /**
  25851. * Makes a copy of the animation
  25852. * @returns Cloned animation
  25853. */
  25854. clone(): Animation;
  25855. /**
  25856. * Sets the key frames of the animation
  25857. * @param values The animation key frames to set
  25858. */
  25859. setKeys(values: Array<IAnimationKey>): void;
  25860. /**
  25861. * Serializes the animation to an object
  25862. * @returns Serialized object
  25863. */
  25864. serialize(): any;
  25865. /**
  25866. * Float animation type
  25867. */
  25868. private static _ANIMATIONTYPE_FLOAT;
  25869. /**
  25870. * Vector3 animation type
  25871. */
  25872. private static _ANIMATIONTYPE_VECTOR3;
  25873. /**
  25874. * Quaternion animation type
  25875. */
  25876. private static _ANIMATIONTYPE_QUATERNION;
  25877. /**
  25878. * Matrix animation type
  25879. */
  25880. private static _ANIMATIONTYPE_MATRIX;
  25881. /**
  25882. * Color3 animation type
  25883. */
  25884. private static _ANIMATIONTYPE_COLOR3;
  25885. /**
  25886. * Vector2 animation type
  25887. */
  25888. private static _ANIMATIONTYPE_VECTOR2;
  25889. /**
  25890. * Size animation type
  25891. */
  25892. private static _ANIMATIONTYPE_SIZE;
  25893. /**
  25894. * Relative Loop Mode
  25895. */
  25896. private static _ANIMATIONLOOPMODE_RELATIVE;
  25897. /**
  25898. * Cycle Loop Mode
  25899. */
  25900. private static _ANIMATIONLOOPMODE_CYCLE;
  25901. /**
  25902. * Constant Loop Mode
  25903. */
  25904. private static _ANIMATIONLOOPMODE_CONSTANT;
  25905. /**
  25906. * Get the float animation type
  25907. */
  25908. static readonly ANIMATIONTYPE_FLOAT: number;
  25909. /**
  25910. * Get the Vector3 animation type
  25911. */
  25912. static readonly ANIMATIONTYPE_VECTOR3: number;
  25913. /**
  25914. * Get the Vector2 animation type
  25915. */
  25916. static readonly ANIMATIONTYPE_VECTOR2: number;
  25917. /**
  25918. * Get the Size animation type
  25919. */
  25920. static readonly ANIMATIONTYPE_SIZE: number;
  25921. /**
  25922. * Get the Quaternion animation type
  25923. */
  25924. static readonly ANIMATIONTYPE_QUATERNION: number;
  25925. /**
  25926. * Get the Matrix animation type
  25927. */
  25928. static readonly ANIMATIONTYPE_MATRIX: number;
  25929. /**
  25930. * Get the Color3 animation type
  25931. */
  25932. static readonly ANIMATIONTYPE_COLOR3: number;
  25933. /**
  25934. * Get the Relative Loop Mode
  25935. */
  25936. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25937. /**
  25938. * Get the Cycle Loop Mode
  25939. */
  25940. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25941. /**
  25942. * Get the Constant Loop Mode
  25943. */
  25944. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25945. /** @hidden */
  25946. static _UniversalLerp(left: any, right: any, amount: number): any;
  25947. /**
  25948. * Parses an animation object and creates an animation
  25949. * @param parsedAnimation Parsed animation object
  25950. * @returns Animation object
  25951. */
  25952. static Parse(parsedAnimation: any): Animation;
  25953. /**
  25954. * Appends the serialized animations from the source animations
  25955. * @param source Source containing the animations
  25956. * @param destination Target to store the animations
  25957. */
  25958. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25959. }
  25960. }
  25961. declare module "babylonjs/Materials/Textures/baseTexture" {
  25962. import { Observable } from "babylonjs/Misc/observable";
  25963. import { IAnimatable } from "babylonjs/Misc/tools";
  25964. import { Nullable } from "babylonjs/types";
  25965. import { Scene } from "babylonjs/scene";
  25966. import { Matrix, ISize } from "babylonjs/Maths/math";
  25967. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25969. /**
  25970. * Base class of all the textures in babylon.
  25971. * It groups all the common properties the materials, post process, lights... might need
  25972. * in order to make a correct use of the texture.
  25973. */
  25974. export class BaseTexture implements IAnimatable {
  25975. /**
  25976. * Default anisotropic filtering level for the application.
  25977. * It is set to 4 as a good tradeoff between perf and quality.
  25978. */
  25979. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25980. /**
  25981. * Gets or sets the unique id of the texture
  25982. */
  25983. uniqueId: number;
  25984. /**
  25985. * Define the name of the texture.
  25986. */
  25987. name: string;
  25988. /**
  25989. * Gets or sets an object used to store user defined information.
  25990. */
  25991. metadata: any;
  25992. /**
  25993. * For internal use only. Please do not use.
  25994. */
  25995. reservedDataStore: any;
  25996. private _hasAlpha;
  25997. /**
  25998. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25999. */
  26000. hasAlpha: boolean;
  26001. /**
  26002. * Defines if the alpha value should be determined via the rgb values.
  26003. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26004. */
  26005. getAlphaFromRGB: boolean;
  26006. /**
  26007. * Intensity or strength of the texture.
  26008. * It is commonly used by materials to fine tune the intensity of the texture
  26009. */
  26010. level: number;
  26011. /**
  26012. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26013. * This is part of the texture as textures usually maps to one uv set.
  26014. */
  26015. coordinatesIndex: number;
  26016. private _coordinatesMode;
  26017. /**
  26018. * How a texture is mapped.
  26019. *
  26020. * | Value | Type | Description |
  26021. * | ----- | ----------------------------------- | ----------- |
  26022. * | 0 | EXPLICIT_MODE | |
  26023. * | 1 | SPHERICAL_MODE | |
  26024. * | 2 | PLANAR_MODE | |
  26025. * | 3 | CUBIC_MODE | |
  26026. * | 4 | PROJECTION_MODE | |
  26027. * | 5 | SKYBOX_MODE | |
  26028. * | 6 | INVCUBIC_MODE | |
  26029. * | 7 | EQUIRECTANGULAR_MODE | |
  26030. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26031. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26032. */
  26033. coordinatesMode: number;
  26034. /**
  26035. * | Value | Type | Description |
  26036. * | ----- | ------------------ | ----------- |
  26037. * | 0 | CLAMP_ADDRESSMODE | |
  26038. * | 1 | WRAP_ADDRESSMODE | |
  26039. * | 2 | MIRROR_ADDRESSMODE | |
  26040. */
  26041. wrapU: number;
  26042. /**
  26043. * | Value | Type | Description |
  26044. * | ----- | ------------------ | ----------- |
  26045. * | 0 | CLAMP_ADDRESSMODE | |
  26046. * | 1 | WRAP_ADDRESSMODE | |
  26047. * | 2 | MIRROR_ADDRESSMODE | |
  26048. */
  26049. wrapV: number;
  26050. /**
  26051. * | Value | Type | Description |
  26052. * | ----- | ------------------ | ----------- |
  26053. * | 0 | CLAMP_ADDRESSMODE | |
  26054. * | 1 | WRAP_ADDRESSMODE | |
  26055. * | 2 | MIRROR_ADDRESSMODE | |
  26056. */
  26057. wrapR: number;
  26058. /**
  26059. * With compliant hardware and browser (supporting anisotropic filtering)
  26060. * this defines the level of anisotropic filtering in the texture.
  26061. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26062. */
  26063. anisotropicFilteringLevel: number;
  26064. /**
  26065. * Define if the texture is a cube texture or if false a 2d texture.
  26066. */
  26067. isCube: boolean;
  26068. /**
  26069. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26070. */
  26071. is3D: boolean;
  26072. /**
  26073. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26074. * HDR texture are usually stored in linear space.
  26075. * This only impacts the PBR and Background materials
  26076. */
  26077. gammaSpace: boolean;
  26078. /**
  26079. * Gets whether or not the texture contains RGBD data.
  26080. */
  26081. readonly isRGBD: boolean;
  26082. /**
  26083. * Is Z inverted in the texture (useful in a cube texture).
  26084. */
  26085. invertZ: boolean;
  26086. /**
  26087. * Are mip maps generated for this texture or not.
  26088. */
  26089. readonly noMipmap: boolean;
  26090. /**
  26091. * @hidden
  26092. */
  26093. lodLevelInAlpha: boolean;
  26094. /**
  26095. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26096. */
  26097. lodGenerationOffset: number;
  26098. /**
  26099. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26100. */
  26101. lodGenerationScale: number;
  26102. /**
  26103. * Define if the texture is a render target.
  26104. */
  26105. isRenderTarget: boolean;
  26106. /**
  26107. * Define the unique id of the texture in the scene.
  26108. */
  26109. readonly uid: string;
  26110. /**
  26111. * Return a string representation of the texture.
  26112. * @returns the texture as a string
  26113. */
  26114. toString(): string;
  26115. /**
  26116. * Get the class name of the texture.
  26117. * @returns "BaseTexture"
  26118. */
  26119. getClassName(): string;
  26120. /**
  26121. * Define the list of animation attached to the texture.
  26122. */
  26123. animations: import("babylonjs/Animations/animation").Animation[];
  26124. /**
  26125. * An event triggered when the texture is disposed.
  26126. */
  26127. onDisposeObservable: Observable<BaseTexture>;
  26128. private _onDisposeObserver;
  26129. /**
  26130. * Callback triggered when the texture has been disposed.
  26131. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26132. */
  26133. onDispose: () => void;
  26134. /**
  26135. * Define the current state of the loading sequence when in delayed load mode.
  26136. */
  26137. delayLoadState: number;
  26138. private _scene;
  26139. /** @hidden */
  26140. _texture: Nullable<InternalTexture>;
  26141. private _uid;
  26142. /**
  26143. * Define if the texture is preventinga material to render or not.
  26144. * If not and the texture is not ready, the engine will use a default black texture instead.
  26145. */
  26146. readonly isBlocking: boolean;
  26147. /**
  26148. * Instantiates a new BaseTexture.
  26149. * Base class of all the textures in babylon.
  26150. * It groups all the common properties the materials, post process, lights... might need
  26151. * in order to make a correct use of the texture.
  26152. * @param scene Define the scene the texture blongs to
  26153. */
  26154. constructor(scene: Nullable<Scene>);
  26155. /**
  26156. * Get the scene the texture belongs to.
  26157. * @returns the scene or null if undefined
  26158. */
  26159. getScene(): Nullable<Scene>;
  26160. /**
  26161. * Get the texture transform matrix used to offset tile the texture for istance.
  26162. * @returns the transformation matrix
  26163. */
  26164. getTextureMatrix(): Matrix;
  26165. /**
  26166. * Get the texture reflection matrix used to rotate/transform the reflection.
  26167. * @returns the reflection matrix
  26168. */
  26169. getReflectionTextureMatrix(): Matrix;
  26170. /**
  26171. * Get the underlying lower level texture from Babylon.
  26172. * @returns the insternal texture
  26173. */
  26174. getInternalTexture(): Nullable<InternalTexture>;
  26175. /**
  26176. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26177. * @returns true if ready or not blocking
  26178. */
  26179. isReadyOrNotBlocking(): boolean;
  26180. /**
  26181. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26182. * @returns true if fully ready
  26183. */
  26184. isReady(): boolean;
  26185. private _cachedSize;
  26186. /**
  26187. * Get the size of the texture.
  26188. * @returns the texture size.
  26189. */
  26190. getSize(): ISize;
  26191. /**
  26192. * Get the base size of the texture.
  26193. * It can be different from the size if the texture has been resized for POT for instance
  26194. * @returns the base size
  26195. */
  26196. getBaseSize(): ISize;
  26197. /**
  26198. * Update the sampling mode of the texture.
  26199. * Default is Trilinear mode.
  26200. *
  26201. * | Value | Type | Description |
  26202. * | ----- | ------------------ | ----------- |
  26203. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26204. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26205. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26206. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26207. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26208. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26209. * | 7 | NEAREST_LINEAR | |
  26210. * | 8 | NEAREST_NEAREST | |
  26211. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26212. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26213. * | 11 | LINEAR_LINEAR | |
  26214. * | 12 | LINEAR_NEAREST | |
  26215. *
  26216. * > _mag_: magnification filter (close to the viewer)
  26217. * > _min_: minification filter (far from the viewer)
  26218. * > _mip_: filter used between mip map levels
  26219. *@param samplingMode Define the new sampling mode of the texture
  26220. */
  26221. updateSamplingMode(samplingMode: number): void;
  26222. /**
  26223. * Scales the texture if is `canRescale()`
  26224. * @param ratio the resize factor we want to use to rescale
  26225. */
  26226. scale(ratio: number): void;
  26227. /**
  26228. * Get if the texture can rescale.
  26229. */
  26230. readonly canRescale: boolean;
  26231. /** @hidden */
  26232. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26233. /** @hidden */
  26234. _rebuild(): void;
  26235. /**
  26236. * Triggers the load sequence in delayed load mode.
  26237. */
  26238. delayLoad(): void;
  26239. /**
  26240. * Clones the texture.
  26241. * @returns the cloned texture
  26242. */
  26243. clone(): Nullable<BaseTexture>;
  26244. /**
  26245. * Get the texture underlying type (INT, FLOAT...)
  26246. */
  26247. readonly textureType: number;
  26248. /**
  26249. * Get the texture underlying format (RGB, RGBA...)
  26250. */
  26251. readonly textureFormat: number;
  26252. /**
  26253. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26254. * This will returns an RGBA array buffer containing either in values (0-255) or
  26255. * float values (0-1) depending of the underlying buffer type.
  26256. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26257. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26258. * @param buffer defines a user defined buffer to fill with data (can be null)
  26259. * @returns The Array buffer containing the pixels data.
  26260. */
  26261. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26262. /**
  26263. * Release and destroy the underlying lower level texture aka internalTexture.
  26264. */
  26265. releaseInternalTexture(): void;
  26266. /**
  26267. * Get the polynomial representation of the texture data.
  26268. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26269. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26270. */
  26271. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26272. /** @hidden */
  26273. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26274. /** @hidden */
  26275. readonly _lodTextureMid: Nullable<BaseTexture>;
  26276. /** @hidden */
  26277. readonly _lodTextureLow: Nullable<BaseTexture>;
  26278. /**
  26279. * Dispose the texture and release its associated resources.
  26280. */
  26281. dispose(): void;
  26282. /**
  26283. * Serialize the texture into a JSON representation that can be parsed later on.
  26284. * @returns the JSON representation of the texture
  26285. */
  26286. serialize(): any;
  26287. /**
  26288. * Helper function to be called back once a list of texture contains only ready textures.
  26289. * @param textures Define the list of textures to wait for
  26290. * @param callback Define the callback triggered once the entire list will be ready
  26291. */
  26292. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26293. }
  26294. }
  26295. declare module "babylonjs/Materials/uniformBuffer" {
  26296. import { Nullable, FloatArray } from "babylonjs/types";
  26297. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26298. import { Engine } from "babylonjs/Engines/engine";
  26299. import { Effect } from "babylonjs/Materials/effect";
  26300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26301. /**
  26302. * Uniform buffer objects.
  26303. *
  26304. * Handles blocks of uniform on the GPU.
  26305. *
  26306. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26307. *
  26308. * For more information, please refer to :
  26309. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26310. */
  26311. export class UniformBuffer {
  26312. private _engine;
  26313. private _buffer;
  26314. private _data;
  26315. private _bufferData;
  26316. private _dynamic?;
  26317. private _uniformLocations;
  26318. private _uniformSizes;
  26319. private _uniformLocationPointer;
  26320. private _needSync;
  26321. private _noUBO;
  26322. private _currentEffect;
  26323. private static _MAX_UNIFORM_SIZE;
  26324. private static _tempBuffer;
  26325. /**
  26326. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26327. * This is dynamic to allow compat with webgl 1 and 2.
  26328. * You will need to pass the name of the uniform as well as the value.
  26329. */
  26330. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26331. /**
  26332. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26333. * This is dynamic to allow compat with webgl 1 and 2.
  26334. * You will need to pass the name of the uniform as well as the value.
  26335. */
  26336. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26337. /**
  26338. * Lambda to Update a single float in a uniform buffer.
  26339. * This is dynamic to allow compat with webgl 1 and 2.
  26340. * You will need to pass the name of the uniform as well as the value.
  26341. */
  26342. updateFloat: (name: string, x: number) => void;
  26343. /**
  26344. * Lambda to Update a vec2 of float in a uniform buffer.
  26345. * This is dynamic to allow compat with webgl 1 and 2.
  26346. * You will need to pass the name of the uniform as well as the value.
  26347. */
  26348. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26349. /**
  26350. * Lambda to Update a vec3 of float in a uniform buffer.
  26351. * This is dynamic to allow compat with webgl 1 and 2.
  26352. * You will need to pass the name of the uniform as well as the value.
  26353. */
  26354. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26355. /**
  26356. * Lambda to Update a vec4 of float in a uniform buffer.
  26357. * This is dynamic to allow compat with webgl 1 and 2.
  26358. * You will need to pass the name of the uniform as well as the value.
  26359. */
  26360. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26361. /**
  26362. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26363. * This is dynamic to allow compat with webgl 1 and 2.
  26364. * You will need to pass the name of the uniform as well as the value.
  26365. */
  26366. updateMatrix: (name: string, mat: Matrix) => void;
  26367. /**
  26368. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26369. * This is dynamic to allow compat with webgl 1 and 2.
  26370. * You will need to pass the name of the uniform as well as the value.
  26371. */
  26372. updateVector3: (name: string, vector: Vector3) => void;
  26373. /**
  26374. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26375. * This is dynamic to allow compat with webgl 1 and 2.
  26376. * You will need to pass the name of the uniform as well as the value.
  26377. */
  26378. updateVector4: (name: string, vector: Vector4) => void;
  26379. /**
  26380. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26381. * This is dynamic to allow compat with webgl 1 and 2.
  26382. * You will need to pass the name of the uniform as well as the value.
  26383. */
  26384. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26385. /**
  26386. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26387. * This is dynamic to allow compat with webgl 1 and 2.
  26388. * You will need to pass the name of the uniform as well as the value.
  26389. */
  26390. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26391. /**
  26392. * Instantiates a new Uniform buffer objects.
  26393. *
  26394. * Handles blocks of uniform on the GPU.
  26395. *
  26396. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26397. *
  26398. * For more information, please refer to :
  26399. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26400. * @param engine Define the engine the buffer is associated with
  26401. * @param data Define the data contained in the buffer
  26402. * @param dynamic Define if the buffer is updatable
  26403. */
  26404. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26405. /**
  26406. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26407. * or just falling back on setUniformXXX calls.
  26408. */
  26409. readonly useUbo: boolean;
  26410. /**
  26411. * Indicates if the WebGL underlying uniform buffer is in sync
  26412. * with the javascript cache data.
  26413. */
  26414. readonly isSync: boolean;
  26415. /**
  26416. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26417. * Also, a dynamic UniformBuffer will disable cache verification and always
  26418. * update the underlying WebGL uniform buffer to the GPU.
  26419. * @returns if Dynamic, otherwise false
  26420. */
  26421. isDynamic(): boolean;
  26422. /**
  26423. * The data cache on JS side.
  26424. * @returns the underlying data as a float array
  26425. */
  26426. getData(): Float32Array;
  26427. /**
  26428. * The underlying WebGL Uniform buffer.
  26429. * @returns the webgl buffer
  26430. */
  26431. getBuffer(): Nullable<WebGLBuffer>;
  26432. /**
  26433. * std140 layout specifies how to align data within an UBO structure.
  26434. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26435. * for specs.
  26436. */
  26437. private _fillAlignment;
  26438. /**
  26439. * Adds an uniform in the buffer.
  26440. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26441. * for the layout to be correct !
  26442. * @param name Name of the uniform, as used in the uniform block in the shader.
  26443. * @param size Data size, or data directly.
  26444. */
  26445. addUniform(name: string, size: number | number[]): void;
  26446. /**
  26447. * Adds a Matrix 4x4 to the uniform buffer.
  26448. * @param name Name of the uniform, as used in the uniform block in the shader.
  26449. * @param mat A 4x4 matrix.
  26450. */
  26451. addMatrix(name: string, mat: Matrix): void;
  26452. /**
  26453. * Adds a vec2 to the uniform buffer.
  26454. * @param name Name of the uniform, as used in the uniform block in the shader.
  26455. * @param x Define the x component value of the vec2
  26456. * @param y Define the y component value of the vec2
  26457. */
  26458. addFloat2(name: string, x: number, y: number): void;
  26459. /**
  26460. * Adds a vec3 to the uniform buffer.
  26461. * @param name Name of the uniform, as used in the uniform block in the shader.
  26462. * @param x Define the x component value of the vec3
  26463. * @param y Define the y component value of the vec3
  26464. * @param z Define the z component value of the vec3
  26465. */
  26466. addFloat3(name: string, x: number, y: number, z: number): void;
  26467. /**
  26468. * Adds a vec3 to the uniform buffer.
  26469. * @param name Name of the uniform, as used in the uniform block in the shader.
  26470. * @param color Define the vec3 from a Color
  26471. */
  26472. addColor3(name: string, color: Color3): void;
  26473. /**
  26474. * Adds a vec4 to the uniform buffer.
  26475. * @param name Name of the uniform, as used in the uniform block in the shader.
  26476. * @param color Define the rgb components from a Color
  26477. * @param alpha Define the a component of the vec4
  26478. */
  26479. addColor4(name: string, color: Color3, alpha: number): void;
  26480. /**
  26481. * Adds a vec3 to the uniform buffer.
  26482. * @param name Name of the uniform, as used in the uniform block in the shader.
  26483. * @param vector Define the vec3 components from a Vector
  26484. */
  26485. addVector3(name: string, vector: Vector3): void;
  26486. /**
  26487. * Adds a Matrix 3x3 to the uniform buffer.
  26488. * @param name Name of the uniform, as used in the uniform block in the shader.
  26489. */
  26490. addMatrix3x3(name: string): void;
  26491. /**
  26492. * Adds a Matrix 2x2 to the uniform buffer.
  26493. * @param name Name of the uniform, as used in the uniform block in the shader.
  26494. */
  26495. addMatrix2x2(name: string): void;
  26496. /**
  26497. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26498. */
  26499. create(): void;
  26500. /** @hidden */
  26501. _rebuild(): void;
  26502. /**
  26503. * Updates the WebGL Uniform Buffer on the GPU.
  26504. * If the `dynamic` flag is set to true, no cache comparison is done.
  26505. * Otherwise, the buffer will be updated only if the cache differs.
  26506. */
  26507. update(): void;
  26508. /**
  26509. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26510. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26511. * @param data Define the flattened data
  26512. * @param size Define the size of the data.
  26513. */
  26514. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26515. private _updateMatrix3x3ForUniform;
  26516. private _updateMatrix3x3ForEffect;
  26517. private _updateMatrix2x2ForEffect;
  26518. private _updateMatrix2x2ForUniform;
  26519. private _updateFloatForEffect;
  26520. private _updateFloatForUniform;
  26521. private _updateFloat2ForEffect;
  26522. private _updateFloat2ForUniform;
  26523. private _updateFloat3ForEffect;
  26524. private _updateFloat3ForUniform;
  26525. private _updateFloat4ForEffect;
  26526. private _updateFloat4ForUniform;
  26527. private _updateMatrixForEffect;
  26528. private _updateMatrixForUniform;
  26529. private _updateVector3ForEffect;
  26530. private _updateVector3ForUniform;
  26531. private _updateVector4ForEffect;
  26532. private _updateVector4ForUniform;
  26533. private _updateColor3ForEffect;
  26534. private _updateColor3ForUniform;
  26535. private _updateColor4ForEffect;
  26536. private _updateColor4ForUniform;
  26537. /**
  26538. * Sets a sampler uniform on the effect.
  26539. * @param name Define the name of the sampler.
  26540. * @param texture Define the texture to set in the sampler
  26541. */
  26542. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26543. /**
  26544. * Directly updates the value of the uniform in the cache AND on the GPU.
  26545. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26546. * @param data Define the flattened data
  26547. */
  26548. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26549. /**
  26550. * Binds this uniform buffer to an effect.
  26551. * @param effect Define the effect to bind the buffer to
  26552. * @param name Name of the uniform block in the shader.
  26553. */
  26554. bindToEffect(effect: Effect, name: string): void;
  26555. /**
  26556. * Disposes the uniform buffer.
  26557. */
  26558. dispose(): void;
  26559. }
  26560. }
  26561. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26562. import { Nullable } from "babylonjs/types";
  26563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26564. /**
  26565. * This represents the required contract to create a new type of texture loader.
  26566. */
  26567. export interface IInternalTextureLoader {
  26568. /**
  26569. * Defines wether the loader supports cascade loading the different faces.
  26570. */
  26571. supportCascades: boolean;
  26572. /**
  26573. * This returns if the loader support the current file information.
  26574. * @param extension defines the file extension of the file being loaded
  26575. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26576. * @param fallback defines the fallback internal texture if any
  26577. * @param isBase64 defines whether the texture is encoded as a base64
  26578. * @param isBuffer defines whether the texture data are stored as a buffer
  26579. * @returns true if the loader can load the specified file
  26580. */
  26581. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26582. /**
  26583. * Transform the url before loading if required.
  26584. * @param rootUrl the url of the texture
  26585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26586. * @returns the transformed texture
  26587. */
  26588. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26589. /**
  26590. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26591. * @param rootUrl the url of the texture
  26592. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26593. * @returns the fallback texture
  26594. */
  26595. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26596. /**
  26597. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26598. * @param data contains the texture data
  26599. * @param texture defines the BabylonJS internal texture
  26600. * @param createPolynomials will be true if polynomials have been requested
  26601. * @param onLoad defines the callback to trigger once the texture is ready
  26602. * @param onError defines the callback to trigger in case of error
  26603. */
  26604. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26605. /**
  26606. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26607. * @param data contains the texture data
  26608. * @param texture defines the BabylonJS internal texture
  26609. * @param callback defines the method to call once ready to upload
  26610. */
  26611. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26612. }
  26613. }
  26614. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26615. import { Scene } from "babylonjs/scene";
  26616. import { Engine } from "babylonjs/Engines/engine";
  26617. import { Texture } from "babylonjs/Materials/Textures/texture";
  26618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26619. /**
  26620. * Creation options of the multi render target texture.
  26621. */
  26622. export interface IMultiRenderTargetOptions {
  26623. /**
  26624. * Define if the texture needs to create mip maps after render.
  26625. */
  26626. generateMipMaps?: boolean;
  26627. /**
  26628. * Define the types of all the draw buffers we want to create
  26629. */
  26630. types?: number[];
  26631. /**
  26632. * Define the sampling modes of all the draw buffers we want to create
  26633. */
  26634. samplingModes?: number[];
  26635. /**
  26636. * Define if a depth buffer is required
  26637. */
  26638. generateDepthBuffer?: boolean;
  26639. /**
  26640. * Define if a stencil buffer is required
  26641. */
  26642. generateStencilBuffer?: boolean;
  26643. /**
  26644. * Define if a depth texture is required instead of a depth buffer
  26645. */
  26646. generateDepthTexture?: boolean;
  26647. /**
  26648. * Define the number of desired draw buffers
  26649. */
  26650. textureCount?: number;
  26651. /**
  26652. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26653. */
  26654. doNotChangeAspectRatio?: boolean;
  26655. /**
  26656. * Define the default type of the buffers we are creating
  26657. */
  26658. defaultType?: number;
  26659. }
  26660. /**
  26661. * A multi render target, like a render target provides the ability to render to a texture.
  26662. * Unlike the render target, it can render to several draw buffers in one draw.
  26663. * This is specially interesting in deferred rendering or for any effects requiring more than
  26664. * just one color from a single pass.
  26665. */
  26666. export class MultiRenderTarget extends RenderTargetTexture {
  26667. private _internalTextures;
  26668. private _textures;
  26669. private _multiRenderTargetOptions;
  26670. /**
  26671. * Get if draw buffers are currently supported by the used hardware and browser.
  26672. */
  26673. readonly isSupported: boolean;
  26674. /**
  26675. * Get the list of textures generated by the multi render target.
  26676. */
  26677. readonly textures: Texture[];
  26678. /**
  26679. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26680. */
  26681. readonly depthTexture: Texture;
  26682. /**
  26683. * Set the wrapping mode on U of all the textures we are rendering to.
  26684. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26685. */
  26686. wrapU: number;
  26687. /**
  26688. * Set the wrapping mode on V of all the textures we are rendering to.
  26689. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26690. */
  26691. wrapV: number;
  26692. /**
  26693. * Instantiate a new multi render target texture.
  26694. * A multi render target, like a render target provides the ability to render to a texture.
  26695. * Unlike the render target, it can render to several draw buffers in one draw.
  26696. * This is specially interesting in deferred rendering or for any effects requiring more than
  26697. * just one color from a single pass.
  26698. * @param name Define the name of the texture
  26699. * @param size Define the size of the buffers to render to
  26700. * @param count Define the number of target we are rendering into
  26701. * @param scene Define the scene the texture belongs to
  26702. * @param options Define the options used to create the multi render target
  26703. */
  26704. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26705. /** @hidden */
  26706. _rebuild(): void;
  26707. private _createInternalTextures;
  26708. private _createTextures;
  26709. /**
  26710. * Define the number of samples used if MSAA is enabled.
  26711. */
  26712. samples: number;
  26713. /**
  26714. * Resize all the textures in the multi render target.
  26715. * Be carrefull as it will recreate all the data in the new texture.
  26716. * @param size Define the new size
  26717. */
  26718. resize(size: any): void;
  26719. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26720. /**
  26721. * Dispose the render targets and their associated resources
  26722. */
  26723. dispose(): void;
  26724. /**
  26725. * Release all the underlying texture used as draw buffers.
  26726. */
  26727. releaseInternalTextures(): void;
  26728. }
  26729. }
  26730. declare module "babylonjs/Audio/analyser" {
  26731. import { Scene } from "babylonjs/scene";
  26732. /**
  26733. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26735. */
  26736. export class Analyser {
  26737. /**
  26738. * Gets or sets the smoothing
  26739. * @ignorenaming
  26740. */
  26741. SMOOTHING: number;
  26742. /**
  26743. * Gets or sets the FFT table size
  26744. * @ignorenaming
  26745. */
  26746. FFT_SIZE: number;
  26747. /**
  26748. * Gets or sets the bar graph amplitude
  26749. * @ignorenaming
  26750. */
  26751. BARGRAPHAMPLITUDE: number;
  26752. /**
  26753. * Gets or sets the position of the debug canvas
  26754. * @ignorenaming
  26755. */
  26756. DEBUGCANVASPOS: {
  26757. x: number;
  26758. y: number;
  26759. };
  26760. /**
  26761. * Gets or sets the debug canvas size
  26762. * @ignorenaming
  26763. */
  26764. DEBUGCANVASSIZE: {
  26765. width: number;
  26766. height: number;
  26767. };
  26768. private _byteFreqs;
  26769. private _byteTime;
  26770. private _floatFreqs;
  26771. private _webAudioAnalyser;
  26772. private _debugCanvas;
  26773. private _debugCanvasContext;
  26774. private _scene;
  26775. private _registerFunc;
  26776. private _audioEngine;
  26777. /**
  26778. * Creates a new analyser
  26779. * @param scene defines hosting scene
  26780. */
  26781. constructor(scene: Scene);
  26782. /**
  26783. * Get the number of data values you will have to play with for the visualization
  26784. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26785. * @returns a number
  26786. */
  26787. getFrequencyBinCount(): number;
  26788. /**
  26789. * Gets the current frequency data as a byte array
  26790. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26791. * @returns a Uint8Array
  26792. */
  26793. getByteFrequencyData(): Uint8Array;
  26794. /**
  26795. * Gets the current waveform as a byte array
  26796. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26797. * @returns a Uint8Array
  26798. */
  26799. getByteTimeDomainData(): Uint8Array;
  26800. /**
  26801. * Gets the current frequency data as a float array
  26802. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26803. * @returns a Float32Array
  26804. */
  26805. getFloatFrequencyData(): Float32Array;
  26806. /**
  26807. * Renders the debug canvas
  26808. */
  26809. drawDebugCanvas(): void;
  26810. /**
  26811. * Stops rendering the debug canvas and removes it
  26812. */
  26813. stopDebugCanvas(): void;
  26814. /**
  26815. * Connects two audio nodes
  26816. * @param inputAudioNode defines first node to connect
  26817. * @param outputAudioNode defines second node to connect
  26818. */
  26819. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26820. /**
  26821. * Releases all associated resources
  26822. */
  26823. dispose(): void;
  26824. }
  26825. }
  26826. declare module "babylonjs/Audio/audioEngine" {
  26827. import { IDisposable } from "babylonjs/scene";
  26828. import { Analyser } from "babylonjs/Audio/analyser";
  26829. import { Nullable } from "babylonjs/types";
  26830. import { Observable } from "babylonjs/Misc/observable";
  26831. /**
  26832. * This represents an audio engine and it is responsible
  26833. * to play, synchronize and analyse sounds throughout the application.
  26834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26835. */
  26836. export interface IAudioEngine extends IDisposable {
  26837. /**
  26838. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26839. */
  26840. readonly canUseWebAudio: boolean;
  26841. /**
  26842. * Gets the current AudioContext if available.
  26843. */
  26844. readonly audioContext: Nullable<AudioContext>;
  26845. /**
  26846. * The master gain node defines the global audio volume of your audio engine.
  26847. */
  26848. readonly masterGain: GainNode;
  26849. /**
  26850. * Gets whether or not mp3 are supported by your browser.
  26851. */
  26852. readonly isMP3supported: boolean;
  26853. /**
  26854. * Gets whether or not ogg are supported by your browser.
  26855. */
  26856. readonly isOGGsupported: boolean;
  26857. /**
  26858. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26859. * @ignoreNaming
  26860. */
  26861. WarnedWebAudioUnsupported: boolean;
  26862. /**
  26863. * Defines if the audio engine relies on a custom unlocked button.
  26864. * In this case, the embedded button will not be displayed.
  26865. */
  26866. useCustomUnlockedButton: boolean;
  26867. /**
  26868. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26869. */
  26870. readonly unlocked: boolean;
  26871. /**
  26872. * Event raised when audio has been unlocked on the browser.
  26873. */
  26874. onAudioUnlockedObservable: Observable<AudioEngine>;
  26875. /**
  26876. * Event raised when audio has been locked on the browser.
  26877. */
  26878. onAudioLockedObservable: Observable<AudioEngine>;
  26879. /**
  26880. * Flags the audio engine in Locked state.
  26881. * This happens due to new browser policies preventing audio to autoplay.
  26882. */
  26883. lock(): void;
  26884. /**
  26885. * Unlocks the audio engine once a user action has been done on the dom.
  26886. * This is helpful to resume play once browser policies have been satisfied.
  26887. */
  26888. unlock(): void;
  26889. }
  26890. /**
  26891. * This represents the default audio engine used in babylon.
  26892. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26894. */
  26895. export class AudioEngine implements IAudioEngine {
  26896. private _audioContext;
  26897. private _audioContextInitialized;
  26898. private _muteButton;
  26899. private _hostElement;
  26900. /**
  26901. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26902. */
  26903. canUseWebAudio: boolean;
  26904. /**
  26905. * The master gain node defines the global audio volume of your audio engine.
  26906. */
  26907. masterGain: GainNode;
  26908. /**
  26909. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26910. * @ignoreNaming
  26911. */
  26912. WarnedWebAudioUnsupported: boolean;
  26913. /**
  26914. * Gets whether or not mp3 are supported by your browser.
  26915. */
  26916. isMP3supported: boolean;
  26917. /**
  26918. * Gets whether or not ogg are supported by your browser.
  26919. */
  26920. isOGGsupported: boolean;
  26921. /**
  26922. * Gets whether audio has been unlocked on the device.
  26923. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26924. * a user interaction has happened.
  26925. */
  26926. unlocked: boolean;
  26927. /**
  26928. * Defines if the audio engine relies on a custom unlocked button.
  26929. * In this case, the embedded button will not be displayed.
  26930. */
  26931. useCustomUnlockedButton: boolean;
  26932. /**
  26933. * Event raised when audio has been unlocked on the browser.
  26934. */
  26935. onAudioUnlockedObservable: Observable<AudioEngine>;
  26936. /**
  26937. * Event raised when audio has been locked on the browser.
  26938. */
  26939. onAudioLockedObservable: Observable<AudioEngine>;
  26940. /**
  26941. * Gets the current AudioContext if available.
  26942. */
  26943. readonly audioContext: Nullable<AudioContext>;
  26944. private _connectedAnalyser;
  26945. /**
  26946. * Instantiates a new audio engine.
  26947. *
  26948. * There should be only one per page as some browsers restrict the number
  26949. * of audio contexts you can create.
  26950. * @param hostElement defines the host element where to display the mute icon if necessary
  26951. */
  26952. constructor(hostElement?: Nullable<HTMLElement>);
  26953. /**
  26954. * Flags the audio engine in Locked state.
  26955. * This happens due to new browser policies preventing audio to autoplay.
  26956. */
  26957. lock(): void;
  26958. /**
  26959. * Unlocks the audio engine once a user action has been done on the dom.
  26960. * This is helpful to resume play once browser policies have been satisfied.
  26961. */
  26962. unlock(): void;
  26963. private _resumeAudioContext;
  26964. private _initializeAudioContext;
  26965. private _tryToRun;
  26966. private _triggerRunningState;
  26967. private _triggerSuspendedState;
  26968. private _displayMuteButton;
  26969. private _moveButtonToTopLeft;
  26970. private _onResize;
  26971. private _hideMuteButton;
  26972. /**
  26973. * Destroy and release the resources associated with the audio ccontext.
  26974. */
  26975. dispose(): void;
  26976. /**
  26977. * Gets the global volume sets on the master gain.
  26978. * @returns the global volume if set or -1 otherwise
  26979. */
  26980. getGlobalVolume(): number;
  26981. /**
  26982. * Sets the global volume of your experience (sets on the master gain).
  26983. * @param newVolume Defines the new global volume of the application
  26984. */
  26985. setGlobalVolume(newVolume: number): void;
  26986. /**
  26987. * Connect the audio engine to an audio analyser allowing some amazing
  26988. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26989. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26990. * @param analyser The analyser to connect to the engine
  26991. */
  26992. connectToAnalyser(analyser: Analyser): void;
  26993. }
  26994. }
  26995. declare module "babylonjs/Loading/loadingScreen" {
  26996. /**
  26997. * Interface used to present a loading screen while loading a scene
  26998. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26999. */
  27000. export interface ILoadingScreen {
  27001. /**
  27002. * Function called to display the loading screen
  27003. */
  27004. displayLoadingUI: () => void;
  27005. /**
  27006. * Function called to hide the loading screen
  27007. */
  27008. hideLoadingUI: () => void;
  27009. /**
  27010. * Gets or sets the color to use for the background
  27011. */
  27012. loadingUIBackgroundColor: string;
  27013. /**
  27014. * Gets or sets the text to display while loading
  27015. */
  27016. loadingUIText: string;
  27017. }
  27018. /**
  27019. * Class used for the default loading screen
  27020. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27021. */
  27022. export class DefaultLoadingScreen implements ILoadingScreen {
  27023. private _renderingCanvas;
  27024. private _loadingText;
  27025. private _loadingDivBackgroundColor;
  27026. private _loadingDiv;
  27027. private _loadingTextDiv;
  27028. /**
  27029. * Creates a new default loading screen
  27030. * @param _renderingCanvas defines the canvas used to render the scene
  27031. * @param _loadingText defines the default text to display
  27032. * @param _loadingDivBackgroundColor defines the default background color
  27033. */
  27034. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27035. /**
  27036. * Function called to display the loading screen
  27037. */
  27038. displayLoadingUI(): void;
  27039. /**
  27040. * Function called to hide the loading screen
  27041. */
  27042. hideLoadingUI(): void;
  27043. /**
  27044. * Gets or sets the text to display while loading
  27045. */
  27046. loadingUIText: string;
  27047. /**
  27048. * Gets or sets the color to use for the background
  27049. */
  27050. loadingUIBackgroundColor: string;
  27051. private _resizeLoadingUI;
  27052. }
  27053. }
  27054. declare module "babylonjs/Materials/Textures/videoTexture" {
  27055. import { Observable } from "babylonjs/Misc/observable";
  27056. import { Nullable } from "babylonjs/types";
  27057. import { Scene } from "babylonjs/scene";
  27058. import { Texture } from "babylonjs/Materials/Textures/texture";
  27059. /**
  27060. * Settings for finer control over video usage
  27061. */
  27062. export interface VideoTextureSettings {
  27063. /**
  27064. * Applies `autoplay` to video, if specified
  27065. */
  27066. autoPlay?: boolean;
  27067. /**
  27068. * Applies `loop` to video, if specified
  27069. */
  27070. loop?: boolean;
  27071. /**
  27072. * Automatically updates internal texture from video at every frame in the render loop
  27073. */
  27074. autoUpdateTexture: boolean;
  27075. /**
  27076. * Image src displayed during the video loading or until the user interacts with the video.
  27077. */
  27078. poster?: string;
  27079. }
  27080. /**
  27081. * If you want to display a video in your scene, this is the special texture for that.
  27082. * This special texture works similar to other textures, with the exception of a few parameters.
  27083. * @see https://doc.babylonjs.com/how_to/video_texture
  27084. */
  27085. export class VideoTexture extends Texture {
  27086. /**
  27087. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27088. */
  27089. readonly autoUpdateTexture: boolean;
  27090. /**
  27091. * The video instance used by the texture internally
  27092. */
  27093. readonly video: HTMLVideoElement;
  27094. private _onUserActionRequestedObservable;
  27095. /**
  27096. * Event triggerd when a dom action is required by the user to play the video.
  27097. * This happens due to recent changes in browser policies preventing video to auto start.
  27098. */
  27099. readonly onUserActionRequestedObservable: Observable<Texture>;
  27100. private _generateMipMaps;
  27101. private _engine;
  27102. private _stillImageCaptured;
  27103. private _displayingPosterTexture;
  27104. private _settings;
  27105. private _createInternalTextureOnEvent;
  27106. /**
  27107. * Creates a video texture.
  27108. * If you want to display a video in your scene, this is the special texture for that.
  27109. * This special texture works similar to other textures, with the exception of a few parameters.
  27110. * @see https://doc.babylonjs.com/how_to/video_texture
  27111. * @param name optional name, will detect from video source, if not defined
  27112. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27113. * @param scene is obviously the current scene.
  27114. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27115. * @param invertY is false by default but can be used to invert video on Y axis
  27116. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27117. * @param settings allows finer control over video usage
  27118. */
  27119. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27120. private _getName;
  27121. private _getVideo;
  27122. private _createInternalTexture;
  27123. private reset;
  27124. /**
  27125. * @hidden Internal method to initiate `update`.
  27126. */
  27127. _rebuild(): void;
  27128. /**
  27129. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27130. */
  27131. update(): void;
  27132. /**
  27133. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27134. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27135. */
  27136. updateTexture(isVisible: boolean): void;
  27137. protected _updateInternalTexture: () => void;
  27138. /**
  27139. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27140. * @param url New url.
  27141. */
  27142. updateURL(url: string): void;
  27143. /**
  27144. * Dispose the texture and release its associated resources.
  27145. */
  27146. dispose(): void;
  27147. /**
  27148. * Creates a video texture straight from a stream.
  27149. * @param scene Define the scene the texture should be created in
  27150. * @param stream Define the stream the texture should be created from
  27151. * @returns The created video texture as a promise
  27152. */
  27153. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27154. /**
  27155. * Creates a video texture straight from your WebCam video feed.
  27156. * @param scene Define the scene the texture should be created in
  27157. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27158. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27159. * @returns The created video texture as a promise
  27160. */
  27161. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27162. minWidth: number;
  27163. maxWidth: number;
  27164. minHeight: number;
  27165. maxHeight: number;
  27166. deviceId: string;
  27167. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27168. /**
  27169. * Creates a video texture straight from your WebCam video feed.
  27170. * @param scene Define the scene the texture should be created in
  27171. * @param onReady Define a callback to triggered once the texture will be ready
  27172. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27173. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27174. */
  27175. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27176. minWidth: number;
  27177. maxWidth: number;
  27178. minHeight: number;
  27179. maxHeight: number;
  27180. deviceId: string;
  27181. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27182. }
  27183. }
  27184. declare module "babylonjs/Engines/engine" {
  27185. import { Observable } from "babylonjs/Misc/observable";
  27186. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27187. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27188. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27189. import { Camera } from "babylonjs/Cameras/camera";
  27190. import { Scene } from "babylonjs/scene";
  27191. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27192. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27193. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27195. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27196. import { Material } from "babylonjs/Materials/material";
  27197. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27198. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27200. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27201. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27202. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27203. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27204. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27205. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27206. import { WebRequest } from "babylonjs/Misc/webRequest";
  27207. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27208. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27209. /**
  27210. * Interface for attribute information associated with buffer instanciation
  27211. */
  27212. export class InstancingAttributeInfo {
  27213. /**
  27214. * Index/offset of the attribute in the vertex shader
  27215. */
  27216. index: number;
  27217. /**
  27218. * size of the attribute, 1, 2, 3 or 4
  27219. */
  27220. attributeSize: number;
  27221. /**
  27222. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27223. * default is FLOAT
  27224. */
  27225. attribyteType: number;
  27226. /**
  27227. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27228. */
  27229. normalized: boolean;
  27230. /**
  27231. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27232. */
  27233. offset: number;
  27234. /**
  27235. * Name of the GLSL attribute, for debugging purpose only
  27236. */
  27237. attributeName: string;
  27238. }
  27239. /**
  27240. * Define options used to create a depth texture
  27241. */
  27242. export class DepthTextureCreationOptions {
  27243. /** Specifies whether or not a stencil should be allocated in the texture */
  27244. generateStencil?: boolean;
  27245. /** Specifies whether or not bilinear filtering is enable on the texture */
  27246. bilinearFiltering?: boolean;
  27247. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27248. comparisonFunction?: number;
  27249. /** Specifies if the created texture is a cube texture */
  27250. isCube?: boolean;
  27251. }
  27252. /**
  27253. * Class used to describe the capabilities of the engine relatively to the current browser
  27254. */
  27255. export class EngineCapabilities {
  27256. /** Maximum textures units per fragment shader */
  27257. maxTexturesImageUnits: number;
  27258. /** Maximum texture units per vertex shader */
  27259. maxVertexTextureImageUnits: number;
  27260. /** Maximum textures units in the entire pipeline */
  27261. maxCombinedTexturesImageUnits: number;
  27262. /** Maximum texture size */
  27263. maxTextureSize: number;
  27264. /** Maximum cube texture size */
  27265. maxCubemapTextureSize: number;
  27266. /** Maximum render texture size */
  27267. maxRenderTextureSize: number;
  27268. /** Maximum number of vertex attributes */
  27269. maxVertexAttribs: number;
  27270. /** Maximum number of varyings */
  27271. maxVaryingVectors: number;
  27272. /** Maximum number of uniforms per vertex shader */
  27273. maxVertexUniformVectors: number;
  27274. /** Maximum number of uniforms per fragment shader */
  27275. maxFragmentUniformVectors: number;
  27276. /** Defines if standard derivates (dx/dy) are supported */
  27277. standardDerivatives: boolean;
  27278. /** Defines if s3tc texture compression is supported */
  27279. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27280. /** Defines if pvrtc texture compression is supported */
  27281. pvrtc: any;
  27282. /** Defines if etc1 texture compression is supported */
  27283. etc1: any;
  27284. /** Defines if etc2 texture compression is supported */
  27285. etc2: any;
  27286. /** Defines if astc texture compression is supported */
  27287. astc: any;
  27288. /** Defines if float textures are supported */
  27289. textureFloat: boolean;
  27290. /** Defines if vertex array objects are supported */
  27291. vertexArrayObject: boolean;
  27292. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27293. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27294. /** Gets the maximum level of anisotropy supported */
  27295. maxAnisotropy: number;
  27296. /** Defines if instancing is supported */
  27297. instancedArrays: boolean;
  27298. /** Defines if 32 bits indices are supported */
  27299. uintIndices: boolean;
  27300. /** Defines if high precision shaders are supported */
  27301. highPrecisionShaderSupported: boolean;
  27302. /** Defines if depth reading in the fragment shader is supported */
  27303. fragmentDepthSupported: boolean;
  27304. /** Defines if float texture linear filtering is supported*/
  27305. textureFloatLinearFiltering: boolean;
  27306. /** Defines if rendering to float textures is supported */
  27307. textureFloatRender: boolean;
  27308. /** Defines if half float textures are supported*/
  27309. textureHalfFloat: boolean;
  27310. /** Defines if half float texture linear filtering is supported*/
  27311. textureHalfFloatLinearFiltering: boolean;
  27312. /** Defines if rendering to half float textures is supported */
  27313. textureHalfFloatRender: boolean;
  27314. /** Defines if textureLOD shader command is supported */
  27315. textureLOD: boolean;
  27316. /** Defines if draw buffers extension is supported */
  27317. drawBuffersExtension: boolean;
  27318. /** Defines if depth textures are supported */
  27319. depthTextureExtension: boolean;
  27320. /** Defines if float color buffer are supported */
  27321. colorBufferFloat: boolean;
  27322. /** Gets disjoint timer query extension (null if not supported) */
  27323. timerQuery: EXT_disjoint_timer_query;
  27324. /** Defines if timestamp can be used with timer query */
  27325. canUseTimestampForTimerQuery: boolean;
  27326. /** Function used to let the system compiles shaders in background */
  27327. parallelShaderCompile: {
  27328. COMPLETION_STATUS_KHR: number;
  27329. };
  27330. }
  27331. /** Interface defining initialization parameters for Engine class */
  27332. export interface EngineOptions extends WebGLContextAttributes {
  27333. /**
  27334. * Defines if the engine should no exceed a specified device ratio
  27335. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27336. */
  27337. limitDeviceRatio?: number;
  27338. /**
  27339. * Defines if webvr should be enabled automatically
  27340. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27341. */
  27342. autoEnableWebVR?: boolean;
  27343. /**
  27344. * Defines if webgl2 should be turned off even if supported
  27345. * @see http://doc.babylonjs.com/features/webgl2
  27346. */
  27347. disableWebGL2Support?: boolean;
  27348. /**
  27349. * Defines if webaudio should be initialized as well
  27350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27351. */
  27352. audioEngine?: boolean;
  27353. /**
  27354. * Defines if animations should run using a deterministic lock step
  27355. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27356. */
  27357. deterministicLockstep?: boolean;
  27358. /** Defines the maximum steps to use with deterministic lock step mode */
  27359. lockstepMaxSteps?: number;
  27360. /**
  27361. * Defines that engine should ignore context lost events
  27362. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27363. */
  27364. doNotHandleContextLost?: boolean;
  27365. /**
  27366. * Defines that engine should ignore modifying touch action attribute and style
  27367. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27368. */
  27369. doNotHandleTouchAction?: boolean;
  27370. /**
  27371. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27372. */
  27373. useHighPrecisionFloats?: boolean;
  27374. }
  27375. /**
  27376. * Defines the interface used by display changed events
  27377. */
  27378. export interface IDisplayChangedEventArgs {
  27379. /** Gets the vrDisplay object (if any) */
  27380. vrDisplay: Nullable<any>;
  27381. /** Gets a boolean indicating if webVR is supported */
  27382. vrSupported: boolean;
  27383. }
  27384. /**
  27385. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27386. */
  27387. export class Engine {
  27388. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27389. static ExceptionList: ({
  27390. key: string;
  27391. capture: string;
  27392. captureConstraint: number;
  27393. targets: string[];
  27394. } | {
  27395. key: string;
  27396. capture: null;
  27397. captureConstraint: null;
  27398. targets: string[];
  27399. })[];
  27400. /** Gets the list of created engines */
  27401. static readonly Instances: Engine[];
  27402. /**
  27403. * Gets the latest created engine
  27404. */
  27405. static readonly LastCreatedEngine: Nullable<Engine>;
  27406. /**
  27407. * Gets the latest created scene
  27408. */
  27409. static readonly LastCreatedScene: Nullable<Scene>;
  27410. /**
  27411. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27412. * @param flag defines which part of the materials must be marked as dirty
  27413. * @param predicate defines a predicate used to filter which materials should be affected
  27414. */
  27415. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27416. /**
  27417. * Hidden
  27418. */
  27419. static _TextureLoaders: IInternalTextureLoader[];
  27420. /** Defines that alpha blending is disabled */
  27421. static readonly ALPHA_DISABLE: number;
  27422. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27423. static readonly ALPHA_ADD: number;
  27424. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27425. static readonly ALPHA_COMBINE: number;
  27426. /** Defines that alpha blending to DEST - SRC * DEST */
  27427. static readonly ALPHA_SUBTRACT: number;
  27428. /** Defines that alpha blending to SRC * DEST */
  27429. static readonly ALPHA_MULTIPLY: number;
  27430. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27431. static readonly ALPHA_MAXIMIZED: number;
  27432. /** Defines that alpha blending to SRC + DEST */
  27433. static readonly ALPHA_ONEONE: number;
  27434. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27435. static readonly ALPHA_PREMULTIPLIED: number;
  27436. /**
  27437. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27438. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27439. */
  27440. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27441. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27442. static readonly ALPHA_INTERPOLATE: number;
  27443. /**
  27444. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27445. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27446. */
  27447. static readonly ALPHA_SCREENMODE: number;
  27448. /** Defines that the ressource is not delayed*/
  27449. static readonly DELAYLOADSTATE_NONE: number;
  27450. /** Defines that the ressource was successfully delay loaded */
  27451. static readonly DELAYLOADSTATE_LOADED: number;
  27452. /** Defines that the ressource is currently delay loading */
  27453. static readonly DELAYLOADSTATE_LOADING: number;
  27454. /** Defines that the ressource is delayed and has not started loading */
  27455. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27456. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27457. static readonly NEVER: number;
  27458. /** 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 */
  27459. static readonly ALWAYS: number;
  27460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27461. static readonly LESS: number;
  27462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27463. static readonly EQUAL: number;
  27464. /** 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 */
  27465. static readonly LEQUAL: number;
  27466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27467. static readonly GREATER: number;
  27468. /** 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 */
  27469. static readonly GEQUAL: number;
  27470. /** 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 */
  27471. static readonly NOTEQUAL: number;
  27472. /** Passed to stencilOperation to specify that stencil value must be kept */
  27473. static readonly KEEP: number;
  27474. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27475. static readonly REPLACE: number;
  27476. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27477. static readonly INCR: number;
  27478. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27479. static readonly DECR: number;
  27480. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27481. static readonly INVERT: number;
  27482. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27483. static readonly INCR_WRAP: number;
  27484. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27485. static readonly DECR_WRAP: number;
  27486. /** Texture is not repeating outside of 0..1 UVs */
  27487. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27488. /** Texture is repeating outside of 0..1 UVs */
  27489. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27490. /** Texture is repeating and mirrored */
  27491. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27492. /** ALPHA */
  27493. static readonly TEXTUREFORMAT_ALPHA: number;
  27494. /** LUMINANCE */
  27495. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27496. /** LUMINANCE_ALPHA */
  27497. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27498. /** RGB */
  27499. static readonly TEXTUREFORMAT_RGB: number;
  27500. /** RGBA */
  27501. static readonly TEXTUREFORMAT_RGBA: number;
  27502. /** RED */
  27503. static readonly TEXTUREFORMAT_RED: number;
  27504. /** RED (2nd reference) */
  27505. static readonly TEXTUREFORMAT_R: number;
  27506. /** RG */
  27507. static readonly TEXTUREFORMAT_RG: number;
  27508. /** RED_INTEGER */
  27509. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27510. /** RED_INTEGER (2nd reference) */
  27511. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27512. /** RG_INTEGER */
  27513. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27514. /** RGB_INTEGER */
  27515. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27516. /** RGBA_INTEGER */
  27517. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27518. /** UNSIGNED_BYTE */
  27519. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27520. /** UNSIGNED_BYTE (2nd reference) */
  27521. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27522. /** FLOAT */
  27523. static readonly TEXTURETYPE_FLOAT: number;
  27524. /** HALF_FLOAT */
  27525. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27526. /** BYTE */
  27527. static readonly TEXTURETYPE_BYTE: number;
  27528. /** SHORT */
  27529. static readonly TEXTURETYPE_SHORT: number;
  27530. /** UNSIGNED_SHORT */
  27531. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27532. /** INT */
  27533. static readonly TEXTURETYPE_INT: number;
  27534. /** UNSIGNED_INT */
  27535. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27536. /** UNSIGNED_SHORT_4_4_4_4 */
  27537. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27538. /** UNSIGNED_SHORT_5_5_5_1 */
  27539. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27540. /** UNSIGNED_SHORT_5_6_5 */
  27541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27542. /** UNSIGNED_INT_2_10_10_10_REV */
  27543. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27544. /** UNSIGNED_INT_24_8 */
  27545. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27546. /** UNSIGNED_INT_10F_11F_11F_REV */
  27547. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27548. /** UNSIGNED_INT_5_9_9_9_REV */
  27549. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27550. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27551. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27552. /** nearest is mag = nearest and min = nearest and mip = linear */
  27553. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27554. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27555. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27556. /** Trilinear is mag = linear and min = linear and mip = linear */
  27557. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27558. /** nearest is mag = nearest and min = nearest and mip = linear */
  27559. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27560. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27561. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27562. /** Trilinear is mag = linear and min = linear and mip = linear */
  27563. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27564. /** mag = nearest and min = nearest and mip = nearest */
  27565. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27566. /** mag = nearest and min = linear and mip = nearest */
  27567. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27568. /** mag = nearest and min = linear and mip = linear */
  27569. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27570. /** mag = nearest and min = linear and mip = none */
  27571. static readonly TEXTURE_NEAREST_LINEAR: number;
  27572. /** mag = nearest and min = nearest and mip = none */
  27573. static readonly TEXTURE_NEAREST_NEAREST: number;
  27574. /** mag = linear and min = nearest and mip = nearest */
  27575. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27576. /** mag = linear and min = nearest and mip = linear */
  27577. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27578. /** mag = linear and min = linear and mip = none */
  27579. static readonly TEXTURE_LINEAR_LINEAR: number;
  27580. /** mag = linear and min = nearest and mip = none */
  27581. static readonly TEXTURE_LINEAR_NEAREST: number;
  27582. /** Explicit coordinates mode */
  27583. static readonly TEXTURE_EXPLICIT_MODE: number;
  27584. /** Spherical coordinates mode */
  27585. static readonly TEXTURE_SPHERICAL_MODE: number;
  27586. /** Planar coordinates mode */
  27587. static readonly TEXTURE_PLANAR_MODE: number;
  27588. /** Cubic coordinates mode */
  27589. static readonly TEXTURE_CUBIC_MODE: number;
  27590. /** Projection coordinates mode */
  27591. static readonly TEXTURE_PROJECTION_MODE: number;
  27592. /** Skybox coordinates mode */
  27593. static readonly TEXTURE_SKYBOX_MODE: number;
  27594. /** Inverse Cubic coordinates mode */
  27595. static readonly TEXTURE_INVCUBIC_MODE: number;
  27596. /** Equirectangular coordinates mode */
  27597. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27598. /** Equirectangular Fixed coordinates mode */
  27599. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27600. /** Equirectangular Fixed Mirrored coordinates mode */
  27601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27602. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27603. static readonly SCALEMODE_FLOOR: number;
  27604. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27605. static readonly SCALEMODE_NEAREST: number;
  27606. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27607. static readonly SCALEMODE_CEILING: number;
  27608. /**
  27609. * Returns the current npm package of the sdk
  27610. */
  27611. static readonly NpmPackage: string;
  27612. /**
  27613. * Returns the current version of the framework
  27614. */
  27615. static readonly Version: string;
  27616. /**
  27617. * Returns a string describing the current engine
  27618. */
  27619. readonly description: string;
  27620. /**
  27621. * Gets or sets the epsilon value used by collision engine
  27622. */
  27623. static CollisionsEpsilon: number;
  27624. /**
  27625. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27626. */
  27627. static ShadersRepository: string;
  27628. /**
  27629. * Method called to create the default loading screen.
  27630. * This can be overriden in your own app.
  27631. * @param canvas The rendering canvas element
  27632. * @returns The loading screen
  27633. */
  27634. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27635. /**
  27636. * Method called to create the default rescale post process on each engine.
  27637. */
  27638. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27639. /**
  27640. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27641. */
  27642. forcePOTTextures: boolean;
  27643. /**
  27644. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27645. */
  27646. isFullscreen: boolean;
  27647. /**
  27648. * Gets a boolean indicating if the pointer is currently locked
  27649. */
  27650. isPointerLock: boolean;
  27651. /**
  27652. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27653. */
  27654. cullBackFaces: boolean;
  27655. /**
  27656. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27657. */
  27658. renderEvenInBackground: boolean;
  27659. /**
  27660. * Gets or sets a boolean indicating that cache can be kept between frames
  27661. */
  27662. preventCacheWipeBetweenFrames: boolean;
  27663. /**
  27664. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27665. **/
  27666. enableOfflineSupport: boolean;
  27667. /**
  27668. * 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)
  27669. **/
  27670. disableManifestCheck: boolean;
  27671. /**
  27672. * Gets the list of created scenes
  27673. */
  27674. scenes: Scene[];
  27675. /**
  27676. * Event raised when a new scene is created
  27677. */
  27678. onNewSceneAddedObservable: Observable<Scene>;
  27679. /**
  27680. * Gets the list of created postprocesses
  27681. */
  27682. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27683. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27684. validateShaderPrograms: boolean;
  27685. /**
  27686. * Observable event triggered each time the rendering canvas is resized
  27687. */
  27688. onResizeObservable: Observable<Engine>;
  27689. /**
  27690. * Observable event triggered each time the canvas loses focus
  27691. */
  27692. onCanvasBlurObservable: Observable<Engine>;
  27693. /**
  27694. * Observable event triggered each time the canvas gains focus
  27695. */
  27696. onCanvasFocusObservable: Observable<Engine>;
  27697. /**
  27698. * Observable event triggered each time the canvas receives pointerout event
  27699. */
  27700. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27701. /**
  27702. * Observable event triggered before each texture is initialized
  27703. */
  27704. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27705. private _vrDisplay;
  27706. private _vrSupported;
  27707. private _oldSize;
  27708. private _oldHardwareScaleFactor;
  27709. private _vrExclusivePointerMode;
  27710. private _webVRInitPromise;
  27711. /**
  27712. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27713. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27714. */
  27715. readonly isInVRExclusivePointerMode: boolean;
  27716. /**
  27717. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27718. */
  27719. disableUniformBuffers: boolean;
  27720. /** @hidden */
  27721. _uniformBuffers: UniformBuffer[];
  27722. /**
  27723. * Gets a boolean indicating that the engine supports uniform buffers
  27724. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27725. */
  27726. readonly supportsUniformBuffers: boolean;
  27727. /**
  27728. * Observable raised when the engine begins a new frame
  27729. */
  27730. onBeginFrameObservable: Observable<Engine>;
  27731. /**
  27732. * If set, will be used to request the next animation frame for the render loop
  27733. */
  27734. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27735. /**
  27736. * Observable raised when the engine ends the current frame
  27737. */
  27738. onEndFrameObservable: Observable<Engine>;
  27739. /**
  27740. * Observable raised when the engine is about to compile a shader
  27741. */
  27742. onBeforeShaderCompilationObservable: Observable<Engine>;
  27743. /**
  27744. * Observable raised when the engine has jsut compiled a shader
  27745. */
  27746. onAfterShaderCompilationObservable: Observable<Engine>;
  27747. /** @hidden */
  27748. _gl: WebGLRenderingContext;
  27749. private _renderingCanvas;
  27750. private _windowIsBackground;
  27751. private _webGLVersion;
  27752. protected _highPrecisionShadersAllowed: boolean;
  27753. /** @hidden */
  27754. readonly _shouldUseHighPrecisionShader: boolean;
  27755. /**
  27756. * Gets a boolean indicating that only power of 2 textures are supported
  27757. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27758. */
  27759. readonly needPOTTextures: boolean;
  27760. /** @hidden */
  27761. _badOS: boolean;
  27762. /** @hidden */
  27763. _badDesktopOS: boolean;
  27764. /**
  27765. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27766. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27767. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27768. */
  27769. disableTextureBindingOptimization: boolean;
  27770. /**
  27771. * Gets the audio engine
  27772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27773. * @ignorenaming
  27774. */
  27775. static audioEngine: IAudioEngine;
  27776. /**
  27777. * Default AudioEngine factory responsible of creating the Audio Engine.
  27778. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27779. */
  27780. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27781. /**
  27782. * Default offline support factory responsible of creating a tool used to store data locally.
  27783. * By default, this will create a Database object if the workload has been embedded.
  27784. */
  27785. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27786. private _onFocus;
  27787. private _onBlur;
  27788. private _onCanvasPointerOut;
  27789. private _onCanvasBlur;
  27790. private _onCanvasFocus;
  27791. private _onFullscreenChange;
  27792. private _onPointerLockChange;
  27793. private _onVRDisplayPointerRestricted;
  27794. private _onVRDisplayPointerUnrestricted;
  27795. private _onVrDisplayConnect;
  27796. private _onVrDisplayDisconnect;
  27797. private _onVrDisplayPresentChange;
  27798. /**
  27799. * Observable signaled when VR display mode changes
  27800. */
  27801. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27802. /**
  27803. * Observable signaled when VR request present is complete
  27804. */
  27805. onVRRequestPresentComplete: Observable<boolean>;
  27806. /**
  27807. * Observable signaled when VR request present starts
  27808. */
  27809. onVRRequestPresentStart: Observable<Engine>;
  27810. private _hardwareScalingLevel;
  27811. /** @hidden */
  27812. protected _caps: EngineCapabilities;
  27813. private _pointerLockRequested;
  27814. private _isStencilEnable;
  27815. private _colorWrite;
  27816. private _loadingScreen;
  27817. /** @hidden */
  27818. _drawCalls: PerfCounter;
  27819. /** @hidden */
  27820. _textureCollisions: PerfCounter;
  27821. private _glVersion;
  27822. private _glRenderer;
  27823. private _glVendor;
  27824. private _videoTextureSupported;
  27825. private _renderingQueueLaunched;
  27826. private _activeRenderLoops;
  27827. private _deterministicLockstep;
  27828. private _lockstepMaxSteps;
  27829. /**
  27830. * Observable signaled when a context lost event is raised
  27831. */
  27832. onContextLostObservable: Observable<Engine>;
  27833. /**
  27834. * Observable signaled when a context restored event is raised
  27835. */
  27836. onContextRestoredObservable: Observable<Engine>;
  27837. private _onContextLost;
  27838. private _onContextRestored;
  27839. private _contextWasLost;
  27840. private _doNotHandleContextLost;
  27841. /**
  27842. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27843. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27844. */
  27845. doNotHandleContextLost: boolean;
  27846. private _performanceMonitor;
  27847. private _fps;
  27848. private _deltaTime;
  27849. /**
  27850. * Turn this value on if you want to pause FPS computation when in background
  27851. */
  27852. disablePerformanceMonitorInBackground: boolean;
  27853. /**
  27854. * Gets the performance monitor attached to this engine
  27855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27856. */
  27857. readonly performanceMonitor: PerformanceMonitor;
  27858. /** @hidden */
  27859. protected _depthCullingState: _DepthCullingState;
  27860. /** @hidden */
  27861. protected _stencilState: _StencilState;
  27862. /** @hidden */
  27863. protected _alphaState: _AlphaState;
  27864. /** @hidden */
  27865. protected _alphaMode: number;
  27866. protected _internalTexturesCache: InternalTexture[];
  27867. /** @hidden */
  27868. protected _activeChannel: number;
  27869. private _currentTextureChannel;
  27870. /** @hidden */
  27871. protected _boundTexturesCache: {
  27872. [key: string]: Nullable<InternalTexture>;
  27873. };
  27874. /** @hidden */
  27875. protected _currentEffect: Nullable<Effect>;
  27876. /** @hidden */
  27877. protected _currentProgram: Nullable<WebGLProgram>;
  27878. private _compiledEffects;
  27879. private _vertexAttribArraysEnabled;
  27880. /** @hidden */
  27881. protected _cachedViewport: Nullable<Viewport>;
  27882. private _cachedVertexArrayObject;
  27883. /** @hidden */
  27884. protected _cachedVertexBuffers: any;
  27885. /** @hidden */
  27886. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27887. /** @hidden */
  27888. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27889. /** @hidden */
  27890. protected _currentRenderTarget: Nullable<InternalTexture>;
  27891. private _uintIndicesCurrentlySet;
  27892. private _currentBoundBuffer;
  27893. /** @hidden */
  27894. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27895. private _currentBufferPointers;
  27896. private _currentInstanceLocations;
  27897. private _currentInstanceBuffers;
  27898. private _textureUnits;
  27899. private _firstBoundInternalTextureTracker;
  27900. private _lastBoundInternalTextureTracker;
  27901. private _workingCanvas;
  27902. private _workingContext;
  27903. private _rescalePostProcess;
  27904. private _dummyFramebuffer;
  27905. private _externalData;
  27906. private _bindedRenderFunction;
  27907. private _vaoRecordInProgress;
  27908. private _mustWipeVertexAttributes;
  27909. private _emptyTexture;
  27910. private _emptyCubeTexture;
  27911. private _emptyTexture3D;
  27912. /** @hidden */
  27913. _frameHandler: number;
  27914. private _nextFreeTextureSlots;
  27915. private _maxSimultaneousTextures;
  27916. private _activeRequests;
  27917. private _texturesSupported;
  27918. private _textureFormatInUse;
  27919. /**
  27920. * Gets the list of texture formats supported
  27921. */
  27922. readonly texturesSupported: Array<string>;
  27923. /**
  27924. * Gets the list of texture formats in use
  27925. */
  27926. readonly textureFormatInUse: Nullable<string>;
  27927. /**
  27928. * Gets the current viewport
  27929. */
  27930. readonly currentViewport: Nullable<Viewport>;
  27931. /**
  27932. * Gets the default empty texture
  27933. */
  27934. readonly emptyTexture: InternalTexture;
  27935. /**
  27936. * Gets the default empty 3D texture
  27937. */
  27938. readonly emptyTexture3D: InternalTexture;
  27939. /**
  27940. * Gets the default empty cube texture
  27941. */
  27942. readonly emptyCubeTexture: InternalTexture;
  27943. /**
  27944. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27945. */
  27946. readonly premultipliedAlpha: boolean;
  27947. /**
  27948. * Creates a new engine
  27949. * @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
  27950. * @param antialias defines enable antialiasing (default: false)
  27951. * @param options defines further options to be sent to the getContext() function
  27952. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27953. */
  27954. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27955. private _disableTouchAction;
  27956. private _rebuildInternalTextures;
  27957. private _rebuildEffects;
  27958. /**
  27959. * Gets a boolean indicating if all created effects are ready
  27960. * @returns true if all effects are ready
  27961. */
  27962. areAllEffectsReady(): boolean;
  27963. private _rebuildBuffers;
  27964. private _initGLContext;
  27965. /**
  27966. * Gets version of the current webGL context
  27967. */
  27968. readonly webGLVersion: number;
  27969. /**
  27970. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27971. */
  27972. readonly isStencilEnable: boolean;
  27973. private _prepareWorkingCanvas;
  27974. /**
  27975. * Reset the texture cache to empty state
  27976. */
  27977. resetTextureCache(): void;
  27978. /**
  27979. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27980. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27981. * @returns true if engine is in deterministic lock step mode
  27982. */
  27983. isDeterministicLockStep(): boolean;
  27984. /**
  27985. * Gets the max steps when engine is running in deterministic lock step
  27986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27987. * @returns the max steps
  27988. */
  27989. getLockstepMaxSteps(): number;
  27990. /**
  27991. * Gets an object containing information about the current webGL context
  27992. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27993. */
  27994. getGlInfo(): {
  27995. vendor: string;
  27996. renderer: string;
  27997. version: string;
  27998. };
  27999. /**
  28000. * Gets current aspect ratio
  28001. * @param camera defines the camera to use to get the aspect ratio
  28002. * @param useScreen defines if screen size must be used (or the current render target if any)
  28003. * @returns a number defining the aspect ratio
  28004. */
  28005. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28006. /**
  28007. * Gets current screen aspect ratio
  28008. * @returns a number defining the aspect ratio
  28009. */
  28010. getScreenAspectRatio(): number;
  28011. /**
  28012. * Gets the current render width
  28013. * @param useScreen defines if screen size must be used (or the current render target if any)
  28014. * @returns a number defining the current render width
  28015. */
  28016. getRenderWidth(useScreen?: boolean): number;
  28017. /**
  28018. * Gets the current render height
  28019. * @param useScreen defines if screen size must be used (or the current render target if any)
  28020. * @returns a number defining the current render height
  28021. */
  28022. getRenderHeight(useScreen?: boolean): number;
  28023. /**
  28024. * Gets the HTML canvas attached with the current webGL context
  28025. * @returns a HTML canvas
  28026. */
  28027. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28028. /**
  28029. * Gets the client rect of the HTML canvas attached with the current webGL context
  28030. * @returns a client rectanglee
  28031. */
  28032. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28033. /**
  28034. * Defines the hardware scaling level.
  28035. * By default the hardware scaling level is computed from the window device ratio.
  28036. * 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.
  28037. * @param level defines the level to use
  28038. */
  28039. setHardwareScalingLevel(level: number): void;
  28040. /**
  28041. * Gets the current hardware scaling level.
  28042. * By default the hardware scaling level is computed from the window device ratio.
  28043. * 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.
  28044. * @returns a number indicating the current hardware scaling level
  28045. */
  28046. getHardwareScalingLevel(): number;
  28047. /**
  28048. * Gets the list of loaded textures
  28049. * @returns an array containing all loaded textures
  28050. */
  28051. getLoadedTexturesCache(): InternalTexture[];
  28052. /**
  28053. * Gets the object containing all engine capabilities
  28054. * @returns the EngineCapabilities object
  28055. */
  28056. getCaps(): EngineCapabilities;
  28057. /**
  28058. * Gets the current depth function
  28059. * @returns a number defining the depth function
  28060. */
  28061. getDepthFunction(): Nullable<number>;
  28062. /**
  28063. * Sets the current depth function
  28064. * @param depthFunc defines the function to use
  28065. */
  28066. setDepthFunction(depthFunc: number): void;
  28067. /**
  28068. * Sets the current depth function to GREATER
  28069. */
  28070. setDepthFunctionToGreater(): void;
  28071. /**
  28072. * Sets the current depth function to GEQUAL
  28073. */
  28074. setDepthFunctionToGreaterOrEqual(): void;
  28075. /**
  28076. * Sets the current depth function to LESS
  28077. */
  28078. setDepthFunctionToLess(): void;
  28079. private _cachedStencilBuffer;
  28080. private _cachedStencilFunction;
  28081. private _cachedStencilMask;
  28082. private _cachedStencilOperationPass;
  28083. private _cachedStencilOperationFail;
  28084. private _cachedStencilOperationDepthFail;
  28085. private _cachedStencilReference;
  28086. /**
  28087. * Caches the the state of the stencil buffer
  28088. */
  28089. cacheStencilState(): void;
  28090. /**
  28091. * Restores the state of the stencil buffer
  28092. */
  28093. restoreStencilState(): void;
  28094. /**
  28095. * Sets the current depth function to LEQUAL
  28096. */
  28097. setDepthFunctionToLessOrEqual(): void;
  28098. /**
  28099. * Gets a boolean indicating if stencil buffer is enabled
  28100. * @returns the current stencil buffer state
  28101. */
  28102. getStencilBuffer(): boolean;
  28103. /**
  28104. * Enable or disable the stencil buffer
  28105. * @param enable defines if the stencil buffer must be enabled or disabled
  28106. */
  28107. setStencilBuffer(enable: boolean): void;
  28108. /**
  28109. * Gets the current stencil mask
  28110. * @returns a number defining the new stencil mask to use
  28111. */
  28112. getStencilMask(): number;
  28113. /**
  28114. * Sets the current stencil mask
  28115. * @param mask defines the new stencil mask to use
  28116. */
  28117. setStencilMask(mask: number): void;
  28118. /**
  28119. * Gets the current stencil function
  28120. * @returns a number defining the stencil function to use
  28121. */
  28122. getStencilFunction(): number;
  28123. /**
  28124. * Gets the current stencil reference value
  28125. * @returns a number defining the stencil reference value to use
  28126. */
  28127. getStencilFunctionReference(): number;
  28128. /**
  28129. * Gets the current stencil mask
  28130. * @returns a number defining the stencil mask to use
  28131. */
  28132. getStencilFunctionMask(): number;
  28133. /**
  28134. * Sets the current stencil function
  28135. * @param stencilFunc defines the new stencil function to use
  28136. */
  28137. setStencilFunction(stencilFunc: number): void;
  28138. /**
  28139. * Sets the current stencil reference
  28140. * @param reference defines the new stencil reference to use
  28141. */
  28142. setStencilFunctionReference(reference: number): void;
  28143. /**
  28144. * Sets the current stencil mask
  28145. * @param mask defines the new stencil mask to use
  28146. */
  28147. setStencilFunctionMask(mask: number): void;
  28148. /**
  28149. * Gets the current stencil operation when stencil fails
  28150. * @returns a number defining stencil operation to use when stencil fails
  28151. */
  28152. getStencilOperationFail(): number;
  28153. /**
  28154. * Gets the current stencil operation when depth fails
  28155. * @returns a number defining stencil operation to use when depth fails
  28156. */
  28157. getStencilOperationDepthFail(): number;
  28158. /**
  28159. * Gets the current stencil operation when stencil passes
  28160. * @returns a number defining stencil operation to use when stencil passes
  28161. */
  28162. getStencilOperationPass(): number;
  28163. /**
  28164. * Sets the stencil operation to use when stencil fails
  28165. * @param operation defines the stencil operation to use when stencil fails
  28166. */
  28167. setStencilOperationFail(operation: number): void;
  28168. /**
  28169. * Sets the stencil operation to use when depth fails
  28170. * @param operation defines the stencil operation to use when depth fails
  28171. */
  28172. setStencilOperationDepthFail(operation: number): void;
  28173. /**
  28174. * Sets the stencil operation to use when stencil passes
  28175. * @param operation defines the stencil operation to use when stencil passes
  28176. */
  28177. setStencilOperationPass(operation: number): void;
  28178. /**
  28179. * Sets a boolean indicating if the dithering state is enabled or disabled
  28180. * @param value defines the dithering state
  28181. */
  28182. setDitheringState(value: boolean): void;
  28183. /**
  28184. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28185. * @param value defines the rasterizer state
  28186. */
  28187. setRasterizerState(value: boolean): void;
  28188. /**
  28189. * stop executing a render loop function and remove it from the execution array
  28190. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28191. */
  28192. stopRenderLoop(renderFunction?: () => void): void;
  28193. /** @hidden */
  28194. _renderLoop(): void;
  28195. /**
  28196. * Register and execute a render loop. The engine can have more than one render function
  28197. * @param renderFunction defines the function to continuously execute
  28198. */
  28199. runRenderLoop(renderFunction: () => void): void;
  28200. /**
  28201. * Toggle full screen mode
  28202. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28203. */
  28204. switchFullscreen(requestPointerLock: boolean): void;
  28205. /**
  28206. * Enters full screen mode
  28207. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28208. */
  28209. enterFullscreen(requestPointerLock: boolean): void;
  28210. /**
  28211. * Exits full screen mode
  28212. */
  28213. exitFullscreen(): void;
  28214. /**
  28215. * Clear the current render buffer or the current render target (if any is set up)
  28216. * @param color defines the color to use
  28217. * @param backBuffer defines if the back buffer must be cleared
  28218. * @param depth defines if the depth buffer must be cleared
  28219. * @param stencil defines if the stencil buffer must be cleared
  28220. */
  28221. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28222. /**
  28223. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28224. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28225. * @param y defines the y-coordinate of the corner of the clear rectangle
  28226. * @param width defines the width of the clear rectangle
  28227. * @param height defines the height of the clear rectangle
  28228. * @param clearColor defines the clear color
  28229. */
  28230. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28231. /**
  28232. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28233. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28234. * @param y defines the y-coordinate of the corner of the clear rectangle
  28235. * @param width defines the width of the clear rectangle
  28236. * @param height defines the height of the clear rectangle
  28237. */
  28238. enableScissor(x: number, y: number, width: number, height: number): void;
  28239. /**
  28240. * Disable previously set scissor test rectangle
  28241. */
  28242. disableScissor(): void;
  28243. private _viewportCached;
  28244. /** @hidden */
  28245. _viewport(x: number, y: number, width: number, height: number): void;
  28246. /**
  28247. * Set the WebGL's viewport
  28248. * @param viewport defines the viewport element to be used
  28249. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28250. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28251. */
  28252. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28253. /**
  28254. * Directly set the WebGL Viewport
  28255. * @param x defines the x coordinate of the viewport (in screen space)
  28256. * @param y defines the y coordinate of the viewport (in screen space)
  28257. * @param width defines the width of the viewport (in screen space)
  28258. * @param height defines the height of the viewport (in screen space)
  28259. * @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
  28260. */
  28261. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28262. /**
  28263. * Begin a new frame
  28264. */
  28265. beginFrame(): void;
  28266. /**
  28267. * Enf the current frame
  28268. */
  28269. endFrame(): void;
  28270. /**
  28271. * Resize the view according to the canvas' size
  28272. */
  28273. resize(): void;
  28274. /**
  28275. * Force a specific size of the canvas
  28276. * @param width defines the new canvas' width
  28277. * @param height defines the new canvas' height
  28278. */
  28279. setSize(width: number, height: number): void;
  28280. /**
  28281. * Gets a boolean indicating if a webVR device was detected
  28282. * @returns true if a webVR device was detected
  28283. */
  28284. isVRDevicePresent(): boolean;
  28285. /**
  28286. * Gets the current webVR device
  28287. * @returns the current webVR device (or null)
  28288. */
  28289. getVRDevice(): any;
  28290. /**
  28291. * Initializes a webVR display and starts listening to display change events
  28292. * The onVRDisplayChangedObservable will be notified upon these changes
  28293. * @returns The onVRDisplayChangedObservable
  28294. */
  28295. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28296. /**
  28297. * Initializes a webVR display and starts listening to display change events
  28298. * The onVRDisplayChangedObservable will be notified upon these changes
  28299. * @returns A promise containing a VRDisplay and if vr is supported
  28300. */
  28301. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28302. /**
  28303. * Call this function to switch to webVR mode
  28304. * Will do nothing if webVR is not supported or if there is no webVR device
  28305. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28306. */
  28307. enableVR(): void;
  28308. /**
  28309. * Call this function to leave webVR mode
  28310. * Will do nothing if webVR is not supported or if there is no webVR device
  28311. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28312. */
  28313. disableVR(): void;
  28314. private _onVRFullScreenTriggered;
  28315. private _getVRDisplaysAsync;
  28316. /**
  28317. * Binds the frame buffer to the specified texture.
  28318. * @param texture The texture to render to or null for the default canvas
  28319. * @param faceIndex The face of the texture to render to in case of cube texture
  28320. * @param requiredWidth The width of the target to render to
  28321. * @param requiredHeight The height of the target to render to
  28322. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28323. * @param depthStencilTexture The depth stencil texture to use to render
  28324. * @param lodLevel defines le lod level to bind to the frame buffer
  28325. */
  28326. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28327. private bindUnboundFramebuffer;
  28328. /**
  28329. * Unbind the current render target texture from the webGL context
  28330. * @param texture defines the render target texture to unbind
  28331. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28332. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28333. */
  28334. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28335. /**
  28336. * Unbind a list of render target textures from the webGL context
  28337. * This is used only when drawBuffer extension or webGL2 are active
  28338. * @param textures defines the render target textures to unbind
  28339. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28340. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28341. */
  28342. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28343. /**
  28344. * Force the mipmap generation for the given render target texture
  28345. * @param texture defines the render target texture to use
  28346. */
  28347. generateMipMapsForCubemap(texture: InternalTexture): void;
  28348. /**
  28349. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28350. */
  28351. flushFramebuffer(): void;
  28352. /**
  28353. * Unbind the current render target and bind the default framebuffer
  28354. */
  28355. restoreDefaultFramebuffer(): void;
  28356. /**
  28357. * Create an uniform buffer
  28358. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28359. * @param elements defines the content of the uniform buffer
  28360. * @returns the webGL uniform buffer
  28361. */
  28362. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28363. /**
  28364. * Create a dynamic uniform buffer
  28365. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28366. * @param elements defines the content of the uniform buffer
  28367. * @returns the webGL uniform buffer
  28368. */
  28369. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28370. /**
  28371. * Update an existing uniform buffer
  28372. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28373. * @param uniformBuffer defines the target uniform buffer
  28374. * @param elements defines the content to update
  28375. * @param offset defines the offset in the uniform buffer where update should start
  28376. * @param count defines the size of the data to update
  28377. */
  28378. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28379. private _resetVertexBufferBinding;
  28380. /**
  28381. * Creates a vertex buffer
  28382. * @param data the data for the vertex buffer
  28383. * @returns the new WebGL static buffer
  28384. */
  28385. createVertexBuffer(data: DataArray): WebGLBuffer;
  28386. /**
  28387. * Creates a dynamic vertex buffer
  28388. * @param data the data for the dynamic vertex buffer
  28389. * @returns the new WebGL dynamic buffer
  28390. */
  28391. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28392. /**
  28393. * Update a dynamic index buffer
  28394. * @param indexBuffer defines the target index buffer
  28395. * @param indices defines the data to update
  28396. * @param offset defines the offset in the target index buffer where update should start
  28397. */
  28398. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28399. /**
  28400. * Updates a dynamic vertex buffer.
  28401. * @param vertexBuffer the vertex buffer to update
  28402. * @param data the data used to update the vertex buffer
  28403. * @param byteOffset the byte offset of the data
  28404. * @param byteLength the byte length of the data
  28405. */
  28406. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28407. private _resetIndexBufferBinding;
  28408. /**
  28409. * Creates a new index buffer
  28410. * @param indices defines the content of the index buffer
  28411. * @param updatable defines if the index buffer must be updatable
  28412. * @returns a new webGL buffer
  28413. */
  28414. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28415. /**
  28416. * Bind a webGL buffer to the webGL context
  28417. * @param buffer defines the buffer to bind
  28418. */
  28419. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28420. /**
  28421. * Bind an uniform buffer to the current webGL context
  28422. * @param buffer defines the buffer to bind
  28423. */
  28424. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28425. /**
  28426. * Bind a buffer to the current webGL context at a given location
  28427. * @param buffer defines the buffer to bind
  28428. * @param location defines the index where to bind the buffer
  28429. */
  28430. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28431. /**
  28432. * Bind a specific block at a given index in a specific shader program
  28433. * @param shaderProgram defines the shader program
  28434. * @param blockName defines the block name
  28435. * @param index defines the index where to bind the block
  28436. */
  28437. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28438. private bindIndexBuffer;
  28439. private bindBuffer;
  28440. /**
  28441. * update the bound buffer with the given data
  28442. * @param data defines the data to update
  28443. */
  28444. updateArrayBuffer(data: Float32Array): void;
  28445. private _vertexAttribPointer;
  28446. private _bindIndexBufferWithCache;
  28447. private _bindVertexBuffersAttributes;
  28448. /**
  28449. * Records a vertex array object
  28450. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28451. * @param vertexBuffers defines the list of vertex buffers to store
  28452. * @param indexBuffer defines the index buffer to store
  28453. * @param effect defines the effect to store
  28454. * @returns the new vertex array object
  28455. */
  28456. recordVertexArrayObject(vertexBuffers: {
  28457. [key: string]: VertexBuffer;
  28458. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28459. /**
  28460. * Bind a specific vertex array object
  28461. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28462. * @param vertexArrayObject defines the vertex array object to bind
  28463. * @param indexBuffer defines the index buffer to bind
  28464. */
  28465. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28466. /**
  28467. * Bind webGl buffers directly to the webGL context
  28468. * @param vertexBuffer defines the vertex buffer to bind
  28469. * @param indexBuffer defines the index buffer to bind
  28470. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28471. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28472. * @param effect defines the effect associated with the vertex buffer
  28473. */
  28474. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28475. private _unbindVertexArrayObject;
  28476. /**
  28477. * Bind a list of vertex buffers to the webGL context
  28478. * @param vertexBuffers defines the list of vertex buffers to bind
  28479. * @param indexBuffer defines the index buffer to bind
  28480. * @param effect defines the effect associated with the vertex buffers
  28481. */
  28482. bindBuffers(vertexBuffers: {
  28483. [key: string]: Nullable<VertexBuffer>;
  28484. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28485. /**
  28486. * Unbind all instance attributes
  28487. */
  28488. unbindInstanceAttributes(): void;
  28489. /**
  28490. * Release and free the memory of a vertex array object
  28491. * @param vao defines the vertex array object to delete
  28492. */
  28493. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28494. /** @hidden */
  28495. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28496. /**
  28497. * Creates a webGL buffer to use with instanciation
  28498. * @param capacity defines the size of the buffer
  28499. * @returns the webGL buffer
  28500. */
  28501. createInstancesBuffer(capacity: number): WebGLBuffer;
  28502. /**
  28503. * Delete a webGL buffer used with instanciation
  28504. * @param buffer defines the webGL buffer to delete
  28505. */
  28506. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28507. /**
  28508. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28509. * @param instancesBuffer defines the webGL buffer to update and bind
  28510. * @param data defines the data to store in the buffer
  28511. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28512. */
  28513. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28514. /**
  28515. * Apply all cached states (depth, culling, stencil and alpha)
  28516. */
  28517. applyStates(): void;
  28518. /**
  28519. * Send a draw order
  28520. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28521. * @param indexStart defines the starting index
  28522. * @param indexCount defines the number of index to draw
  28523. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28524. */
  28525. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28526. /**
  28527. * Draw a list of points
  28528. * @param verticesStart defines the index of first vertex to draw
  28529. * @param verticesCount defines the count of vertices to draw
  28530. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28531. */
  28532. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28533. /**
  28534. * Draw a list of unindexed primitives
  28535. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28536. * @param verticesStart defines the index of first vertex to draw
  28537. * @param verticesCount defines the count of vertices to draw
  28538. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28539. */
  28540. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28541. /**
  28542. * Draw a list of indexed primitives
  28543. * @param fillMode defines the primitive to use
  28544. * @param indexStart defines the starting index
  28545. * @param indexCount defines the number of index to draw
  28546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28547. */
  28548. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28549. /**
  28550. * Draw a list of unindexed primitives
  28551. * @param fillMode defines the primitive to use
  28552. * @param verticesStart defines the index of first vertex to draw
  28553. * @param verticesCount defines the count of vertices to draw
  28554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28555. */
  28556. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28557. private _drawMode;
  28558. /** @hidden */
  28559. _releaseEffect(effect: Effect): void;
  28560. /** @hidden */
  28561. _deleteProgram(program: WebGLProgram): void;
  28562. /**
  28563. * Create a new effect (used to store vertex/fragment shaders)
  28564. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28565. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28566. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28567. * @param samplers defines an array of string used to represent textures
  28568. * @param defines defines the string containing the defines to use to compile the shaders
  28569. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28570. * @param onCompiled defines a function to call when the effect creation is successful
  28571. * @param onError defines a function to call when the effect creation has failed
  28572. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28573. * @returns the new Effect
  28574. */
  28575. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  28576. private _compileShader;
  28577. private _compileRawShader;
  28578. /**
  28579. * Directly creates a webGL program
  28580. * @param vertexCode defines the vertex shader code to use
  28581. * @param fragmentCode defines the fragment shader code to use
  28582. * @param context defines the webGL context to use (if not set, the current one will be used)
  28583. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28584. * @returns the new webGL program
  28585. */
  28586. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28587. /**
  28588. * Creates a webGL program
  28589. * @param vertexCode defines the vertex shader code to use
  28590. * @param fragmentCode defines the fragment shader code to use
  28591. * @param defines defines the string containing the defines to use to compile the shaders
  28592. * @param context defines the webGL context to use (if not set, the current one will be used)
  28593. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28594. * @returns the new webGL program
  28595. */
  28596. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28597. private _createShaderProgram;
  28598. private _finalizeProgram;
  28599. /** @hidden */
  28600. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28601. /** @hidden */
  28602. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28603. /**
  28604. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28605. * @param shaderProgram defines the webGL program to use
  28606. * @param uniformsNames defines the list of uniform names
  28607. * @returns an array of webGL uniform locations
  28608. */
  28609. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28610. /**
  28611. * Gets the lsit of active attributes for a given webGL program
  28612. * @param shaderProgram defines the webGL program to use
  28613. * @param attributesNames defines the list of attribute names to get
  28614. * @returns an array of indices indicating the offset of each attribute
  28615. */
  28616. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28617. /**
  28618. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28619. * @param effect defines the effect to activate
  28620. */
  28621. enableEffect(effect: Nullable<Effect>): void;
  28622. /**
  28623. * Set the value of an uniform to an array of int32
  28624. * @param uniform defines the webGL uniform location where to store the value
  28625. * @param array defines the array of int32 to store
  28626. */
  28627. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28628. /**
  28629. * Set the value of an uniform to an array of int32 (stored as vec2)
  28630. * @param uniform defines the webGL uniform location where to store the value
  28631. * @param array defines the array of int32 to store
  28632. */
  28633. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28634. /**
  28635. * Set the value of an uniform to an array of int32 (stored as vec3)
  28636. * @param uniform defines the webGL uniform location where to store the value
  28637. * @param array defines the array of int32 to store
  28638. */
  28639. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28640. /**
  28641. * Set the value of an uniform to an array of int32 (stored as vec4)
  28642. * @param uniform defines the webGL uniform location where to store the value
  28643. * @param array defines the array of int32 to store
  28644. */
  28645. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28646. /**
  28647. * Set the value of an uniform to an array of float32
  28648. * @param uniform defines the webGL uniform location where to store the value
  28649. * @param array defines the array of float32 to store
  28650. */
  28651. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28652. /**
  28653. * Set the value of an uniform to an array of float32 (stored as vec2)
  28654. * @param uniform defines the webGL uniform location where to store the value
  28655. * @param array defines the array of float32 to store
  28656. */
  28657. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28658. /**
  28659. * Set the value of an uniform to an array of float32 (stored as vec3)
  28660. * @param uniform defines the webGL uniform location where to store the value
  28661. * @param array defines the array of float32 to store
  28662. */
  28663. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28664. /**
  28665. * Set the value of an uniform to an array of float32 (stored as vec4)
  28666. * @param uniform defines the webGL uniform location where to store the value
  28667. * @param array defines the array of float32 to store
  28668. */
  28669. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28670. /**
  28671. * Set the value of an uniform to an array of number
  28672. * @param uniform defines the webGL uniform location where to store the value
  28673. * @param array defines the array of number to store
  28674. */
  28675. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28676. /**
  28677. * Set the value of an uniform to an array of number (stored as vec2)
  28678. * @param uniform defines the webGL uniform location where to store the value
  28679. * @param array defines the array of number to store
  28680. */
  28681. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28682. /**
  28683. * Set the value of an uniform to an array of number (stored as vec3)
  28684. * @param uniform defines the webGL uniform location where to store the value
  28685. * @param array defines the array of number to store
  28686. */
  28687. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28688. /**
  28689. * Set the value of an uniform to an array of number (stored as vec4)
  28690. * @param uniform defines the webGL uniform location where to store the value
  28691. * @param array defines the array of number to store
  28692. */
  28693. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28694. /**
  28695. * Set the value of an uniform to an array of float32 (stored as matrices)
  28696. * @param uniform defines the webGL uniform location where to store the value
  28697. * @param matrices defines the array of float32 to store
  28698. */
  28699. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28700. /**
  28701. * Set the value of an uniform to a matrix
  28702. * @param uniform defines the webGL uniform location where to store the value
  28703. * @param matrix defines the matrix to store
  28704. */
  28705. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28706. /**
  28707. * Set the value of an uniform to a matrix (3x3)
  28708. * @param uniform defines the webGL uniform location where to store the value
  28709. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28710. */
  28711. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28712. /**
  28713. * Set the value of an uniform to a matrix (2x2)
  28714. * @param uniform defines the webGL uniform location where to store the value
  28715. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28716. */
  28717. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28718. /**
  28719. * Set the value of an uniform to a number (int)
  28720. * @param uniform defines the webGL uniform location where to store the value
  28721. * @param value defines the int number to store
  28722. */
  28723. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28724. /**
  28725. * Set the value of an uniform to a number (float)
  28726. * @param uniform defines the webGL uniform location where to store the value
  28727. * @param value defines the float number to store
  28728. */
  28729. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28730. /**
  28731. * Set the value of an uniform to a vec2
  28732. * @param uniform defines the webGL uniform location where to store the value
  28733. * @param x defines the 1st component of the value
  28734. * @param y defines the 2nd component of the value
  28735. */
  28736. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28737. /**
  28738. * Set the value of an uniform to a vec3
  28739. * @param uniform defines the webGL uniform location where to store the value
  28740. * @param x defines the 1st component of the value
  28741. * @param y defines the 2nd component of the value
  28742. * @param z defines the 3rd component of the value
  28743. */
  28744. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28745. /**
  28746. * Set the value of an uniform to a boolean
  28747. * @param uniform defines the webGL uniform location where to store the value
  28748. * @param bool defines the boolean to store
  28749. */
  28750. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28751. /**
  28752. * Set the value of an uniform to a vec4
  28753. * @param uniform defines the webGL uniform location where to store the value
  28754. * @param x defines the 1st component of the value
  28755. * @param y defines the 2nd component of the value
  28756. * @param z defines the 3rd component of the value
  28757. * @param w defines the 4th component of the value
  28758. */
  28759. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28760. /**
  28761. * Set the value of an uniform to a Color3
  28762. * @param uniform defines the webGL uniform location where to store the value
  28763. * @param color3 defines the color to store
  28764. */
  28765. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28766. /**
  28767. * Set the value of an uniform to a Color3 and an alpha value
  28768. * @param uniform defines the webGL uniform location where to store the value
  28769. * @param color3 defines the color to store
  28770. * @param alpha defines the alpha component to store
  28771. */
  28772. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28773. /**
  28774. * Sets a Color4 on a uniform variable
  28775. * @param uniform defines the uniform location
  28776. * @param color4 defines the value to be set
  28777. */
  28778. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28779. /**
  28780. * Set various states to the webGL context
  28781. * @param culling defines backface culling state
  28782. * @param zOffset defines the value to apply to zOffset (0 by default)
  28783. * @param force defines if states must be applied even if cache is up to date
  28784. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28785. */
  28786. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28787. /**
  28788. * Set the z offset to apply to current rendering
  28789. * @param value defines the offset to apply
  28790. */
  28791. setZOffset(value: number): void;
  28792. /**
  28793. * Gets the current value of the zOffset
  28794. * @returns the current zOffset state
  28795. */
  28796. getZOffset(): number;
  28797. /**
  28798. * Enable or disable depth buffering
  28799. * @param enable defines the state to set
  28800. */
  28801. setDepthBuffer(enable: boolean): void;
  28802. /**
  28803. * Gets a boolean indicating if depth writing is enabled
  28804. * @returns the current depth writing state
  28805. */
  28806. getDepthWrite(): boolean;
  28807. /**
  28808. * Enable or disable depth writing
  28809. * @param enable defines the state to set
  28810. */
  28811. setDepthWrite(enable: boolean): void;
  28812. /**
  28813. * Enable or disable color writing
  28814. * @param enable defines the state to set
  28815. */
  28816. setColorWrite(enable: boolean): void;
  28817. /**
  28818. * Gets a boolean indicating if color writing is enabled
  28819. * @returns the current color writing state
  28820. */
  28821. getColorWrite(): boolean;
  28822. /**
  28823. * Sets alpha constants used by some alpha blending modes
  28824. * @param r defines the red component
  28825. * @param g defines the green component
  28826. * @param b defines the blue component
  28827. * @param a defines the alpha component
  28828. */
  28829. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28830. /**
  28831. * Sets the current alpha mode
  28832. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28833. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28834. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28835. */
  28836. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28837. /**
  28838. * Gets the current alpha mode
  28839. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28840. * @returns the current alpha mode
  28841. */
  28842. getAlphaMode(): number;
  28843. /**
  28844. * Clears the list of texture accessible through engine.
  28845. * This can help preventing texture load conflict due to name collision.
  28846. */
  28847. clearInternalTexturesCache(): void;
  28848. /**
  28849. * Force the entire cache to be cleared
  28850. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28851. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28852. */
  28853. wipeCaches(bruteForce?: boolean): void;
  28854. /**
  28855. * Set the compressed texture format to use, based on the formats you have, and the formats
  28856. * supported by the hardware / browser.
  28857. *
  28858. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28859. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28860. * to API arguments needed to compressed textures. This puts the burden on the container
  28861. * generator to house the arcane code for determining these for current & future formats.
  28862. *
  28863. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28864. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28865. *
  28866. * Note: The result of this call is not taken into account when a texture is base64.
  28867. *
  28868. * @param formatsAvailable defines the list of those format families you have created
  28869. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28870. *
  28871. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28872. * @returns The extension selected.
  28873. */
  28874. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28875. private _getSamplingParameters;
  28876. private _partialLoadImg;
  28877. private _cascadeLoadImgs;
  28878. /** @hidden */
  28879. _createTexture(): WebGLTexture;
  28880. /**
  28881. * Usually called from Texture.ts.
  28882. * Passed information to create a WebGLTexture
  28883. * @param urlArg defines a value which contains one of the following:
  28884. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28885. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28886. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28887. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28888. * @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)
  28889. * @param scene needed for loading to the correct scene
  28890. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28891. * @param onLoad optional callback to be called upon successful completion
  28892. * @param onError optional callback to be called upon failure
  28893. * @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
  28894. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28895. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28896. * @param forcedExtension defines the extension to use to pick the right loader
  28897. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28898. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28899. */
  28900. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28901. private _rescaleTexture;
  28902. /**
  28903. * Update a raw texture
  28904. * @param texture defines the texture to update
  28905. * @param data defines the data to store in the texture
  28906. * @param format defines the format of the data
  28907. * @param invertY defines if data must be stored with Y axis inverted
  28908. * @param compression defines the compression used (null by default)
  28909. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28910. */
  28911. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28912. /**
  28913. * Creates a raw texture
  28914. * @param data defines the data to store in the texture
  28915. * @param width defines the width of the texture
  28916. * @param height defines the height of the texture
  28917. * @param format defines the format of the data
  28918. * @param generateMipMaps defines if the engine should generate the mip levels
  28919. * @param invertY defines if data must be stored with Y axis inverted
  28920. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28921. * @param compression defines the compression used (null by default)
  28922. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28923. * @returns the raw texture inside an InternalTexture
  28924. */
  28925. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28926. private _unpackFlipYCached;
  28927. /**
  28928. * In case you are sharing the context with other applications, it might
  28929. * be interested to not cache the unpack flip y state to ensure a consistent
  28930. * value would be set.
  28931. */
  28932. enableUnpackFlipYCached: boolean;
  28933. /** @hidden */
  28934. _unpackFlipY(value: boolean): void;
  28935. /** @hidden */
  28936. _getUnpackAlignement(): number;
  28937. /**
  28938. * Creates a dynamic texture
  28939. * @param width defines the width of the texture
  28940. * @param height defines the height of the texture
  28941. * @param generateMipMaps defines if the engine should generate the mip levels
  28942. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28943. * @returns the dynamic texture inside an InternalTexture
  28944. */
  28945. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28946. /**
  28947. * Update the sampling mode of a given texture
  28948. * @param samplingMode defines the required sampling mode
  28949. * @param texture defines the texture to update
  28950. */
  28951. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28952. /**
  28953. * Update the content of a dynamic texture
  28954. * @param texture defines the texture to update
  28955. * @param canvas defines the canvas containing the source
  28956. * @param invertY defines if data must be stored with Y axis inverted
  28957. * @param premulAlpha defines if alpha is stored as premultiplied
  28958. * @param format defines the format of the data
  28959. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28960. */
  28961. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28962. /**
  28963. * Update a video texture
  28964. * @param texture defines the texture to update
  28965. * @param video defines the video element to use
  28966. * @param invertY defines if data must be stored with Y axis inverted
  28967. */
  28968. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28969. /**
  28970. * Updates a depth texture Comparison Mode and Function.
  28971. * If the comparison Function is equal to 0, the mode will be set to none.
  28972. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28973. * @param texture The texture to set the comparison function for
  28974. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28975. */
  28976. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28977. private _setupDepthStencilTexture;
  28978. /**
  28979. * Creates a depth stencil texture.
  28980. * This is only available in WebGL 2 or with the depth texture extension available.
  28981. * @param size The size of face edge in the texture.
  28982. * @param options The options defining the texture.
  28983. * @returns The texture
  28984. */
  28985. createDepthStencilTexture(size: number | {
  28986. width: number;
  28987. height: number;
  28988. }, options: DepthTextureCreationOptions): InternalTexture;
  28989. /**
  28990. * Creates a depth stencil texture.
  28991. * This is only available in WebGL 2 or with the depth texture extension available.
  28992. * @param size The size of face edge in the texture.
  28993. * @param options The options defining the texture.
  28994. * @returns The texture
  28995. */
  28996. private _createDepthStencilTexture;
  28997. /**
  28998. * Creates a depth stencil cube texture.
  28999. * This is only available in WebGL 2.
  29000. * @param size The size of face edge in the cube texture.
  29001. * @param options The options defining the cube texture.
  29002. * @returns The cube texture
  29003. */
  29004. private _createDepthStencilCubeTexture;
  29005. /**
  29006. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29007. * @param renderTarget The render target to set the frame buffer for
  29008. */
  29009. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29010. /**
  29011. * Creates a new render target texture
  29012. * @param size defines the size of the texture
  29013. * @param options defines the options used to create the texture
  29014. * @returns a new render target texture stored in an InternalTexture
  29015. */
  29016. createRenderTargetTexture(size: number | {
  29017. width: number;
  29018. height: number;
  29019. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29020. /**
  29021. * Create a multi render target texture
  29022. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29023. * @param size defines the size of the texture
  29024. * @param options defines the creation options
  29025. * @returns the cube texture as an InternalTexture
  29026. */
  29027. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29028. private _setupFramebufferDepthAttachments;
  29029. /**
  29030. * Updates the sample count of a render target texture
  29031. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29032. * @param texture defines the texture to update
  29033. * @param samples defines the sample count to set
  29034. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29035. */
  29036. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29037. /**
  29038. * Update the sample count for a given multiple render target texture
  29039. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29040. * @param textures defines the textures to update
  29041. * @param samples defines the sample count to set
  29042. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29043. */
  29044. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29045. /** @hidden */
  29046. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29047. /** @hidden */
  29048. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29049. /** @hidden */
  29050. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29051. /** @hidden */
  29052. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29053. /**
  29054. * Creates a new render target cube texture
  29055. * @param size defines the size of the texture
  29056. * @param options defines the options used to create the texture
  29057. * @returns a new render target cube texture stored in an InternalTexture
  29058. */
  29059. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29060. /**
  29061. * Creates a cube texture
  29062. * @param rootUrl defines the url where the files to load is located
  29063. * @param scene defines the current scene
  29064. * @param files defines the list of files to load (1 per face)
  29065. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29066. * @param onLoad defines an optional callback raised when the texture is loaded
  29067. * @param onError defines an optional callback raised if there is an issue to load the texture
  29068. * @param format defines the format of the data
  29069. * @param forcedExtension defines the extension to use to pick the right loader
  29070. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29071. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29072. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29073. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29074. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29075. * @returns the cube texture as an InternalTexture
  29076. */
  29077. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29078. /**
  29079. * @hidden
  29080. */
  29081. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29082. /**
  29083. * Update a raw cube texture
  29084. * @param texture defines the texture to udpdate
  29085. * @param data defines the data to store
  29086. * @param format defines the data format
  29087. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29088. * @param invertY defines if data must be stored with Y axis inverted
  29089. * @param compression defines the compression used (null by default)
  29090. * @param level defines which level of the texture to update
  29091. */
  29092. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29093. /**
  29094. * Creates a new raw cube texture
  29095. * @param data defines the array of data to use to create each face
  29096. * @param size defines the size of the textures
  29097. * @param format defines the format of the data
  29098. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29099. * @param generateMipMaps defines if the engine should generate the mip levels
  29100. * @param invertY defines if data must be stored with Y axis inverted
  29101. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29102. * @param compression defines the compression used (null by default)
  29103. * @returns the cube texture as an InternalTexture
  29104. */
  29105. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29106. /**
  29107. * Creates a new raw cube texture from a specified url
  29108. * @param url defines the url where the data is located
  29109. * @param scene defines the current scene
  29110. * @param size defines the size of the textures
  29111. * @param format defines the format of the data
  29112. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29113. * @param noMipmap defines if the engine should avoid generating the mip levels
  29114. * @param callback defines a callback used to extract texture data from loaded data
  29115. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29116. * @param onLoad defines a callback called when texture is loaded
  29117. * @param onError defines a callback called if there is an error
  29118. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29119. * @param invertY defines if data must be stored with Y axis inverted
  29120. * @returns the cube texture as an InternalTexture
  29121. */
  29122. 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;
  29123. /**
  29124. * Update a raw 3D texture
  29125. * @param texture defines the texture to update
  29126. * @param data defines the data to store
  29127. * @param format defines the data format
  29128. * @param invertY defines if data must be stored with Y axis inverted
  29129. * @param compression defines the used compression (can be null)
  29130. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29131. */
  29132. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29133. /**
  29134. * Creates a new raw 3D texture
  29135. * @param data defines the data used to create the texture
  29136. * @param width defines the width of the texture
  29137. * @param height defines the height of the texture
  29138. * @param depth defines the depth of the texture
  29139. * @param format defines the format of the texture
  29140. * @param generateMipMaps defines if the engine must generate mip levels
  29141. * @param invertY defines if data must be stored with Y axis inverted
  29142. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29143. * @param compression defines the compressed used (can be null)
  29144. * @param textureType defines the compressed used (can be null)
  29145. * @returns a new raw 3D texture (stored in an InternalTexture)
  29146. */
  29147. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29148. private _prepareWebGLTextureContinuation;
  29149. private _prepareWebGLTexture;
  29150. private _convertRGBtoRGBATextureData;
  29151. /** @hidden */
  29152. _releaseFramebufferObjects(texture: InternalTexture): void;
  29153. /** @hidden */
  29154. _releaseTexture(texture: InternalTexture): void;
  29155. private setProgram;
  29156. private _boundUniforms;
  29157. /**
  29158. * Binds an effect to the webGL context
  29159. * @param effect defines the effect to bind
  29160. */
  29161. bindSamplers(effect: Effect): void;
  29162. private _moveBoundTextureOnTop;
  29163. private _getCorrectTextureChannel;
  29164. private _linkTrackers;
  29165. private _removeDesignatedSlot;
  29166. private _activateCurrentTexture;
  29167. /** @hidden */
  29168. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29169. /** @hidden */
  29170. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29171. /**
  29172. * Sets a texture to the webGL context from a postprocess
  29173. * @param channel defines the channel to use
  29174. * @param postProcess defines the source postprocess
  29175. */
  29176. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29177. /**
  29178. * Binds the output of the passed in post process to the texture channel specified
  29179. * @param channel The channel the texture should be bound to
  29180. * @param postProcess The post process which's output should be bound
  29181. */
  29182. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29183. /**
  29184. * Unbind all textures from the webGL context
  29185. */
  29186. unbindAllTextures(): void;
  29187. /**
  29188. * Sets a texture to the according uniform.
  29189. * @param channel The texture channel
  29190. * @param uniform The uniform to set
  29191. * @param texture The texture to apply
  29192. */
  29193. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29194. /**
  29195. * Sets a depth stencil texture from a render target to the according uniform.
  29196. * @param channel The texture channel
  29197. * @param uniform The uniform to set
  29198. * @param texture The render target texture containing the depth stencil texture to apply
  29199. */
  29200. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29201. private _bindSamplerUniformToChannel;
  29202. private _getTextureWrapMode;
  29203. private _setTexture;
  29204. /**
  29205. * Sets an array of texture to the webGL context
  29206. * @param channel defines the channel where the texture array must be set
  29207. * @param uniform defines the associated uniform location
  29208. * @param textures defines the array of textures to bind
  29209. */
  29210. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29211. /** @hidden */
  29212. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29213. private _setTextureParameterFloat;
  29214. private _setTextureParameterInteger;
  29215. /**
  29216. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29217. * @param x defines the x coordinate of the rectangle where pixels must be read
  29218. * @param y defines the y coordinate of the rectangle where pixels must be read
  29219. * @param width defines the width of the rectangle where pixels must be read
  29220. * @param height defines the height of the rectangle where pixels must be read
  29221. * @returns a Uint8Array containing RGBA colors
  29222. */
  29223. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29224. /**
  29225. * Add an externaly attached data from its key.
  29226. * This method call will fail and return false, if such key already exists.
  29227. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29228. * @param key the unique key that identifies the data
  29229. * @param data the data object to associate to the key for this Engine instance
  29230. * @return true if no such key were already present and the data was added successfully, false otherwise
  29231. */
  29232. addExternalData<T>(key: string, data: T): boolean;
  29233. /**
  29234. * Get an externaly attached data from its key
  29235. * @param key the unique key that identifies the data
  29236. * @return the associated data, if present (can be null), or undefined if not present
  29237. */
  29238. getExternalData<T>(key: string): T;
  29239. /**
  29240. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29241. * @param key the unique key that identifies the data
  29242. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29243. * @return the associated data, can be null if the factory returned null.
  29244. */
  29245. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29246. /**
  29247. * Remove an externaly attached data from the Engine instance
  29248. * @param key the unique key that identifies the data
  29249. * @return true if the data was successfully removed, false if it doesn't exist
  29250. */
  29251. removeExternalData(key: string): boolean;
  29252. /**
  29253. * Unbind all vertex attributes from the webGL context
  29254. */
  29255. unbindAllAttributes(): void;
  29256. /**
  29257. * 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
  29258. */
  29259. releaseEffects(): void;
  29260. /**
  29261. * Dispose and release all associated resources
  29262. */
  29263. dispose(): void;
  29264. /**
  29265. * Display the loading screen
  29266. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29267. */
  29268. displayLoadingUI(): void;
  29269. /**
  29270. * Hide the loading screen
  29271. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29272. */
  29273. hideLoadingUI(): void;
  29274. /**
  29275. * Gets the current loading screen object
  29276. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29277. */
  29278. /**
  29279. * Sets the current loading screen object
  29280. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29281. */
  29282. loadingScreen: ILoadingScreen;
  29283. /**
  29284. * Sets the current loading screen text
  29285. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29286. */
  29287. loadingUIText: string;
  29288. /**
  29289. * Sets the current loading screen background color
  29290. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29291. */
  29292. loadingUIBackgroundColor: string;
  29293. /**
  29294. * Attach a new callback raised when context lost event is fired
  29295. * @param callback defines the callback to call
  29296. */
  29297. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29298. /**
  29299. * Attach a new callback raised when context restored event is fired
  29300. * @param callback defines the callback to call
  29301. */
  29302. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29303. /**
  29304. * Gets the source code of the vertex shader associated with a specific webGL program
  29305. * @param program defines the program to use
  29306. * @returns a string containing the source code of the vertex shader associated with the program
  29307. */
  29308. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29309. /**
  29310. * Gets the source code of the fragment shader associated with a specific webGL program
  29311. * @param program defines the program to use
  29312. * @returns a string containing the source code of the fragment shader associated with the program
  29313. */
  29314. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29315. /**
  29316. * Get the current error code of the webGL context
  29317. * @returns the error code
  29318. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29319. */
  29320. getError(): number;
  29321. /**
  29322. * Gets the current framerate
  29323. * @returns a number representing the framerate
  29324. */
  29325. getFps(): number;
  29326. /**
  29327. * Gets the time spent between current and previous frame
  29328. * @returns a number representing the delta time in ms
  29329. */
  29330. getDeltaTime(): number;
  29331. private _measureFps;
  29332. /** @hidden */
  29333. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29334. private _canRenderToFloatFramebuffer;
  29335. private _canRenderToHalfFloatFramebuffer;
  29336. private _canRenderToFramebuffer;
  29337. /** @hidden */
  29338. _getWebGLTextureType(type: number): number;
  29339. private _getInternalFormat;
  29340. /** @hidden */
  29341. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29342. /** @hidden */
  29343. _getRGBAMultiSampleBufferFormat(type: number): number;
  29344. /** @hidden */
  29345. _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;
  29346. /** @hidden */
  29347. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29348. private _partialLoadFile;
  29349. private _cascadeLoadFiles;
  29350. /**
  29351. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29352. * @returns true if the engine can be created
  29353. * @ignorenaming
  29354. */
  29355. static isSupported(): boolean;
  29356. }
  29357. }
  29358. declare module "babylonjs/Materials/effect" {
  29359. import { Observable } from "babylonjs/Misc/observable";
  29360. import { Nullable } from "babylonjs/types";
  29361. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29362. import { Engine } from "babylonjs/Engines/engine";
  29363. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29365. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29366. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29368. /**
  29369. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29370. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29371. */
  29372. export class EffectFallbacks {
  29373. private _defines;
  29374. private _currentRank;
  29375. private _maxRank;
  29376. private _mesh;
  29377. /**
  29378. * Removes the fallback from the bound mesh.
  29379. */
  29380. unBindMesh(): void;
  29381. /**
  29382. * Adds a fallback on the specified property.
  29383. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29384. * @param define The name of the define in the shader
  29385. */
  29386. addFallback(rank: number, define: string): void;
  29387. /**
  29388. * Sets the mesh to use CPU skinning when needing to fallback.
  29389. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29390. * @param mesh The mesh to use the fallbacks.
  29391. */
  29392. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29393. /**
  29394. * Checks to see if more fallbacks are still availible.
  29395. */
  29396. readonly isMoreFallbacks: boolean;
  29397. /**
  29398. * Removes the defines that shoould be removed when falling back.
  29399. * @param currentDefines defines the current define statements for the shader.
  29400. * @param effect defines the current effect we try to compile
  29401. * @returns The resulting defines with defines of the current rank removed.
  29402. */
  29403. reduce(currentDefines: string, effect: Effect): string;
  29404. }
  29405. /**
  29406. * Options to be used when creating an effect.
  29407. */
  29408. export class EffectCreationOptions {
  29409. /**
  29410. * Atrributes that will be used in the shader.
  29411. */
  29412. attributes: string[];
  29413. /**
  29414. * Uniform varible names that will be set in the shader.
  29415. */
  29416. uniformsNames: string[];
  29417. /**
  29418. * Uniform buffer varible names that will be set in the shader.
  29419. */
  29420. uniformBuffersNames: string[];
  29421. /**
  29422. * Sampler texture variable names that will be set in the shader.
  29423. */
  29424. samplers: string[];
  29425. /**
  29426. * Define statements that will be set in the shader.
  29427. */
  29428. defines: any;
  29429. /**
  29430. * Possible fallbacks for this effect to improve performance when needed.
  29431. */
  29432. fallbacks: Nullable<EffectFallbacks>;
  29433. /**
  29434. * Callback that will be called when the shader is compiled.
  29435. */
  29436. onCompiled: Nullable<(effect: Effect) => void>;
  29437. /**
  29438. * Callback that will be called if an error occurs during shader compilation.
  29439. */
  29440. onError: Nullable<(effect: Effect, errors: string) => void>;
  29441. /**
  29442. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29443. */
  29444. indexParameters: any;
  29445. /**
  29446. * Max number of lights that can be used in the shader.
  29447. */
  29448. maxSimultaneousLights: number;
  29449. /**
  29450. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29451. */
  29452. transformFeedbackVaryings: Nullable<string[]>;
  29453. }
  29454. /**
  29455. * Effect containing vertex and fragment shader that can be executed on an object.
  29456. */
  29457. export class Effect {
  29458. /**
  29459. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29460. */
  29461. static ShadersRepository: string;
  29462. /**
  29463. * Name of the effect.
  29464. */
  29465. name: any;
  29466. /**
  29467. * String container all the define statements that should be set on the shader.
  29468. */
  29469. defines: string;
  29470. /**
  29471. * Callback that will be called when the shader is compiled.
  29472. */
  29473. onCompiled: Nullable<(effect: Effect) => void>;
  29474. /**
  29475. * Callback that will be called if an error occurs during shader compilation.
  29476. */
  29477. onError: Nullable<(effect: Effect, errors: string) => void>;
  29478. /**
  29479. * Callback that will be called when effect is bound.
  29480. */
  29481. onBind: Nullable<(effect: Effect) => void>;
  29482. /**
  29483. * Unique ID of the effect.
  29484. */
  29485. uniqueId: number;
  29486. /**
  29487. * Observable that will be called when the shader is compiled.
  29488. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29489. */
  29490. onCompileObservable: Observable<Effect>;
  29491. /**
  29492. * Observable that will be called if an error occurs during shader compilation.
  29493. */
  29494. onErrorObservable: Observable<Effect>;
  29495. /** @hidden */
  29496. _onBindObservable: Nullable<Observable<Effect>>;
  29497. /**
  29498. * Observable that will be called when effect is bound.
  29499. */
  29500. readonly onBindObservable: Observable<Effect>;
  29501. /** @hidden */
  29502. _bonesComputationForcedToCPU: boolean;
  29503. private static _uniqueIdSeed;
  29504. private _engine;
  29505. private _uniformBuffersNames;
  29506. private _uniformsNames;
  29507. private _samplers;
  29508. private _isReady;
  29509. private _compilationError;
  29510. private _attributesNames;
  29511. private _attributes;
  29512. private _uniforms;
  29513. /**
  29514. * Key for the effect.
  29515. * @hidden
  29516. */
  29517. _key: string;
  29518. private _indexParameters;
  29519. private _fallbacks;
  29520. private _vertexSourceCode;
  29521. private _fragmentSourceCode;
  29522. private _vertexSourceCodeOverride;
  29523. private _fragmentSourceCodeOverride;
  29524. private _transformFeedbackVaryings;
  29525. /**
  29526. * Compiled shader to webGL program.
  29527. * @hidden
  29528. */
  29529. _program: WebGLProgram;
  29530. private _valueCache;
  29531. private static _baseCache;
  29532. /**
  29533. * Instantiates an effect.
  29534. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29535. * @param baseName Name of the effect.
  29536. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29537. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29538. * @param samplers List of sampler variables that will be passed to the shader.
  29539. * @param engine Engine to be used to render the effect
  29540. * @param defines Define statements to be added to the shader.
  29541. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29542. * @param onCompiled Callback that will be called when the shader is compiled.
  29543. * @param onError Callback that will be called if an error occurs during shader compilation.
  29544. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29545. */
  29546. 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);
  29547. /**
  29548. * Unique key for this effect
  29549. */
  29550. readonly key: string;
  29551. /**
  29552. * If the effect has been compiled and prepared.
  29553. * @returns if the effect is compiled and prepared.
  29554. */
  29555. isReady(): boolean;
  29556. /**
  29557. * The engine the effect was initialized with.
  29558. * @returns the engine.
  29559. */
  29560. getEngine(): Engine;
  29561. /**
  29562. * The compiled webGL program for the effect
  29563. * @returns the webGL program.
  29564. */
  29565. getProgram(): WebGLProgram;
  29566. /**
  29567. * The set of names of attribute variables for the shader.
  29568. * @returns An array of attribute names.
  29569. */
  29570. getAttributesNames(): string[];
  29571. /**
  29572. * Returns the attribute at the given index.
  29573. * @param index The index of the attribute.
  29574. * @returns The location of the attribute.
  29575. */
  29576. getAttributeLocation(index: number): number;
  29577. /**
  29578. * Returns the attribute based on the name of the variable.
  29579. * @param name of the attribute to look up.
  29580. * @returns the attribute location.
  29581. */
  29582. getAttributeLocationByName(name: string): number;
  29583. /**
  29584. * The number of attributes.
  29585. * @returns the numnber of attributes.
  29586. */
  29587. getAttributesCount(): number;
  29588. /**
  29589. * Gets the index of a uniform variable.
  29590. * @param uniformName of the uniform to look up.
  29591. * @returns the index.
  29592. */
  29593. getUniformIndex(uniformName: string): number;
  29594. /**
  29595. * Returns the attribute based on the name of the variable.
  29596. * @param uniformName of the uniform to look up.
  29597. * @returns the location of the uniform.
  29598. */
  29599. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29600. /**
  29601. * Returns an array of sampler variable names
  29602. * @returns The array of sampler variable neames.
  29603. */
  29604. getSamplers(): string[];
  29605. /**
  29606. * The error from the last compilation.
  29607. * @returns the error string.
  29608. */
  29609. getCompilationError(): string;
  29610. /**
  29611. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29612. * @param func The callback to be used.
  29613. */
  29614. executeWhenCompiled(func: (effect: Effect) => void): void;
  29615. private _checkIsReady;
  29616. /** @hidden */
  29617. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29618. /** @hidden */
  29619. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29620. /** @hidden */
  29621. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29622. private _processShaderConversion;
  29623. private _processIncludes;
  29624. private _processPrecision;
  29625. /**
  29626. * Recompiles the webGL program
  29627. * @param vertexSourceCode The source code for the vertex shader.
  29628. * @param fragmentSourceCode The source code for the fragment shader.
  29629. * @param onCompiled Callback called when completed.
  29630. * @param onError Callback called on error.
  29631. * @hidden
  29632. */
  29633. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29634. /**
  29635. * Gets the uniform locations of the the specified variable names
  29636. * @param names THe names of the variables to lookup.
  29637. * @returns Array of locations in the same order as variable names.
  29638. */
  29639. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29640. /**
  29641. * Prepares the effect
  29642. * @hidden
  29643. */
  29644. _prepareEffect(): void;
  29645. /**
  29646. * Checks if the effect is supported. (Must be called after compilation)
  29647. */
  29648. readonly isSupported: boolean;
  29649. /**
  29650. * Binds a texture to the engine to be used as output of the shader.
  29651. * @param channel Name of the output variable.
  29652. * @param texture Texture to bind.
  29653. * @hidden
  29654. */
  29655. _bindTexture(channel: string, texture: InternalTexture): void;
  29656. /**
  29657. * Sets a texture on the engine to be used in the shader.
  29658. * @param channel Name of the sampler variable.
  29659. * @param texture Texture to set.
  29660. */
  29661. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29662. /**
  29663. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29664. * @param channel Name of the sampler variable.
  29665. * @param texture Texture to set.
  29666. */
  29667. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29668. /**
  29669. * Sets an array of textures on the engine to be used in the shader.
  29670. * @param channel Name of the variable.
  29671. * @param textures Textures to set.
  29672. */
  29673. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29674. /**
  29675. * 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)
  29676. * @param channel Name of the sampler variable.
  29677. * @param postProcess Post process to get the input texture from.
  29678. */
  29679. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29680. /**
  29681. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29682. * 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)
  29683. * @param channel Name of the sampler variable.
  29684. * @param postProcess Post process to get the output texture from.
  29685. */
  29686. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29687. /** @hidden */
  29688. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29689. /** @hidden */
  29690. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29691. /** @hidden */
  29692. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29693. /** @hidden */
  29694. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29695. /**
  29696. * Binds a buffer to a uniform.
  29697. * @param buffer Buffer to bind.
  29698. * @param name Name of the uniform variable to bind to.
  29699. */
  29700. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29701. /**
  29702. * Binds block to a uniform.
  29703. * @param blockName Name of the block to bind.
  29704. * @param index Index to bind.
  29705. */
  29706. bindUniformBlock(blockName: string, index: number): void;
  29707. /**
  29708. * Sets an interger value on a uniform variable.
  29709. * @param uniformName Name of the variable.
  29710. * @param value Value to be set.
  29711. * @returns this effect.
  29712. */
  29713. setInt(uniformName: string, value: number): Effect;
  29714. /**
  29715. * Sets an int array on a uniform variable.
  29716. * @param uniformName Name of the variable.
  29717. * @param array array to be set.
  29718. * @returns this effect.
  29719. */
  29720. setIntArray(uniformName: string, array: Int32Array): Effect;
  29721. /**
  29722. * 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)
  29723. * @param uniformName Name of the variable.
  29724. * @param array array to be set.
  29725. * @returns this effect.
  29726. */
  29727. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29728. /**
  29729. * 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)
  29730. * @param uniformName Name of the variable.
  29731. * @param array array to be set.
  29732. * @returns this effect.
  29733. */
  29734. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29735. /**
  29736. * 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)
  29737. * @param uniformName Name of the variable.
  29738. * @param array array to be set.
  29739. * @returns this effect.
  29740. */
  29741. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29742. /**
  29743. * Sets an float array on a uniform variable.
  29744. * @param uniformName Name of the variable.
  29745. * @param array array to be set.
  29746. * @returns this effect.
  29747. */
  29748. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29749. /**
  29750. * 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)
  29751. * @param uniformName Name of the variable.
  29752. * @param array array to be set.
  29753. * @returns this effect.
  29754. */
  29755. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29756. /**
  29757. * 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)
  29758. * @param uniformName Name of the variable.
  29759. * @param array array to be set.
  29760. * @returns this effect.
  29761. */
  29762. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29763. /**
  29764. * 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)
  29765. * @param uniformName Name of the variable.
  29766. * @param array array to be set.
  29767. * @returns this effect.
  29768. */
  29769. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29770. /**
  29771. * Sets an array on a uniform variable.
  29772. * @param uniformName Name of the variable.
  29773. * @param array array to be set.
  29774. * @returns this effect.
  29775. */
  29776. setArray(uniformName: string, array: number[]): Effect;
  29777. /**
  29778. * 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)
  29779. * @param uniformName Name of the variable.
  29780. * @param array array to be set.
  29781. * @returns this effect.
  29782. */
  29783. setArray2(uniformName: string, array: number[]): Effect;
  29784. /**
  29785. * 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)
  29786. * @param uniformName Name of the variable.
  29787. * @param array array to be set.
  29788. * @returns this effect.
  29789. */
  29790. setArray3(uniformName: string, array: number[]): Effect;
  29791. /**
  29792. * 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)
  29793. * @param uniformName Name of the variable.
  29794. * @param array array to be set.
  29795. * @returns this effect.
  29796. */
  29797. setArray4(uniformName: string, array: number[]): Effect;
  29798. /**
  29799. * Sets matrices on a uniform variable.
  29800. * @param uniformName Name of the variable.
  29801. * @param matrices matrices to be set.
  29802. * @returns this effect.
  29803. */
  29804. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29805. /**
  29806. * Sets matrix on a uniform variable.
  29807. * @param uniformName Name of the variable.
  29808. * @param matrix matrix to be set.
  29809. * @returns this effect.
  29810. */
  29811. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29812. /**
  29813. * 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)
  29814. * @param uniformName Name of the variable.
  29815. * @param matrix matrix to be set.
  29816. * @returns this effect.
  29817. */
  29818. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29819. /**
  29820. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29821. * @param uniformName Name of the variable.
  29822. * @param matrix matrix to be set.
  29823. * @returns this effect.
  29824. */
  29825. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29826. /**
  29827. * Sets a float on a uniform variable.
  29828. * @param uniformName Name of the variable.
  29829. * @param value value to be set.
  29830. * @returns this effect.
  29831. */
  29832. setFloat(uniformName: string, value: number): Effect;
  29833. /**
  29834. * Sets a boolean on a uniform variable.
  29835. * @param uniformName Name of the variable.
  29836. * @param bool value to be set.
  29837. * @returns this effect.
  29838. */
  29839. setBool(uniformName: string, bool: boolean): Effect;
  29840. /**
  29841. * Sets a Vector2 on a uniform variable.
  29842. * @param uniformName Name of the variable.
  29843. * @param vector2 vector2 to be set.
  29844. * @returns this effect.
  29845. */
  29846. setVector2(uniformName: string, vector2: Vector2): Effect;
  29847. /**
  29848. * Sets a float2 on a uniform variable.
  29849. * @param uniformName Name of the variable.
  29850. * @param x First float in float2.
  29851. * @param y Second float in float2.
  29852. * @returns this effect.
  29853. */
  29854. setFloat2(uniformName: string, x: number, y: number): Effect;
  29855. /**
  29856. * Sets a Vector3 on a uniform variable.
  29857. * @param uniformName Name of the variable.
  29858. * @param vector3 Value to be set.
  29859. * @returns this effect.
  29860. */
  29861. setVector3(uniformName: string, vector3: Vector3): Effect;
  29862. /**
  29863. * Sets a float3 on a uniform variable.
  29864. * @param uniformName Name of the variable.
  29865. * @param x First float in float3.
  29866. * @param y Second float in float3.
  29867. * @param z Third float in float3.
  29868. * @returns this effect.
  29869. */
  29870. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29871. /**
  29872. * Sets a Vector4 on a uniform variable.
  29873. * @param uniformName Name of the variable.
  29874. * @param vector4 Value to be set.
  29875. * @returns this effect.
  29876. */
  29877. setVector4(uniformName: string, vector4: Vector4): Effect;
  29878. /**
  29879. * Sets a float4 on a uniform variable.
  29880. * @param uniformName Name of the variable.
  29881. * @param x First float in float4.
  29882. * @param y Second float in float4.
  29883. * @param z Third float in float4.
  29884. * @param w Fourth float in float4.
  29885. * @returns this effect.
  29886. */
  29887. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29888. /**
  29889. * Sets a Color3 on a uniform variable.
  29890. * @param uniformName Name of the variable.
  29891. * @param color3 Value to be set.
  29892. * @returns this effect.
  29893. */
  29894. setColor3(uniformName: string, color3: Color3): Effect;
  29895. /**
  29896. * Sets a Color4 on a uniform variable.
  29897. * @param uniformName Name of the variable.
  29898. * @param color3 Value to be set.
  29899. * @param alpha Alpha value to be set.
  29900. * @returns this effect.
  29901. */
  29902. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29903. /**
  29904. * Sets a Color4 on a uniform variable
  29905. * @param uniformName defines the name of the variable
  29906. * @param color4 defines the value to be set
  29907. * @returns this effect.
  29908. */
  29909. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29910. /**
  29911. * This function will add a new shader to the shader store
  29912. * @param name the name of the shader
  29913. * @param pixelShader optional pixel shader content
  29914. * @param vertexShader optional vertex shader content
  29915. */
  29916. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29917. /**
  29918. * Store of each shader (The can be looked up using effect.key)
  29919. */
  29920. static ShadersStore: {
  29921. [key: string]: string;
  29922. };
  29923. /**
  29924. * Store of each included file for a shader (The can be looked up using effect.key)
  29925. */
  29926. static IncludesShadersStore: {
  29927. [key: string]: string;
  29928. };
  29929. /**
  29930. * Resets the cache of effects.
  29931. */
  29932. static ResetCache(): void;
  29933. }
  29934. }
  29935. declare module "babylonjs/Materials/colorCurves" {
  29936. import { Effect } from "babylonjs/Materials/effect";
  29937. /**
  29938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29940. * 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;
  29941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29942. */
  29943. export class ColorCurves {
  29944. private _dirty;
  29945. private _tempColor;
  29946. private _globalCurve;
  29947. private _highlightsCurve;
  29948. private _midtonesCurve;
  29949. private _shadowsCurve;
  29950. private _positiveCurve;
  29951. private _negativeCurve;
  29952. private _globalHue;
  29953. private _globalDensity;
  29954. private _globalSaturation;
  29955. private _globalExposure;
  29956. /**
  29957. * Gets the global Hue value.
  29958. * 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).
  29959. */
  29960. /**
  29961. * Sets the global Hue value.
  29962. * 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).
  29963. */
  29964. globalHue: number;
  29965. /**
  29966. * Gets the global Density value.
  29967. * 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.
  29968. * Values less than zero provide a filter of opposite hue.
  29969. */
  29970. /**
  29971. * Sets the global Density value.
  29972. * 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.
  29973. * Values less than zero provide a filter of opposite hue.
  29974. */
  29975. globalDensity: number;
  29976. /**
  29977. * Gets the global Saturation value.
  29978. * 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.
  29979. */
  29980. /**
  29981. * Sets the global Saturation value.
  29982. * 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.
  29983. */
  29984. globalSaturation: number;
  29985. /**
  29986. * Gets the global Exposure value.
  29987. * 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.
  29988. */
  29989. /**
  29990. * Sets the global Exposure value.
  29991. * 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.
  29992. */
  29993. globalExposure: number;
  29994. private _highlightsHue;
  29995. private _highlightsDensity;
  29996. private _highlightsSaturation;
  29997. private _highlightsExposure;
  29998. /**
  29999. * Gets the highlights Hue value.
  30000. * 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).
  30001. */
  30002. /**
  30003. * Sets the highlights Hue value.
  30004. * 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).
  30005. */
  30006. highlightsHue: number;
  30007. /**
  30008. * Gets the highlights Density value.
  30009. * 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.
  30010. * Values less than zero provide a filter of opposite hue.
  30011. */
  30012. /**
  30013. * Sets the highlights Density value.
  30014. * 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.
  30015. * Values less than zero provide a filter of opposite hue.
  30016. */
  30017. highlightsDensity: number;
  30018. /**
  30019. * Gets the highlights Saturation value.
  30020. * 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.
  30021. */
  30022. /**
  30023. * Sets the highlights Saturation value.
  30024. * 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.
  30025. */
  30026. highlightsSaturation: number;
  30027. /**
  30028. * Gets the highlights Exposure value.
  30029. * 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.
  30030. */
  30031. /**
  30032. * Sets the highlights Exposure value.
  30033. * 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.
  30034. */
  30035. highlightsExposure: number;
  30036. private _midtonesHue;
  30037. private _midtonesDensity;
  30038. private _midtonesSaturation;
  30039. private _midtonesExposure;
  30040. /**
  30041. * Gets the midtones Hue value.
  30042. * 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).
  30043. */
  30044. /**
  30045. * Sets the midtones Hue value.
  30046. * 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).
  30047. */
  30048. midtonesHue: number;
  30049. /**
  30050. * Gets the midtones Density value.
  30051. * 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.
  30052. * Values less than zero provide a filter of opposite hue.
  30053. */
  30054. /**
  30055. * Sets the midtones Density value.
  30056. * 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.
  30057. * Values less than zero provide a filter of opposite hue.
  30058. */
  30059. midtonesDensity: number;
  30060. /**
  30061. * Gets the midtones Saturation value.
  30062. * 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.
  30063. */
  30064. /**
  30065. * Sets the midtones Saturation value.
  30066. * 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.
  30067. */
  30068. midtonesSaturation: number;
  30069. /**
  30070. * Gets the midtones Exposure value.
  30071. * 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.
  30072. */
  30073. /**
  30074. * Sets the midtones Exposure value.
  30075. * 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.
  30076. */
  30077. midtonesExposure: number;
  30078. private _shadowsHue;
  30079. private _shadowsDensity;
  30080. private _shadowsSaturation;
  30081. private _shadowsExposure;
  30082. /**
  30083. * Gets the shadows Hue value.
  30084. * 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).
  30085. */
  30086. /**
  30087. * Sets the shadows Hue value.
  30088. * 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).
  30089. */
  30090. shadowsHue: number;
  30091. /**
  30092. * Gets the shadows Density value.
  30093. * 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.
  30094. * Values less than zero provide a filter of opposite hue.
  30095. */
  30096. /**
  30097. * Sets the shadows Density value.
  30098. * 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.
  30099. * Values less than zero provide a filter of opposite hue.
  30100. */
  30101. shadowsDensity: number;
  30102. /**
  30103. * Gets the shadows Saturation value.
  30104. * 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.
  30105. */
  30106. /**
  30107. * Sets the shadows Saturation value.
  30108. * 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.
  30109. */
  30110. shadowsSaturation: number;
  30111. /**
  30112. * Gets the shadows Exposure value.
  30113. * 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.
  30114. */
  30115. /**
  30116. * Sets the shadows Exposure value.
  30117. * 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.
  30118. */
  30119. shadowsExposure: number;
  30120. /**
  30121. * Returns the class name
  30122. * @returns The class name
  30123. */
  30124. getClassName(): string;
  30125. /**
  30126. * Binds the color curves to the shader.
  30127. * @param colorCurves The color curve to bind
  30128. * @param effect The effect to bind to
  30129. * @param positiveUniform The positive uniform shader parameter
  30130. * @param neutralUniform The neutral uniform shader parameter
  30131. * @param negativeUniform The negative uniform shader parameter
  30132. */
  30133. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30134. /**
  30135. * Prepare the list of uniforms associated with the ColorCurves effects.
  30136. * @param uniformsList The list of uniforms used in the effect
  30137. */
  30138. static PrepareUniforms(uniformsList: string[]): void;
  30139. /**
  30140. * Returns color grading data based on a hue, density, saturation and exposure value.
  30141. * @param filterHue The hue of the color filter.
  30142. * @param filterDensity The density of the color filter.
  30143. * @param saturation The saturation.
  30144. * @param exposure The exposure.
  30145. * @param result The result data container.
  30146. */
  30147. private getColorGradingDataToRef;
  30148. /**
  30149. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30150. * @param value The input slider value in range [-100,100].
  30151. * @returns Adjusted value.
  30152. */
  30153. private static applyColorGradingSliderNonlinear;
  30154. /**
  30155. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30156. * @param hue The hue (H) input.
  30157. * @param saturation The saturation (S) input.
  30158. * @param brightness The brightness (B) input.
  30159. * @result An RGBA color represented as Vector4.
  30160. */
  30161. private static fromHSBToRef;
  30162. /**
  30163. * Returns a value clamped between min and max
  30164. * @param value The value to clamp
  30165. * @param min The minimum of value
  30166. * @param max The maximum of value
  30167. * @returns The clamped value.
  30168. */
  30169. private static clamp;
  30170. /**
  30171. * Clones the current color curve instance.
  30172. * @return The cloned curves
  30173. */
  30174. clone(): ColorCurves;
  30175. /**
  30176. * Serializes the current color curve instance to a json representation.
  30177. * @return a JSON representation
  30178. */
  30179. serialize(): any;
  30180. /**
  30181. * Parses the color curve from a json representation.
  30182. * @param source the JSON source to parse
  30183. * @return The parsed curves
  30184. */
  30185. static Parse(source: any): ColorCurves;
  30186. }
  30187. }
  30188. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30189. import { Observable } from "babylonjs/Misc/observable";
  30190. import { Nullable } from "babylonjs/types";
  30191. import { Color4 } from "babylonjs/Maths/math";
  30192. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30193. import { Effect } from "babylonjs/Materials/effect";
  30194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30195. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30196. /**
  30197. * Interface to follow in your material defines to integrate easily the
  30198. * Image proccessing functions.
  30199. * @hidden
  30200. */
  30201. export interface IImageProcessingConfigurationDefines {
  30202. IMAGEPROCESSING: boolean;
  30203. VIGNETTE: boolean;
  30204. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30205. VIGNETTEBLENDMODEOPAQUE: boolean;
  30206. TONEMAPPING: boolean;
  30207. TONEMAPPING_ACES: boolean;
  30208. CONTRAST: boolean;
  30209. EXPOSURE: boolean;
  30210. COLORCURVES: boolean;
  30211. COLORGRADING: boolean;
  30212. COLORGRADING3D: boolean;
  30213. SAMPLER3DGREENDEPTH: boolean;
  30214. SAMPLER3DBGRMAP: boolean;
  30215. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30216. }
  30217. /**
  30218. * @hidden
  30219. */
  30220. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30221. IMAGEPROCESSING: boolean;
  30222. VIGNETTE: boolean;
  30223. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30224. VIGNETTEBLENDMODEOPAQUE: boolean;
  30225. TONEMAPPING: boolean;
  30226. TONEMAPPING_ACES: boolean;
  30227. CONTRAST: boolean;
  30228. COLORCURVES: boolean;
  30229. COLORGRADING: boolean;
  30230. COLORGRADING3D: boolean;
  30231. SAMPLER3DGREENDEPTH: boolean;
  30232. SAMPLER3DBGRMAP: boolean;
  30233. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30234. EXPOSURE: boolean;
  30235. constructor();
  30236. }
  30237. /**
  30238. * This groups together the common properties used for image processing either in direct forward pass
  30239. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30240. * or not.
  30241. */
  30242. export class ImageProcessingConfiguration {
  30243. /**
  30244. * Default tone mapping applied in BabylonJS.
  30245. */
  30246. static readonly TONEMAPPING_STANDARD: number;
  30247. /**
  30248. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30249. * to other engines rendering to increase portability.
  30250. */
  30251. static readonly TONEMAPPING_ACES: number;
  30252. /**
  30253. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30254. */
  30255. colorCurves: Nullable<ColorCurves>;
  30256. private _colorCurvesEnabled;
  30257. /**
  30258. * Gets wether the color curves effect is enabled.
  30259. */
  30260. /**
  30261. * Sets wether the color curves effect is enabled.
  30262. */
  30263. colorCurvesEnabled: boolean;
  30264. private _colorGradingTexture;
  30265. /**
  30266. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30267. */
  30268. /**
  30269. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30270. */
  30271. colorGradingTexture: Nullable<BaseTexture>;
  30272. private _colorGradingEnabled;
  30273. /**
  30274. * Gets wether the color grading effect is enabled.
  30275. */
  30276. /**
  30277. * Sets wether the color grading effect is enabled.
  30278. */
  30279. colorGradingEnabled: boolean;
  30280. private _colorGradingWithGreenDepth;
  30281. /**
  30282. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30283. */
  30284. /**
  30285. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30286. */
  30287. colorGradingWithGreenDepth: boolean;
  30288. private _colorGradingBGR;
  30289. /**
  30290. * Gets wether the color grading texture contains BGR values.
  30291. */
  30292. /**
  30293. * Sets wether the color grading texture contains BGR values.
  30294. */
  30295. colorGradingBGR: boolean;
  30296. /** @hidden */
  30297. _exposure: number;
  30298. /**
  30299. * Gets the Exposure used in the effect.
  30300. */
  30301. /**
  30302. * Sets the Exposure used in the effect.
  30303. */
  30304. exposure: number;
  30305. private _toneMappingEnabled;
  30306. /**
  30307. * Gets wether the tone mapping effect is enabled.
  30308. */
  30309. /**
  30310. * Sets wether the tone mapping effect is enabled.
  30311. */
  30312. toneMappingEnabled: boolean;
  30313. private _toneMappingType;
  30314. /**
  30315. * Gets the type of tone mapping effect.
  30316. */
  30317. /**
  30318. * Sets the type of tone mapping effect used in BabylonJS.
  30319. */
  30320. toneMappingType: number;
  30321. protected _contrast: number;
  30322. /**
  30323. * Gets the contrast used in the effect.
  30324. */
  30325. /**
  30326. * Sets the contrast used in the effect.
  30327. */
  30328. contrast: number;
  30329. /**
  30330. * Vignette stretch size.
  30331. */
  30332. vignetteStretch: number;
  30333. /**
  30334. * Vignette centre X Offset.
  30335. */
  30336. vignetteCentreX: number;
  30337. /**
  30338. * Vignette centre Y Offset.
  30339. */
  30340. vignetteCentreY: number;
  30341. /**
  30342. * Vignette weight or intensity of the vignette effect.
  30343. */
  30344. vignetteWeight: number;
  30345. /**
  30346. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30347. * if vignetteEnabled is set to true.
  30348. */
  30349. vignetteColor: Color4;
  30350. /**
  30351. * Camera field of view used by the Vignette effect.
  30352. */
  30353. vignetteCameraFov: number;
  30354. private _vignetteBlendMode;
  30355. /**
  30356. * Gets the vignette blend mode allowing different kind of effect.
  30357. */
  30358. /**
  30359. * Sets the vignette blend mode allowing different kind of effect.
  30360. */
  30361. vignetteBlendMode: number;
  30362. private _vignetteEnabled;
  30363. /**
  30364. * Gets wether the vignette effect is enabled.
  30365. */
  30366. /**
  30367. * Sets wether the vignette effect is enabled.
  30368. */
  30369. vignetteEnabled: boolean;
  30370. private _applyByPostProcess;
  30371. /**
  30372. * Gets wether the image processing is applied through a post process or not.
  30373. */
  30374. /**
  30375. * Sets wether the image processing is applied through a post process or not.
  30376. */
  30377. applyByPostProcess: boolean;
  30378. private _isEnabled;
  30379. /**
  30380. * Gets wether the image processing is enabled or not.
  30381. */
  30382. /**
  30383. * Sets wether the image processing is enabled or not.
  30384. */
  30385. isEnabled: boolean;
  30386. /**
  30387. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30388. */
  30389. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30390. /**
  30391. * Method called each time the image processing information changes requires to recompile the effect.
  30392. */
  30393. protected _updateParameters(): void;
  30394. /**
  30395. * Gets the current class name.
  30396. * @return "ImageProcessingConfiguration"
  30397. */
  30398. getClassName(): string;
  30399. /**
  30400. * Prepare the list of uniforms associated with the Image Processing effects.
  30401. * @param uniforms The list of uniforms used in the effect
  30402. * @param defines the list of defines currently in use
  30403. */
  30404. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30405. /**
  30406. * Prepare the list of samplers associated with the Image Processing effects.
  30407. * @param samplersList The list of uniforms used in the effect
  30408. * @param defines the list of defines currently in use
  30409. */
  30410. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30411. /**
  30412. * Prepare the list of defines associated to the shader.
  30413. * @param defines the list of defines to complete
  30414. * @param forPostProcess Define if we are currently in post process mode or not
  30415. */
  30416. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30417. /**
  30418. * Returns true if all the image processing information are ready.
  30419. * @returns True if ready, otherwise, false
  30420. */
  30421. isReady(): boolean;
  30422. /**
  30423. * Binds the image processing to the shader.
  30424. * @param effect The effect to bind to
  30425. * @param aspectRatio Define the current aspect ratio of the effect
  30426. */
  30427. bind(effect: Effect, aspectRatio?: number): void;
  30428. /**
  30429. * Clones the current image processing instance.
  30430. * @return The cloned image processing
  30431. */
  30432. clone(): ImageProcessingConfiguration;
  30433. /**
  30434. * Serializes the current image processing instance to a json representation.
  30435. * @return a JSON representation
  30436. */
  30437. serialize(): any;
  30438. /**
  30439. * Parses the image processing from a json representation.
  30440. * @param source the JSON source to parse
  30441. * @return The parsed image processing
  30442. */
  30443. static Parse(source: any): ImageProcessingConfiguration;
  30444. private static _VIGNETTEMODE_MULTIPLY;
  30445. private static _VIGNETTEMODE_OPAQUE;
  30446. /**
  30447. * Used to apply the vignette as a mix with the pixel color.
  30448. */
  30449. static readonly VIGNETTEMODE_MULTIPLY: number;
  30450. /**
  30451. * Used to apply the vignette as a replacement of the pixel color.
  30452. */
  30453. static readonly VIGNETTEMODE_OPAQUE: number;
  30454. }
  30455. }
  30456. declare module "babylonjs/Materials/fresnelParameters" {
  30457. import { Color3 } from "babylonjs/Maths/math";
  30458. /**
  30459. * This represents all the required information to add a fresnel effect on a material:
  30460. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30461. */
  30462. export class FresnelParameters {
  30463. private _isEnabled;
  30464. /**
  30465. * Define if the fresnel effect is enable or not.
  30466. */
  30467. isEnabled: boolean;
  30468. /**
  30469. * Define the color used on edges (grazing angle)
  30470. */
  30471. leftColor: Color3;
  30472. /**
  30473. * Define the color used on center
  30474. */
  30475. rightColor: Color3;
  30476. /**
  30477. * Define bias applied to computed fresnel term
  30478. */
  30479. bias: number;
  30480. /**
  30481. * Defined the power exponent applied to fresnel term
  30482. */
  30483. power: number;
  30484. /**
  30485. * Clones the current fresnel and its valuues
  30486. * @returns a clone fresnel configuration
  30487. */
  30488. clone(): FresnelParameters;
  30489. /**
  30490. * Serializes the current fresnel parameters to a JSON representation.
  30491. * @return the JSON serialization
  30492. */
  30493. serialize(): any;
  30494. /**
  30495. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30496. * @param parsedFresnelParameters Define the JSON representation
  30497. * @returns the parsed parameters
  30498. */
  30499. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30500. }
  30501. }
  30502. declare module "babylonjs/Misc/decorators" {
  30503. import { Nullable } from "babylonjs/types";
  30504. import { Scene } from "babylonjs/scene";
  30505. import { IAnimatable } from "babylonjs/Misc/tools";
  30506. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30507. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30508. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30509. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30510. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30511. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30512. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30513. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30514. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30515. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30516. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30517. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30518. /**
  30519. * Decorator used to define property that can be serialized as reference to a camera
  30520. * @param sourceName defines the name of the property to decorate
  30521. */
  30522. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30523. /**
  30524. * Class used to help serialization objects
  30525. */
  30526. export class SerializationHelper {
  30527. /** hidden */
  30528. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30529. /** hidden */
  30530. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30531. /** hidden */
  30532. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30533. /** hidden */
  30534. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30535. /**
  30536. * Appends the serialized animations from the source animations
  30537. * @param source Source containing the animations
  30538. * @param destination Target to store the animations
  30539. */
  30540. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30541. /**
  30542. * Static function used to serialized a specific entity
  30543. * @param entity defines the entity to serialize
  30544. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30545. * @returns a JSON compatible object representing the serialization of the entity
  30546. */
  30547. static Serialize<T>(entity: T, serializationObject?: any): any;
  30548. /**
  30549. * Creates a new entity from a serialization data object
  30550. * @param creationFunction defines a function used to instanciated the new entity
  30551. * @param source defines the source serialization data
  30552. * @param scene defines the hosting scene
  30553. * @param rootUrl defines the root url for resources
  30554. * @returns a new entity
  30555. */
  30556. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30557. /**
  30558. * Clones an object
  30559. * @param creationFunction defines the function used to instanciate the new object
  30560. * @param source defines the source object
  30561. * @returns the cloned object
  30562. */
  30563. static Clone<T>(creationFunction: () => T, source: T): T;
  30564. /**
  30565. * Instanciates a new object based on a source one (some data will be shared between both object)
  30566. * @param creationFunction defines the function used to instanciate the new object
  30567. * @param source defines the source object
  30568. * @returns the new object
  30569. */
  30570. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30571. }
  30572. }
  30573. declare module "babylonjs/Cameras/camera" {
  30574. import { SmartArray } from "babylonjs/Misc/smartArray";
  30575. import { Observable } from "babylonjs/Misc/observable";
  30576. import { Nullable } from "babylonjs/types";
  30577. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30578. import { Scene } from "babylonjs/scene";
  30579. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30580. import { Node } from "babylonjs/node";
  30581. import { Mesh } from "babylonjs/Meshes/mesh";
  30582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30583. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30584. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30585. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30586. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30587. import { Ray } from "babylonjs/Culling/ray";
  30588. /**
  30589. * This is the base class of all the camera used in the application.
  30590. * @see http://doc.babylonjs.com/features/cameras
  30591. */
  30592. export class Camera extends Node {
  30593. /** @hidden */
  30594. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30595. /**
  30596. * This is the default projection mode used by the cameras.
  30597. * It helps recreating a feeling of perspective and better appreciate depth.
  30598. * This is the best way to simulate real life cameras.
  30599. */
  30600. static readonly PERSPECTIVE_CAMERA: number;
  30601. /**
  30602. * This helps creating camera with an orthographic mode.
  30603. * 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.
  30604. */
  30605. static readonly ORTHOGRAPHIC_CAMERA: number;
  30606. /**
  30607. * This is the default FOV mode for perspective cameras.
  30608. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30609. */
  30610. static readonly FOVMODE_VERTICAL_FIXED: number;
  30611. /**
  30612. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30613. */
  30614. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30615. /**
  30616. * This specifies ther is no need for a camera rig.
  30617. * Basically only one eye is rendered corresponding to the camera.
  30618. */
  30619. static readonly RIG_MODE_NONE: number;
  30620. /**
  30621. * Simulates a camera Rig with one blue eye and one red eye.
  30622. * This can be use with 3d blue and red glasses.
  30623. */
  30624. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30625. /**
  30626. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30627. */
  30628. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30629. /**
  30630. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30631. */
  30632. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30633. /**
  30634. * Defines that both eyes of the camera will be rendered over under each other.
  30635. */
  30636. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30637. /**
  30638. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30639. */
  30640. static readonly RIG_MODE_VR: number;
  30641. /**
  30642. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30643. */
  30644. static readonly RIG_MODE_WEBVR: number;
  30645. /**
  30646. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30647. */
  30648. static readonly RIG_MODE_CUSTOM: number;
  30649. /**
  30650. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30651. */
  30652. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30653. /**
  30654. * @hidden
  30655. * Might be removed once multiview will be a thing
  30656. */
  30657. static UseAlternateWebVRRendering: boolean;
  30658. /**
  30659. * Define the input manager associated with the camera.
  30660. */
  30661. inputs: CameraInputsManager<Camera>;
  30662. /** @hidden */
  30663. _position: Vector3;
  30664. /**
  30665. * Define the current local position of the camera in the scene
  30666. */
  30667. position: Vector3;
  30668. /**
  30669. * The vector the camera should consider as up.
  30670. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30671. */
  30672. upVector: Vector3;
  30673. /**
  30674. * Define the current limit on the left side for an orthographic camera
  30675. * In scene unit
  30676. */
  30677. orthoLeft: Nullable<number>;
  30678. /**
  30679. * Define the current limit on the right side for an orthographic camera
  30680. * In scene unit
  30681. */
  30682. orthoRight: Nullable<number>;
  30683. /**
  30684. * Define the current limit on the bottom side for an orthographic camera
  30685. * In scene unit
  30686. */
  30687. orthoBottom: Nullable<number>;
  30688. /**
  30689. * Define the current limit on the top side for an orthographic camera
  30690. * In scene unit
  30691. */
  30692. orthoTop: Nullable<number>;
  30693. /**
  30694. * Field Of View is set in Radians. (default is 0.8)
  30695. */
  30696. fov: number;
  30697. /**
  30698. * Define the minimum distance the camera can see from.
  30699. * This is important to note that the depth buffer are not infinite and the closer it starts
  30700. * the more your scene might encounter depth fighting issue.
  30701. */
  30702. minZ: number;
  30703. /**
  30704. * Define the maximum distance the camera can see to.
  30705. * This is important to note that the depth buffer are not infinite and the further it end
  30706. * the more your scene might encounter depth fighting issue.
  30707. */
  30708. maxZ: number;
  30709. /**
  30710. * Define the default inertia of the camera.
  30711. * This helps giving a smooth feeling to the camera movement.
  30712. */
  30713. inertia: number;
  30714. /**
  30715. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30716. */
  30717. mode: number;
  30718. /**
  30719. * Define wether the camera is intermediate.
  30720. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30721. */
  30722. isIntermediate: boolean;
  30723. /**
  30724. * Define the viewport of the camera.
  30725. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30726. */
  30727. viewport: Viewport;
  30728. /**
  30729. * Restricts the camera to viewing objects with the same layerMask.
  30730. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30731. */
  30732. layerMask: number;
  30733. /**
  30734. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30735. */
  30736. fovMode: number;
  30737. /**
  30738. * Rig mode of the camera.
  30739. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30740. * This is normally controlled byt the camera themselves as internal use.
  30741. */
  30742. cameraRigMode: number;
  30743. /**
  30744. * Defines the distance between both "eyes" in case of a RIG
  30745. */
  30746. interaxialDistance: number;
  30747. /**
  30748. * Defines if stereoscopic rendering is done side by side or over under.
  30749. */
  30750. isStereoscopicSideBySide: boolean;
  30751. /**
  30752. * 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
  30753. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30754. * else in the scene.
  30755. */
  30756. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30757. /**
  30758. * When set, the camera will render to this render target instead of the default canvas
  30759. */
  30760. outputRenderTarget: Nullable<RenderTargetTexture>;
  30761. /**
  30762. * Observable triggered when the camera view matrix has changed.
  30763. */
  30764. onViewMatrixChangedObservable: Observable<Camera>;
  30765. /**
  30766. * Observable triggered when the camera Projection matrix has changed.
  30767. */
  30768. onProjectionMatrixChangedObservable: Observable<Camera>;
  30769. /**
  30770. * Observable triggered when the inputs have been processed.
  30771. */
  30772. onAfterCheckInputsObservable: Observable<Camera>;
  30773. /**
  30774. * Observable triggered when reset has been called and applied to the camera.
  30775. */
  30776. onRestoreStateObservable: Observable<Camera>;
  30777. /** @hidden */
  30778. _cameraRigParams: any;
  30779. /** @hidden */
  30780. _rigCameras: Camera[];
  30781. /** @hidden */
  30782. _rigPostProcess: Nullable<PostProcess>;
  30783. protected _webvrViewMatrix: Matrix;
  30784. /** @hidden */
  30785. _skipRendering: boolean;
  30786. /** @hidden */
  30787. _alternateCamera: Camera;
  30788. /** @hidden */
  30789. _projectionMatrix: Matrix;
  30790. /** @hidden */
  30791. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30792. /** @hidden */
  30793. _activeMeshes: SmartArray<AbstractMesh>;
  30794. protected _globalPosition: Vector3;
  30795. /** hidden */
  30796. _computedViewMatrix: Matrix;
  30797. private _doNotComputeProjectionMatrix;
  30798. private _transformMatrix;
  30799. private _frustumPlanes;
  30800. private _refreshFrustumPlanes;
  30801. private _storedFov;
  30802. private _stateStored;
  30803. /**
  30804. * Instantiates a new camera object.
  30805. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30806. * @see http://doc.babylonjs.com/features/cameras
  30807. * @param name Defines the name of the camera in the scene
  30808. * @param position Defines the position of the camera
  30809. * @param scene Defines the scene the camera belongs too
  30810. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30811. */
  30812. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30813. /**
  30814. * Store current camera state (fov, position, etc..)
  30815. * @returns the camera
  30816. */
  30817. storeState(): Camera;
  30818. /**
  30819. * Restores the camera state values if it has been stored. You must call storeState() first
  30820. */
  30821. protected _restoreStateValues(): boolean;
  30822. /**
  30823. * Restored camera state. You must call storeState() first.
  30824. * @returns true if restored and false otherwise
  30825. */
  30826. restoreState(): boolean;
  30827. /**
  30828. * Gets the class name of the camera.
  30829. * @returns the class name
  30830. */
  30831. getClassName(): string;
  30832. /** @hidden */
  30833. readonly _isCamera: boolean;
  30834. /**
  30835. * Gets a string representation of the camera useful for debug purpose.
  30836. * @param fullDetails Defines that a more verboe level of logging is required
  30837. * @returns the string representation
  30838. */
  30839. toString(fullDetails?: boolean): string;
  30840. /**
  30841. * Gets the current world space position of the camera.
  30842. */
  30843. readonly globalPosition: Vector3;
  30844. /**
  30845. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30846. * @returns the active meshe list
  30847. */
  30848. getActiveMeshes(): SmartArray<AbstractMesh>;
  30849. /**
  30850. * Check wether a mesh is part of the current active mesh list of the camera
  30851. * @param mesh Defines the mesh to check
  30852. * @returns true if active, false otherwise
  30853. */
  30854. isActiveMesh(mesh: Mesh): boolean;
  30855. /**
  30856. * Is this camera ready to be used/rendered
  30857. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30858. * @return true if the camera is ready
  30859. */
  30860. isReady(completeCheck?: boolean): boolean;
  30861. /** @hidden */
  30862. _initCache(): void;
  30863. /** @hidden */
  30864. _updateCache(ignoreParentClass?: boolean): void;
  30865. /** @hidden */
  30866. _isSynchronized(): boolean;
  30867. /** @hidden */
  30868. _isSynchronizedViewMatrix(): boolean;
  30869. /** @hidden */
  30870. _isSynchronizedProjectionMatrix(): boolean;
  30871. /**
  30872. * Attach the input controls to a specific dom element to get the input from.
  30873. * @param element Defines the element the controls should be listened from
  30874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30875. */
  30876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30877. /**
  30878. * Detach the current controls from the specified dom element.
  30879. * @param element Defines the element to stop listening the inputs from
  30880. */
  30881. detachControl(element: HTMLElement): void;
  30882. /**
  30883. * Update the camera state according to the different inputs gathered during the frame.
  30884. */
  30885. update(): void;
  30886. /** @hidden */
  30887. _checkInputs(): void;
  30888. /** @hidden */
  30889. readonly rigCameras: Camera[];
  30890. /**
  30891. * Gets the post process used by the rig cameras
  30892. */
  30893. readonly rigPostProcess: Nullable<PostProcess>;
  30894. /**
  30895. * Internal, gets the first post proces.
  30896. * @returns the first post process to be run on this camera.
  30897. */
  30898. _getFirstPostProcess(): Nullable<PostProcess>;
  30899. private _cascadePostProcessesToRigCams;
  30900. /**
  30901. * Attach a post process to the camera.
  30902. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30903. * @param postProcess The post process to attach to the camera
  30904. * @param insertAt The position of the post process in case several of them are in use in the scene
  30905. * @returns the position the post process has been inserted at
  30906. */
  30907. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30908. /**
  30909. * Detach a post process to the camera.
  30910. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30911. * @param postProcess The post process to detach from the camera
  30912. */
  30913. detachPostProcess(postProcess: PostProcess): void;
  30914. /**
  30915. * Gets the current world matrix of the camera
  30916. */
  30917. getWorldMatrix(): Matrix;
  30918. /** @hidden */
  30919. _getViewMatrix(): Matrix;
  30920. /**
  30921. * Gets the current view matrix of the camera.
  30922. * @param force forces the camera to recompute the matrix without looking at the cached state
  30923. * @returns the view matrix
  30924. */
  30925. getViewMatrix(force?: boolean): Matrix;
  30926. /**
  30927. * Freeze the projection matrix.
  30928. * It will prevent the cache check of the camera projection compute and can speed up perf
  30929. * if no parameter of the camera are meant to change
  30930. * @param projection Defines manually a projection if necessary
  30931. */
  30932. freezeProjectionMatrix(projection?: Matrix): void;
  30933. /**
  30934. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30935. */
  30936. unfreezeProjectionMatrix(): void;
  30937. /**
  30938. * Gets the current projection matrix of the camera.
  30939. * @param force forces the camera to recompute the matrix without looking at the cached state
  30940. * @returns the projection matrix
  30941. */
  30942. getProjectionMatrix(force?: boolean): Matrix;
  30943. /**
  30944. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30945. * @returns a Matrix
  30946. */
  30947. getTransformationMatrix(): Matrix;
  30948. private _updateFrustumPlanes;
  30949. /**
  30950. * Checks if a cullable object (mesh...) is in the camera frustum
  30951. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30952. * @param target The object to check
  30953. * @returns true if the object is in frustum otherwise false
  30954. */
  30955. isInFrustum(target: ICullable): boolean;
  30956. /**
  30957. * Checks if a cullable object (mesh...) is in the camera frustum
  30958. * Unlike isInFrustum this cheks the full bounding box
  30959. * @param target The object to check
  30960. * @returns true if the object is in frustum otherwise false
  30961. */
  30962. isCompletelyInFrustum(target: ICullable): boolean;
  30963. /**
  30964. * Gets a ray in the forward direction from the camera.
  30965. * @param length Defines the length of the ray to create
  30966. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30967. * @param origin Defines the start point of the ray which defaults to the camera position
  30968. * @returns the forward ray
  30969. */
  30970. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30971. /**
  30972. * Releases resources associated with this node.
  30973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30975. */
  30976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30977. /** @hidden */
  30978. _isLeftCamera: boolean;
  30979. /**
  30980. * Gets the left camera of a rig setup in case of Rigged Camera
  30981. */
  30982. readonly isLeftCamera: boolean;
  30983. /** @hidden */
  30984. _isRightCamera: boolean;
  30985. /**
  30986. * Gets the right camera of a rig setup in case of Rigged Camera
  30987. */
  30988. readonly isRightCamera: boolean;
  30989. /**
  30990. * Gets the left camera of a rig setup in case of Rigged Camera
  30991. */
  30992. readonly leftCamera: Nullable<FreeCamera>;
  30993. /**
  30994. * Gets the right camera of a rig setup in case of Rigged Camera
  30995. */
  30996. readonly rightCamera: Nullable<FreeCamera>;
  30997. /**
  30998. * Gets the left camera target of a rig setup in case of Rigged Camera
  30999. * @returns the target position
  31000. */
  31001. getLeftTarget(): Nullable<Vector3>;
  31002. /**
  31003. * Gets the right camera target of a rig setup in case of Rigged Camera
  31004. * @returns the target position
  31005. */
  31006. getRightTarget(): Nullable<Vector3>;
  31007. /**
  31008. * @hidden
  31009. */
  31010. setCameraRigMode(mode: number, rigParams: any): void;
  31011. /** @hidden */
  31012. static _setStereoscopicRigMode(camera: Camera): void;
  31013. /** @hidden */
  31014. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31015. /** @hidden */
  31016. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31017. /** @hidden */
  31018. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31019. /** @hidden */
  31020. _getVRProjectionMatrix(): Matrix;
  31021. protected _updateCameraRotationMatrix(): void;
  31022. protected _updateWebVRCameraRotationMatrix(): void;
  31023. /**
  31024. * This function MUST be overwritten by the different WebVR cameras available.
  31025. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31026. * @hidden
  31027. */
  31028. _getWebVRProjectionMatrix(): Matrix;
  31029. /**
  31030. * This function MUST be overwritten by the different WebVR cameras available.
  31031. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31032. * @hidden
  31033. */
  31034. _getWebVRViewMatrix(): Matrix;
  31035. /** @hidden */
  31036. setCameraRigParameter(name: string, value: any): void;
  31037. /**
  31038. * needs to be overridden by children so sub has required properties to be copied
  31039. * @hidden
  31040. */
  31041. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31042. /**
  31043. * May need to be overridden by children
  31044. * @hidden
  31045. */
  31046. _updateRigCameras(): void;
  31047. /** @hidden */
  31048. _setupInputs(): void;
  31049. /**
  31050. * Serialiaze the camera setup to a json represention
  31051. * @returns the JSON representation
  31052. */
  31053. serialize(): any;
  31054. /**
  31055. * Clones the current camera.
  31056. * @param name The cloned camera name
  31057. * @returns the cloned camera
  31058. */
  31059. clone(name: string): Camera;
  31060. /**
  31061. * Gets the direction of the camera relative to a given local axis.
  31062. * @param localAxis Defines the reference axis to provide a relative direction.
  31063. * @return the direction
  31064. */
  31065. getDirection(localAxis: Vector3): Vector3;
  31066. /**
  31067. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31068. * @param localAxis Defines the reference axis to provide a relative direction.
  31069. * @param result Defines the vector to store the result in
  31070. */
  31071. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31072. /**
  31073. * Gets a camera constructor for a given camera type
  31074. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31075. * @param name The name of the camera the result will be able to instantiate
  31076. * @param scene The scene the result will construct the camera in
  31077. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31078. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31079. * @returns a factory method to construc the camera
  31080. */
  31081. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31082. /**
  31083. * Compute the world matrix of the camera.
  31084. * @returns the camera workd matrix
  31085. */
  31086. computeWorldMatrix(): Matrix;
  31087. /**
  31088. * Parse a JSON and creates the camera from the parsed information
  31089. * @param parsedCamera The JSON to parse
  31090. * @param scene The scene to instantiate the camera in
  31091. * @returns the newly constructed camera
  31092. */
  31093. static Parse(parsedCamera: any, scene: Scene): Camera;
  31094. }
  31095. }
  31096. declare module "babylonjs/Misc/tools" {
  31097. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31098. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31099. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31100. import { Observable } from "babylonjs/Misc/observable";
  31101. import { DomManagement } from "babylonjs/Misc/domManagement";
  31102. import { WebRequest } from "babylonjs/Misc/webRequest";
  31103. import { Camera } from "babylonjs/Cameras/camera";
  31104. import { Engine } from "babylonjs/Engines/engine";
  31105. import { Animation } from "babylonjs/Animations/animation";
  31106. /**
  31107. * Interface for any object that can request an animation frame
  31108. */
  31109. export interface ICustomAnimationFrameRequester {
  31110. /**
  31111. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31112. */
  31113. renderFunction?: Function;
  31114. /**
  31115. * Called to request the next frame to render to
  31116. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31117. */
  31118. requestAnimationFrame: Function;
  31119. /**
  31120. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31121. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31122. */
  31123. requestID?: number;
  31124. }
  31125. /**
  31126. * Interface containing an array of animations
  31127. */
  31128. export interface IAnimatable {
  31129. /**
  31130. * Array of animations
  31131. */
  31132. animations: Array<Animation>;
  31133. }
  31134. /** Interface used by value gradients (color, factor, ...) */
  31135. export interface IValueGradient {
  31136. /**
  31137. * Gets or sets the gradient value (between 0 and 1)
  31138. */
  31139. gradient: number;
  31140. }
  31141. /** Class used to store color4 gradient */
  31142. export class ColorGradient implements IValueGradient {
  31143. /**
  31144. * Gets or sets the gradient value (between 0 and 1)
  31145. */
  31146. gradient: number;
  31147. /**
  31148. * Gets or sets first associated color
  31149. */
  31150. color1: Color4;
  31151. /**
  31152. * Gets or sets second associated color
  31153. */
  31154. color2?: Color4;
  31155. /**
  31156. * Will get a color picked randomly between color1 and color2.
  31157. * If color2 is undefined then color1 will be used
  31158. * @param result defines the target Color4 to store the result in
  31159. */
  31160. getColorToRef(result: Color4): void;
  31161. }
  31162. /** Class used to store color 3 gradient */
  31163. export class Color3Gradient implements IValueGradient {
  31164. /**
  31165. * Gets or sets the gradient value (between 0 and 1)
  31166. */
  31167. gradient: number;
  31168. /**
  31169. * Gets or sets the associated color
  31170. */
  31171. color: Color3;
  31172. }
  31173. /** Class used to store factor gradient */
  31174. export class FactorGradient implements IValueGradient {
  31175. /**
  31176. * Gets or sets the gradient value (between 0 and 1)
  31177. */
  31178. gradient: number;
  31179. /**
  31180. * Gets or sets first associated factor
  31181. */
  31182. factor1: number;
  31183. /**
  31184. * Gets or sets second associated factor
  31185. */
  31186. factor2?: number;
  31187. /**
  31188. * Will get a number picked randomly between factor1 and factor2.
  31189. * If factor2 is undefined then factor1 will be used
  31190. * @returns the picked number
  31191. */
  31192. getFactor(): number;
  31193. }
  31194. /**
  31195. * @ignore
  31196. * Application error to support additional information when loading a file
  31197. */
  31198. export class LoadFileError extends Error {
  31199. /** defines the optional web request */
  31200. request?: WebRequest | undefined;
  31201. private static _setPrototypeOf;
  31202. /**
  31203. * Creates a new LoadFileError
  31204. * @param message defines the message of the error
  31205. * @param request defines the optional web request
  31206. */
  31207. constructor(message: string,
  31208. /** defines the optional web request */
  31209. request?: WebRequest | undefined);
  31210. }
  31211. /**
  31212. * Class used to define a retry strategy when error happens while loading assets
  31213. */
  31214. export class RetryStrategy {
  31215. /**
  31216. * Function used to defines an exponential back off strategy
  31217. * @param maxRetries defines the maximum number of retries (3 by default)
  31218. * @param baseInterval defines the interval between retries
  31219. * @returns the strategy function to use
  31220. */
  31221. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31222. }
  31223. /**
  31224. * File request interface
  31225. */
  31226. export interface IFileRequest {
  31227. /**
  31228. * Raised when the request is complete (success or error).
  31229. */
  31230. onCompleteObservable: Observable<IFileRequest>;
  31231. /**
  31232. * Aborts the request for a file.
  31233. */
  31234. abort: () => void;
  31235. }
  31236. /**
  31237. * Class containing a set of static utilities functions
  31238. */
  31239. export class Tools {
  31240. /**
  31241. * Gets or sets the base URL to use to load assets
  31242. */
  31243. static BaseUrl: string;
  31244. /**
  31245. * Enable/Disable Custom HTTP Request Headers globally.
  31246. * default = false
  31247. * @see CustomRequestHeaders
  31248. */
  31249. static UseCustomRequestHeaders: boolean;
  31250. /**
  31251. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31252. * i.e. when loading files, where the server/service expects an Authorization header
  31253. */
  31254. static CustomRequestHeaders: {
  31255. [key: string]: string;
  31256. };
  31257. /**
  31258. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31259. */
  31260. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31261. /**
  31262. * Default behaviour for cors in the application.
  31263. * It can be a string if the expected behavior is identical in the entire app.
  31264. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31265. */
  31266. static CorsBehavior: string | ((url: string | string[]) => string);
  31267. /**
  31268. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31269. * @ignorenaming
  31270. */
  31271. static UseFallbackTexture: boolean;
  31272. /**
  31273. * Use this object to register external classes like custom textures or material
  31274. * to allow the laoders to instantiate them
  31275. */
  31276. static RegisteredExternalClasses: {
  31277. [key: string]: Object;
  31278. };
  31279. /**
  31280. * Texture content used if a texture cannot loaded
  31281. * @ignorenaming
  31282. */
  31283. static fallbackTexture: string;
  31284. /**
  31285. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31286. * @param u defines the coordinate on X axis
  31287. * @param v defines the coordinate on Y axis
  31288. * @param width defines the width of the source data
  31289. * @param height defines the height of the source data
  31290. * @param pixels defines the source byte array
  31291. * @param color defines the output color
  31292. */
  31293. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31294. /**
  31295. * Interpolates between a and b via alpha
  31296. * @param a The lower value (returned when alpha = 0)
  31297. * @param b The upper value (returned when alpha = 1)
  31298. * @param alpha The interpolation-factor
  31299. * @return The mixed value
  31300. */
  31301. static Mix(a: number, b: number, alpha: number): number;
  31302. /**
  31303. * Tries to instantiate a new object from a given class name
  31304. * @param className defines the class name to instantiate
  31305. * @returns the new object or null if the system was not able to do the instantiation
  31306. */
  31307. static Instantiate(className: string): any;
  31308. /**
  31309. * Provides a slice function that will work even on IE
  31310. * @param data defines the array to slice
  31311. * @param start defines the start of the data (optional)
  31312. * @param end defines the end of the data (optional)
  31313. * @returns the new sliced array
  31314. */
  31315. static Slice<T>(data: T, start?: number, end?: number): T;
  31316. /**
  31317. * Polyfill for setImmediate
  31318. * @param action defines the action to execute after the current execution block
  31319. */
  31320. static SetImmediate(action: () => void): void;
  31321. /**
  31322. * Function indicating if a number is an exponent of 2
  31323. * @param value defines the value to test
  31324. * @returns true if the value is an exponent of 2
  31325. */
  31326. static IsExponentOfTwo(value: number): boolean;
  31327. private static _tmpFloatArray;
  31328. /**
  31329. * Returns the nearest 32-bit single precision float representation of a Number
  31330. * @param value A Number. If the parameter is of a different type, it will get converted
  31331. * to a number or to NaN if it cannot be converted
  31332. * @returns number
  31333. */
  31334. static FloatRound(value: number): number;
  31335. /**
  31336. * Find the next highest power of two.
  31337. * @param x Number to start search from.
  31338. * @return Next highest power of two.
  31339. */
  31340. static CeilingPOT(x: number): number;
  31341. /**
  31342. * Find the next lowest power of two.
  31343. * @param x Number to start search from.
  31344. * @return Next lowest power of two.
  31345. */
  31346. static FloorPOT(x: number): number;
  31347. /**
  31348. * Find the nearest power of two.
  31349. * @param x Number to start search from.
  31350. * @return Next nearest power of two.
  31351. */
  31352. static NearestPOT(x: number): number;
  31353. /**
  31354. * Get the closest exponent of two
  31355. * @param value defines the value to approximate
  31356. * @param max defines the maximum value to return
  31357. * @param mode defines how to define the closest value
  31358. * @returns closest exponent of two of the given value
  31359. */
  31360. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31361. /**
  31362. * Extracts the filename from a path
  31363. * @param path defines the path to use
  31364. * @returns the filename
  31365. */
  31366. static GetFilename(path: string): string;
  31367. /**
  31368. * Extracts the "folder" part of a path (everything before the filename).
  31369. * @param uri The URI to extract the info from
  31370. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31371. * @returns The "folder" part of the path
  31372. */
  31373. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31374. /**
  31375. * Extracts text content from a DOM element hierarchy
  31376. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31377. */
  31378. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31379. /**
  31380. * Convert an angle in radians to degrees
  31381. * @param angle defines the angle to convert
  31382. * @returns the angle in degrees
  31383. */
  31384. static ToDegrees(angle: number): number;
  31385. /**
  31386. * Convert an angle in degrees to radians
  31387. * @param angle defines the angle to convert
  31388. * @returns the angle in radians
  31389. */
  31390. static ToRadians(angle: number): number;
  31391. /**
  31392. * Encode a buffer to a base64 string
  31393. * @param buffer defines the buffer to encode
  31394. * @returns the encoded string
  31395. */
  31396. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31397. /**
  31398. * Extracts minimum and maximum values from a list of indexed positions
  31399. * @param positions defines the positions to use
  31400. * @param indices defines the indices to the positions
  31401. * @param indexStart defines the start index
  31402. * @param indexCount defines the end index
  31403. * @param bias defines bias value to add to the result
  31404. * @return minimum and maximum values
  31405. */
  31406. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31407. minimum: Vector3;
  31408. maximum: Vector3;
  31409. };
  31410. /**
  31411. * Extracts minimum and maximum values from a list of positions
  31412. * @param positions defines the positions to use
  31413. * @param start defines the start index in the positions array
  31414. * @param count defines the number of positions to handle
  31415. * @param bias defines bias value to add to the result
  31416. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31417. * @return minimum and maximum values
  31418. */
  31419. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31420. minimum: Vector3;
  31421. maximum: Vector3;
  31422. };
  31423. /**
  31424. * Returns an array if obj is not an array
  31425. * @param obj defines the object to evaluate as an array
  31426. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31427. * @returns either obj directly if obj is an array or a new array containing obj
  31428. */
  31429. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31430. /**
  31431. * Gets the pointer prefix to use
  31432. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31433. */
  31434. static GetPointerPrefix(): string;
  31435. /**
  31436. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31437. * @param func - the function to be called
  31438. * @param requester - the object that will request the next frame. Falls back to window.
  31439. * @returns frame number
  31440. */
  31441. static QueueNewFrame(func: () => void, requester?: any): number;
  31442. /**
  31443. * Ask the browser to promote the current element to fullscreen rendering mode
  31444. * @param element defines the DOM element to promote
  31445. */
  31446. static RequestFullscreen(element: HTMLElement): void;
  31447. /**
  31448. * Asks the browser to exit fullscreen mode
  31449. */
  31450. static ExitFullscreen(): void;
  31451. /**
  31452. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31453. * @param url define the url we are trying
  31454. * @param element define the dom element where to configure the cors policy
  31455. */
  31456. static SetCorsBehavior(url: string | string[], element: {
  31457. crossOrigin: string | null;
  31458. }): void;
  31459. /**
  31460. * Removes unwanted characters from an url
  31461. * @param url defines the url to clean
  31462. * @returns the cleaned url
  31463. */
  31464. static CleanUrl(url: string): string;
  31465. /**
  31466. * Gets or sets a function used to pre-process url before using them to load assets
  31467. */
  31468. static PreprocessUrl: (url: string) => string;
  31469. /**
  31470. * Loads an image as an HTMLImageElement.
  31471. * @param input url string, ArrayBuffer, or Blob to load
  31472. * @param onLoad callback called when the image successfully loads
  31473. * @param onError callback called when the image fails to load
  31474. * @param offlineProvider offline provider for caching
  31475. * @returns the HTMLImageElement of the loaded image
  31476. */
  31477. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31478. /**
  31479. * Loads a file
  31480. * @param url url string, ArrayBuffer, or Blob to load
  31481. * @param onSuccess callback called when the file successfully loads
  31482. * @param onProgress callback called while file is loading (if the server supports this mode)
  31483. * @param offlineProvider defines the offline provider for caching
  31484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31485. * @param onError callback called when the file fails to load
  31486. * @returns a file request object
  31487. */
  31488. 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;
  31489. /**
  31490. * Load a script (identified by an url). When the url returns, the
  31491. * content of this file is added into a new script element, attached to the DOM (body element)
  31492. * @param scriptUrl defines the url of the script to laod
  31493. * @param onSuccess defines the callback called when the script is loaded
  31494. * @param onError defines the callback to call if an error occurs
  31495. */
  31496. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31497. /**
  31498. * Loads a file from a blob
  31499. * @param fileToLoad defines the blob to use
  31500. * @param callback defines the callback to call when data is loaded
  31501. * @param progressCallback defines the callback to call during loading process
  31502. * @returns a file request object
  31503. */
  31504. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31505. /**
  31506. * Loads a file
  31507. * @param fileToLoad defines the file to load
  31508. * @param callback defines the callback to call when data is loaded
  31509. * @param progressCallBack defines the callback to call during loading process
  31510. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31511. * @returns a file request object
  31512. */
  31513. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31514. /**
  31515. * Creates a data url from a given string content
  31516. * @param content defines the content to convert
  31517. * @returns the new data url link
  31518. */
  31519. static FileAsURL(content: string): string;
  31520. /**
  31521. * Format the given number to a specific decimal format
  31522. * @param value defines the number to format
  31523. * @param decimals defines the number of decimals to use
  31524. * @returns the formatted string
  31525. */
  31526. static Format(value: number, decimals?: number): string;
  31527. /**
  31528. * Checks if a given vector is inside a specific range
  31529. * @param v defines the vector to test
  31530. * @param min defines the minimum range
  31531. * @param max defines the maximum range
  31532. */
  31533. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31534. /**
  31535. * Tries to copy an object by duplicating every property
  31536. * @param source defines the source object
  31537. * @param destination defines the target object
  31538. * @param doNotCopyList defines a list of properties to avoid
  31539. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31540. */
  31541. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31542. /**
  31543. * Gets a boolean indicating if the given object has no own property
  31544. * @param obj defines the object to test
  31545. * @returns true if object has no own property
  31546. */
  31547. static IsEmpty(obj: any): boolean;
  31548. /**
  31549. * Function used to register events at window level
  31550. * @param events defines the events to register
  31551. */
  31552. static RegisterTopRootEvents(events: {
  31553. name: string;
  31554. handler: Nullable<(e: FocusEvent) => any>;
  31555. }[]): void;
  31556. /**
  31557. * Function used to unregister events from window level
  31558. * @param events defines the events to unregister
  31559. */
  31560. static UnregisterTopRootEvents(events: {
  31561. name: string;
  31562. handler: Nullable<(e: FocusEvent) => any>;
  31563. }[]): void;
  31564. /**
  31565. * @ignore
  31566. */
  31567. static _ScreenshotCanvas: HTMLCanvasElement;
  31568. /**
  31569. * Dumps the current bound framebuffer
  31570. * @param width defines the rendering width
  31571. * @param height defines the rendering height
  31572. * @param engine defines the hosting engine
  31573. * @param successCallback defines the callback triggered once the data are available
  31574. * @param mimeType defines the mime type of the result
  31575. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31576. */
  31577. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31578. /**
  31579. * Converts the canvas data to blob.
  31580. * This acts as a polyfill for browsers not supporting the to blob function.
  31581. * @param canvas Defines the canvas to extract the data from
  31582. * @param successCallback Defines the callback triggered once the data are available
  31583. * @param mimeType Defines the mime type of the result
  31584. */
  31585. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31586. /**
  31587. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31588. * @param successCallback defines the callback triggered once the data are available
  31589. * @param mimeType defines the mime type of the result
  31590. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31591. */
  31592. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31593. /**
  31594. * Downloads a blob in the browser
  31595. * @param blob defines the blob to download
  31596. * @param fileName defines the name of the downloaded file
  31597. */
  31598. static Download(blob: Blob, fileName: string): void;
  31599. /**
  31600. * Captures a screenshot of the current rendering
  31601. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31602. * @param engine defines the rendering engine
  31603. * @param camera defines the source camera
  31604. * @param size This parameter can be set to a single number or to an object with the
  31605. * following (optional) properties: precision, width, height. If a single number is passed,
  31606. * it will be used for both width and height. If an object is passed, the screenshot size
  31607. * will be derived from the parameters. The precision property is a multiplier allowing
  31608. * rendering at a higher or lower resolution
  31609. * @param successCallback defines the callback receives a single parameter which contains the
  31610. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31611. * src parameter of an <img> to display it
  31612. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31613. * Check your browser for supported MIME types
  31614. */
  31615. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31616. /**
  31617. * Generates an image screenshot from the specified camera.
  31618. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31619. * @param engine The engine to use for rendering
  31620. * @param camera The camera to use for rendering
  31621. * @param size This parameter can be set to a single number or to an object with the
  31622. * following (optional) properties: precision, width, height. If a single number is passed,
  31623. * it will be used for both width and height. If an object is passed, the screenshot size
  31624. * will be derived from the parameters. The precision property is a multiplier allowing
  31625. * rendering at a higher or lower resolution
  31626. * @param successCallback The callback receives a single parameter which contains the
  31627. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31628. * src parameter of an <img> to display it
  31629. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31630. * Check your browser for supported MIME types
  31631. * @param samples Texture samples (default: 1)
  31632. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31633. * @param fileName A name for for the downloaded file.
  31634. */
  31635. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31636. /**
  31637. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31638. * Be aware Math.random() could cause collisions, but:
  31639. * "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"
  31640. * @returns a pseudo random id
  31641. */
  31642. static RandomId(): string;
  31643. /**
  31644. * Test if the given uri is a base64 string
  31645. * @param uri The uri to test
  31646. * @return True if the uri is a base64 string or false otherwise
  31647. */
  31648. static IsBase64(uri: string): boolean;
  31649. /**
  31650. * Decode the given base64 uri.
  31651. * @param uri The uri to decode
  31652. * @return The decoded base64 data.
  31653. */
  31654. static DecodeBase64(uri: string): ArrayBuffer;
  31655. /**
  31656. * No log
  31657. */
  31658. static readonly NoneLogLevel: number;
  31659. /**
  31660. * Only message logs
  31661. */
  31662. static readonly MessageLogLevel: number;
  31663. /**
  31664. * Only warning logs
  31665. */
  31666. static readonly WarningLogLevel: number;
  31667. /**
  31668. * Only error logs
  31669. */
  31670. static readonly ErrorLogLevel: number;
  31671. /**
  31672. * All logs
  31673. */
  31674. static readonly AllLogLevel: number;
  31675. /**
  31676. * Gets a value indicating the number of loading errors
  31677. * @ignorenaming
  31678. */
  31679. static readonly errorsCount: number;
  31680. /**
  31681. * Callback called when a new log is added
  31682. */
  31683. static OnNewCacheEntry: (entry: string) => void;
  31684. /**
  31685. * Log a message to the console
  31686. * @param message defines the message to log
  31687. */
  31688. static Log(message: string): void;
  31689. /**
  31690. * Write a warning message to the console
  31691. * @param message defines the message to log
  31692. */
  31693. static Warn(message: string): void;
  31694. /**
  31695. * Write an error message to the console
  31696. * @param message defines the message to log
  31697. */
  31698. static Error(message: string): void;
  31699. /**
  31700. * Gets current log cache (list of logs)
  31701. */
  31702. static readonly LogCache: string;
  31703. /**
  31704. * Clears the log cache
  31705. */
  31706. static ClearLogCache(): void;
  31707. /**
  31708. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31709. */
  31710. static LogLevels: number;
  31711. /**
  31712. * Checks if the loaded document was accessed via `file:`-Protocol.
  31713. * @returns boolean
  31714. */
  31715. static IsFileURL(): boolean;
  31716. /**
  31717. * Checks if the window object exists
  31718. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31719. */
  31720. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31721. /**
  31722. * No performance log
  31723. */
  31724. static readonly PerformanceNoneLogLevel: number;
  31725. /**
  31726. * Use user marks to log performance
  31727. */
  31728. static readonly PerformanceUserMarkLogLevel: number;
  31729. /**
  31730. * Log performance to the console
  31731. */
  31732. static readonly PerformanceConsoleLogLevel: number;
  31733. private static _performance;
  31734. /**
  31735. * Sets the current performance log level
  31736. */
  31737. static PerformanceLogLevel: number;
  31738. private static _StartPerformanceCounterDisabled;
  31739. private static _EndPerformanceCounterDisabled;
  31740. private static _StartUserMark;
  31741. private static _EndUserMark;
  31742. private static _StartPerformanceConsole;
  31743. private static _EndPerformanceConsole;
  31744. /**
  31745. * Starts a performance counter
  31746. */
  31747. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31748. /**
  31749. * Ends a specific performance coutner
  31750. */
  31751. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31752. /**
  31753. * Gets either window.performance.now() if supported or Date.now() else
  31754. */
  31755. static readonly Now: number;
  31756. /**
  31757. * This method will return the name of the class used to create the instance of the given object.
  31758. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31759. * @param object the object to get the class name from
  31760. * @param isType defines if the object is actually a type
  31761. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31762. */
  31763. static GetClassName(object: any, isType?: boolean): string;
  31764. /**
  31765. * Gets the first element of an array satisfying a given predicate
  31766. * @param array defines the array to browse
  31767. * @param predicate defines the predicate to use
  31768. * @returns null if not found or the element
  31769. */
  31770. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31771. /**
  31772. * This method will return the name of the full name of the class, including its owning module (if any).
  31773. * 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).
  31774. * @param object the object to get the class name from
  31775. * @param isType defines if the object is actually a type
  31776. * @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.
  31777. * @ignorenaming
  31778. */
  31779. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31780. /**
  31781. * Returns a promise that resolves after the given amount of time.
  31782. * @param delay Number of milliseconds to delay
  31783. * @returns Promise that resolves after the given amount of time
  31784. */
  31785. static DelayAsync(delay: number): Promise<void>;
  31786. /**
  31787. * Gets the current gradient from an array of IValueGradient
  31788. * @param ratio defines the current ratio to get
  31789. * @param gradients defines the array of IValueGradient
  31790. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31791. */
  31792. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31793. }
  31794. /**
  31795. * This class is used to track a performance counter which is number based.
  31796. * The user has access to many properties which give statistics of different nature.
  31797. *
  31798. * The implementer can track two kinds of Performance Counter: time and count.
  31799. * 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.
  31800. * 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.
  31801. */
  31802. export class PerfCounter {
  31803. /**
  31804. * Gets or sets a global boolean to turn on and off all the counters
  31805. */
  31806. static Enabled: boolean;
  31807. /**
  31808. * Returns the smallest value ever
  31809. */
  31810. readonly min: number;
  31811. /**
  31812. * Returns the biggest value ever
  31813. */
  31814. readonly max: number;
  31815. /**
  31816. * Returns the average value since the performance counter is running
  31817. */
  31818. readonly average: number;
  31819. /**
  31820. * Returns the average value of the last second the counter was monitored
  31821. */
  31822. readonly lastSecAverage: number;
  31823. /**
  31824. * Returns the current value
  31825. */
  31826. readonly current: number;
  31827. /**
  31828. * Gets the accumulated total
  31829. */
  31830. readonly total: number;
  31831. /**
  31832. * Gets the total value count
  31833. */
  31834. readonly count: number;
  31835. /**
  31836. * Creates a new counter
  31837. */
  31838. constructor();
  31839. /**
  31840. * Call this method to start monitoring a new frame.
  31841. * 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.
  31842. */
  31843. fetchNewFrame(): void;
  31844. /**
  31845. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31846. * @param newCount the count value to add to the monitored count
  31847. * @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.
  31848. */
  31849. addCount(newCount: number, fetchResult: boolean): void;
  31850. /**
  31851. * Start monitoring this performance counter
  31852. */
  31853. beginMonitoring(): void;
  31854. /**
  31855. * Compute the time lapsed since the previous beginMonitoring() call.
  31856. * @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
  31857. */
  31858. endMonitoring(newFrame?: boolean): void;
  31859. private _fetchResult;
  31860. private _startMonitoringTime;
  31861. private _min;
  31862. private _max;
  31863. private _average;
  31864. private _current;
  31865. private _totalValueCount;
  31866. private _totalAccumulated;
  31867. private _lastSecAverage;
  31868. private _lastSecAccumulated;
  31869. private _lastSecTime;
  31870. private _lastSecValueCount;
  31871. }
  31872. /**
  31873. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31874. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31875. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31876. * @param name The name of the class, case should be preserved
  31877. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31878. */
  31879. export function className(name: string, module?: string): (target: Object) => void;
  31880. /**
  31881. * An implementation of a loop for asynchronous functions.
  31882. */
  31883. export class AsyncLoop {
  31884. /**
  31885. * Defines the number of iterations for the loop
  31886. */
  31887. iterations: number;
  31888. /**
  31889. * Defines the current index of the loop.
  31890. */
  31891. index: number;
  31892. private _done;
  31893. private _fn;
  31894. private _successCallback;
  31895. /**
  31896. * Constructor.
  31897. * @param iterations the number of iterations.
  31898. * @param func the function to run each iteration
  31899. * @param successCallback the callback that will be called upon succesful execution
  31900. * @param offset starting offset.
  31901. */
  31902. constructor(
  31903. /**
  31904. * Defines the number of iterations for the loop
  31905. */
  31906. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31907. /**
  31908. * Execute the next iteration. Must be called after the last iteration was finished.
  31909. */
  31910. executeNext(): void;
  31911. /**
  31912. * Break the loop and run the success callback.
  31913. */
  31914. breakLoop(): void;
  31915. /**
  31916. * Create and run an async loop.
  31917. * @param iterations the number of iterations.
  31918. * @param fn the function to run each iteration
  31919. * @param successCallback the callback that will be called upon succesful execution
  31920. * @param offset starting offset.
  31921. * @returns the created async loop object
  31922. */
  31923. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31924. /**
  31925. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31926. * @param iterations total number of iterations
  31927. * @param syncedIterations number of synchronous iterations in each async iteration.
  31928. * @param fn the function to call each iteration.
  31929. * @param callback a success call back that will be called when iterating stops.
  31930. * @param breakFunction a break condition (optional)
  31931. * @param timeout timeout settings for the setTimeout function. default - 0.
  31932. * @returns the created async loop object
  31933. */
  31934. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31935. }
  31936. }
  31937. declare module "babylonjs/Collisions/collisionCoordinator" {
  31938. import { Nullable } from "babylonjs/types";
  31939. import { Scene } from "babylonjs/scene";
  31940. import { Vector3 } from "babylonjs/Maths/math";
  31941. import { Collider } from "babylonjs/Collisions/collider";
  31942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31943. /** @hidden */
  31944. export interface ICollisionCoordinator {
  31945. createCollider(): Collider;
  31946. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31947. init(scene: Scene): void;
  31948. }
  31949. /** @hidden */
  31950. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31951. private _scene;
  31952. private _scaledPosition;
  31953. private _scaledVelocity;
  31954. private _finalPosition;
  31955. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31956. createCollider(): Collider;
  31957. init(scene: Scene): void;
  31958. private _collideWithWorld;
  31959. }
  31960. }
  31961. declare module "babylonjs/Animations/animationGroup" {
  31962. import { Animatable } from "babylonjs/Animations/animatable";
  31963. import { Animation } from "babylonjs/Animations/animation";
  31964. import { Scene, IDisposable } from "babylonjs/scene";
  31965. import { Observable } from "babylonjs/Misc/observable";
  31966. import { Nullable } from "babylonjs/types";
  31967. /**
  31968. * This class defines the direct association between an animation and a target
  31969. */
  31970. export class TargetedAnimation {
  31971. /**
  31972. * Animation to perform
  31973. */
  31974. animation: Animation;
  31975. /**
  31976. * Target to animate
  31977. */
  31978. target: any;
  31979. }
  31980. /**
  31981. * Use this class to create coordinated animations on multiple targets
  31982. */
  31983. export class AnimationGroup implements IDisposable {
  31984. /** The name of the animation group */
  31985. name: string;
  31986. private _scene;
  31987. private _targetedAnimations;
  31988. private _animatables;
  31989. private _from;
  31990. private _to;
  31991. private _isStarted;
  31992. private _isPaused;
  31993. private _speedRatio;
  31994. /**
  31995. * Gets or sets the unique id of the node
  31996. */
  31997. uniqueId: number;
  31998. /**
  31999. * This observable will notify when one animation have ended
  32000. */
  32001. onAnimationEndObservable: Observable<TargetedAnimation>;
  32002. /**
  32003. * Observer raised when one animation loops
  32004. */
  32005. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32006. /**
  32007. * This observable will notify when all animations have ended.
  32008. */
  32009. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32010. /**
  32011. * This observable will notify when all animations have paused.
  32012. */
  32013. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32014. /**
  32015. * This observable will notify when all animations are playing.
  32016. */
  32017. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32018. /**
  32019. * Gets the first frame
  32020. */
  32021. readonly from: number;
  32022. /**
  32023. * Gets the last frame
  32024. */
  32025. readonly to: number;
  32026. /**
  32027. * Define if the animations are started
  32028. */
  32029. readonly isStarted: boolean;
  32030. /**
  32031. * Gets a value indicating that the current group is playing
  32032. */
  32033. readonly isPlaying: boolean;
  32034. /**
  32035. * Gets or sets the speed ratio to use for all animations
  32036. */
  32037. /**
  32038. * Gets or sets the speed ratio to use for all animations
  32039. */
  32040. speedRatio: number;
  32041. /**
  32042. * Gets the targeted animations for this animation group
  32043. */
  32044. readonly targetedAnimations: Array<TargetedAnimation>;
  32045. /**
  32046. * returning the list of animatables controlled by this animation group.
  32047. */
  32048. readonly animatables: Array<Animatable>;
  32049. /**
  32050. * Instantiates a new Animation Group.
  32051. * This helps managing several animations at once.
  32052. * @see http://doc.babylonjs.com/how_to/group
  32053. * @param name Defines the name of the group
  32054. * @param scene Defines the scene the group belongs to
  32055. */
  32056. constructor(
  32057. /** The name of the animation group */
  32058. name: string, scene?: Nullable<Scene>);
  32059. /**
  32060. * Add an animation (with its target) in the group
  32061. * @param animation defines the animation we want to add
  32062. * @param target defines the target of the animation
  32063. * @returns the TargetedAnimation object
  32064. */
  32065. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32066. /**
  32067. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32068. * It can add constant keys at begin or end
  32069. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32070. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32071. * @returns the animation group
  32072. */
  32073. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32074. /**
  32075. * Start all animations on given targets
  32076. * @param loop defines if animations must loop
  32077. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32078. * @param from defines the from key (optional)
  32079. * @param to defines the to key (optional)
  32080. * @returns the current animation group
  32081. */
  32082. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32083. /**
  32084. * Pause all animations
  32085. * @returns the animation group
  32086. */
  32087. pause(): AnimationGroup;
  32088. /**
  32089. * Play all animations to initial state
  32090. * This function will start() the animations if they were not started or will restart() them if they were paused
  32091. * @param loop defines if animations must loop
  32092. * @returns the animation group
  32093. */
  32094. play(loop?: boolean): AnimationGroup;
  32095. /**
  32096. * Reset all animations to initial state
  32097. * @returns the animation group
  32098. */
  32099. reset(): AnimationGroup;
  32100. /**
  32101. * Restart animations from key 0
  32102. * @returns the animation group
  32103. */
  32104. restart(): AnimationGroup;
  32105. /**
  32106. * Stop all animations
  32107. * @returns the animation group
  32108. */
  32109. stop(): AnimationGroup;
  32110. /**
  32111. * Set animation weight for all animatables
  32112. * @param weight defines the weight to use
  32113. * @return the animationGroup
  32114. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32115. */
  32116. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32117. /**
  32118. * Synchronize and normalize all animatables with a source animatable
  32119. * @param root defines the root animatable to synchronize with
  32120. * @return the animationGroup
  32121. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32122. */
  32123. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32124. /**
  32125. * Goes to a specific frame in this animation group
  32126. * @param frame the frame number to go to
  32127. * @return the animationGroup
  32128. */
  32129. goToFrame(frame: number): AnimationGroup;
  32130. /**
  32131. * Dispose all associated resources
  32132. */
  32133. dispose(): void;
  32134. private _checkAnimationGroupEnded;
  32135. /**
  32136. * Clone the current animation group and returns a copy
  32137. * @param newName defines the name of the new group
  32138. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32139. * @returns the new aniamtion group
  32140. */
  32141. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32142. /**
  32143. * Returns a new AnimationGroup object parsed from the source provided.
  32144. * @param parsedAnimationGroup defines the source
  32145. * @param scene defines the scene that will receive the animationGroup
  32146. * @returns a new AnimationGroup
  32147. */
  32148. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32149. /**
  32150. * Returns the string "AnimationGroup"
  32151. * @returns "AnimationGroup"
  32152. */
  32153. getClassName(): string;
  32154. /**
  32155. * Creates a detailled string about the object
  32156. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32157. * @returns a string representing the object
  32158. */
  32159. toString(fullDetails?: boolean): string;
  32160. }
  32161. }
  32162. declare module "babylonjs/scene" {
  32163. import { Nullable } from "babylonjs/types";
  32164. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32165. import { Observable } from "babylonjs/Misc/observable";
  32166. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32167. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32168. import { Geometry } from "babylonjs/Meshes/geometry";
  32169. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32170. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32172. import { Mesh } from "babylonjs/Meshes/mesh";
  32173. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32174. import { Bone } from "babylonjs/Bones/bone";
  32175. import { Skeleton } from "babylonjs/Bones/skeleton";
  32176. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32177. import { Camera } from "babylonjs/Cameras/camera";
  32178. import { AbstractScene } from "babylonjs/abstractScene";
  32179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32181. import { Material } from "babylonjs/Materials/material";
  32182. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32183. import { Effect } from "babylonjs/Materials/effect";
  32184. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32185. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32186. import { Light } from "babylonjs/Lights/light";
  32187. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32188. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32189. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32190. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32191. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32192. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32193. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32194. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32195. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32196. import { Engine } from "babylonjs/Engines/engine";
  32197. import { Node } from "babylonjs/node";
  32198. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32199. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32200. import { WebRequest } from "babylonjs/Misc/webRequest";
  32201. import { Ray } from "babylonjs/Culling/ray";
  32202. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32203. import { Animation } from "babylonjs/Animations/animation";
  32204. import { Animatable } from "babylonjs/Animations/animatable";
  32205. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32206. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32207. import { Collider } from "babylonjs/Collisions/collider";
  32208. /**
  32209. * Define an interface for all classes that will hold resources
  32210. */
  32211. export interface IDisposable {
  32212. /**
  32213. * Releases all held resources
  32214. */
  32215. dispose(): void;
  32216. }
  32217. /** Interface defining initialization parameters for Scene class */
  32218. export interface SceneOptions {
  32219. /**
  32220. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32221. * It will improve performance when the number of geometries becomes important.
  32222. */
  32223. useGeometryUniqueIdsMap?: boolean;
  32224. /**
  32225. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32226. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32227. */
  32228. useMaterialMeshMap?: boolean;
  32229. /**
  32230. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32231. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32232. */
  32233. useClonedMeshhMap?: boolean;
  32234. }
  32235. /**
  32236. * Represents a scene to be rendered by the engine.
  32237. * @see http://doc.babylonjs.com/features/scene
  32238. */
  32239. export class Scene extends AbstractScene implements IAnimatable {
  32240. private static _uniqueIdCounter;
  32241. /** The fog is deactivated */
  32242. static readonly FOGMODE_NONE: number;
  32243. /** The fog density is following an exponential function */
  32244. static readonly FOGMODE_EXP: number;
  32245. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32246. static readonly FOGMODE_EXP2: number;
  32247. /** The fog density is following a linear function. */
  32248. static readonly FOGMODE_LINEAR: number;
  32249. /**
  32250. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32252. */
  32253. static MinDeltaTime: number;
  32254. /**
  32255. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32257. */
  32258. static MaxDeltaTime: number;
  32259. /**
  32260. * Factory used to create the default material.
  32261. * @param name The name of the material to create
  32262. * @param scene The scene to create the material for
  32263. * @returns The default material
  32264. */
  32265. static DefaultMaterialFactory(scene: Scene): Material;
  32266. /**
  32267. * Factory used to create the a collision coordinator.
  32268. * @returns The collision coordinator
  32269. */
  32270. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32271. /** @hidden */
  32272. readonly _isScene: boolean;
  32273. /**
  32274. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32275. */
  32276. autoClear: boolean;
  32277. /**
  32278. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32279. */
  32280. autoClearDepthAndStencil: boolean;
  32281. /**
  32282. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32283. */
  32284. clearColor: Color4;
  32285. /**
  32286. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32287. */
  32288. ambientColor: Color3;
  32289. /** @hidden */
  32290. _environmentBRDFTexture: BaseTexture;
  32291. /** @hidden */
  32292. protected _environmentTexture: Nullable<BaseTexture>;
  32293. /**
  32294. * Texture used in all pbr material as the reflection texture.
  32295. * As in the majority of the scene they are the same (exception for multi room and so on),
  32296. * this is easier to reference from here than from all the materials.
  32297. */
  32298. /**
  32299. * Texture used in all pbr material as the reflection texture.
  32300. * As in the majority of the scene they are the same (exception for multi room and so on),
  32301. * this is easier to set here than in all the materials.
  32302. */
  32303. environmentTexture: Nullable<BaseTexture>;
  32304. /** @hidden */
  32305. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32306. /**
  32307. * Default image processing configuration used either in the rendering
  32308. * Forward main pass or through the imageProcessingPostProcess if present.
  32309. * As in the majority of the scene they are the same (exception for multi camera),
  32310. * this is easier to reference from here than from all the materials and post process.
  32311. *
  32312. * No setter as we it is a shared configuration, you can set the values instead.
  32313. */
  32314. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32315. private _forceWireframe;
  32316. /**
  32317. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32318. */
  32319. forceWireframe: boolean;
  32320. private _forcePointsCloud;
  32321. /**
  32322. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32323. */
  32324. forcePointsCloud: boolean;
  32325. /**
  32326. * Gets or sets the active clipplane 1
  32327. */
  32328. clipPlane: Nullable<Plane>;
  32329. /**
  32330. * Gets or sets the active clipplane 2
  32331. */
  32332. clipPlane2: Nullable<Plane>;
  32333. /**
  32334. * Gets or sets the active clipplane 3
  32335. */
  32336. clipPlane3: Nullable<Plane>;
  32337. /**
  32338. * Gets or sets the active clipplane 4
  32339. */
  32340. clipPlane4: Nullable<Plane>;
  32341. /**
  32342. * Gets or sets a boolean indicating if animations are enabled
  32343. */
  32344. animationsEnabled: boolean;
  32345. private _animationPropertiesOverride;
  32346. /**
  32347. * Gets or sets the animation properties override
  32348. */
  32349. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32350. /**
  32351. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32352. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32353. */
  32354. useConstantAnimationDeltaTime: boolean;
  32355. /**
  32356. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32357. * Please note that it requires to run a ray cast through the scene on every frame
  32358. */
  32359. constantlyUpdateMeshUnderPointer: boolean;
  32360. /**
  32361. * Defines the HTML cursor to use when hovering over interactive elements
  32362. */
  32363. hoverCursor: string;
  32364. /**
  32365. * Defines the HTML default cursor to use (empty by default)
  32366. */
  32367. defaultCursor: string;
  32368. /**
  32369. * This is used to call preventDefault() on pointer down
  32370. * in order to block unwanted artifacts like system double clicks
  32371. */
  32372. preventDefaultOnPointerDown: boolean;
  32373. /**
  32374. * This is used to call preventDefault() on pointer up
  32375. * in order to block unwanted artifacts like system double clicks
  32376. */
  32377. preventDefaultOnPointerUp: boolean;
  32378. /**
  32379. * Gets or sets user defined metadata
  32380. */
  32381. metadata: any;
  32382. /**
  32383. * For internal use only. Please do not use.
  32384. */
  32385. reservedDataStore: any;
  32386. /**
  32387. * Gets the name of the plugin used to load this scene (null by default)
  32388. */
  32389. loadingPluginName: string;
  32390. /**
  32391. * Use this array to add regular expressions used to disable offline support for specific urls
  32392. */
  32393. disableOfflineSupportExceptionRules: RegExp[];
  32394. /**
  32395. * An event triggered when the scene is disposed.
  32396. */
  32397. onDisposeObservable: Observable<Scene>;
  32398. private _onDisposeObserver;
  32399. /** Sets a function to be executed when this scene is disposed. */
  32400. onDispose: () => void;
  32401. /**
  32402. * An event triggered before rendering the scene (right after animations and physics)
  32403. */
  32404. onBeforeRenderObservable: Observable<Scene>;
  32405. private _onBeforeRenderObserver;
  32406. /** Sets a function to be executed before rendering this scene */
  32407. beforeRender: Nullable<() => void>;
  32408. /**
  32409. * An event triggered after rendering the scene
  32410. */
  32411. onAfterRenderObservable: Observable<Scene>;
  32412. private _onAfterRenderObserver;
  32413. /** Sets a function to be executed after rendering this scene */
  32414. afterRender: Nullable<() => void>;
  32415. /**
  32416. * An event triggered before animating the scene
  32417. */
  32418. onBeforeAnimationsObservable: Observable<Scene>;
  32419. /**
  32420. * An event triggered after animations processing
  32421. */
  32422. onAfterAnimationsObservable: Observable<Scene>;
  32423. /**
  32424. * An event triggered before draw calls are ready to be sent
  32425. */
  32426. onBeforeDrawPhaseObservable: Observable<Scene>;
  32427. /**
  32428. * An event triggered after draw calls have been sent
  32429. */
  32430. onAfterDrawPhaseObservable: Observable<Scene>;
  32431. /**
  32432. * An event triggered when the scene is ready
  32433. */
  32434. onReadyObservable: Observable<Scene>;
  32435. /**
  32436. * An event triggered before rendering a camera
  32437. */
  32438. onBeforeCameraRenderObservable: Observable<Camera>;
  32439. private _onBeforeCameraRenderObserver;
  32440. /** Sets a function to be executed before rendering a camera*/
  32441. beforeCameraRender: () => void;
  32442. /**
  32443. * An event triggered after rendering a camera
  32444. */
  32445. onAfterCameraRenderObservable: Observable<Camera>;
  32446. private _onAfterCameraRenderObserver;
  32447. /** Sets a function to be executed after rendering a camera*/
  32448. afterCameraRender: () => void;
  32449. /**
  32450. * An event triggered when active meshes evaluation is about to start
  32451. */
  32452. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32453. /**
  32454. * An event triggered when active meshes evaluation is done
  32455. */
  32456. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32457. /**
  32458. * An event triggered when particles rendering is about to start
  32459. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32460. */
  32461. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32462. /**
  32463. * An event triggered when particles rendering is done
  32464. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32465. */
  32466. onAfterParticlesRenderingObservable: Observable<Scene>;
  32467. /**
  32468. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32469. */
  32470. onDataLoadedObservable: Observable<Scene>;
  32471. /**
  32472. * An event triggered when a camera is created
  32473. */
  32474. onNewCameraAddedObservable: Observable<Camera>;
  32475. /**
  32476. * An event triggered when a camera is removed
  32477. */
  32478. onCameraRemovedObservable: Observable<Camera>;
  32479. /**
  32480. * An event triggered when a light is created
  32481. */
  32482. onNewLightAddedObservable: Observable<Light>;
  32483. /**
  32484. * An event triggered when a light is removed
  32485. */
  32486. onLightRemovedObservable: Observable<Light>;
  32487. /**
  32488. * An event triggered when a geometry is created
  32489. */
  32490. onNewGeometryAddedObservable: Observable<Geometry>;
  32491. /**
  32492. * An event triggered when a geometry is removed
  32493. */
  32494. onGeometryRemovedObservable: Observable<Geometry>;
  32495. /**
  32496. * An event triggered when a transform node is created
  32497. */
  32498. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32499. /**
  32500. * An event triggered when a transform node is removed
  32501. */
  32502. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32503. /**
  32504. * An event triggered when a mesh is created
  32505. */
  32506. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32507. /**
  32508. * An event triggered when a mesh is removed
  32509. */
  32510. onMeshRemovedObservable: Observable<AbstractMesh>;
  32511. /**
  32512. * An event triggered when a skeleton is created
  32513. */
  32514. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32515. /**
  32516. * An event triggered when a skeleton is removed
  32517. */
  32518. onSkeletonRemovedObservable: Observable<Skeleton>;
  32519. /**
  32520. * An event triggered when a material is created
  32521. */
  32522. onNewMaterialAddedObservable: Observable<Material>;
  32523. /**
  32524. * An event triggered when a material is removed
  32525. */
  32526. onMaterialRemovedObservable: Observable<Material>;
  32527. /**
  32528. * An event triggered when a texture is created
  32529. */
  32530. onNewTextureAddedObservable: Observable<BaseTexture>;
  32531. /**
  32532. * An event triggered when a texture is removed
  32533. */
  32534. onTextureRemovedObservable: Observable<BaseTexture>;
  32535. /**
  32536. * An event triggered when render targets are about to be rendered
  32537. * Can happen multiple times per frame.
  32538. */
  32539. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32540. /**
  32541. * An event triggered when render targets were rendered.
  32542. * Can happen multiple times per frame.
  32543. */
  32544. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32545. /**
  32546. * An event triggered before calculating deterministic simulation step
  32547. */
  32548. onBeforeStepObservable: Observable<Scene>;
  32549. /**
  32550. * An event triggered after calculating deterministic simulation step
  32551. */
  32552. onAfterStepObservable: Observable<Scene>;
  32553. /**
  32554. * An event triggered when the activeCamera property is updated
  32555. */
  32556. onActiveCameraChanged: Observable<Scene>;
  32557. /**
  32558. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32559. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32560. * 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)
  32561. */
  32562. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32563. /**
  32564. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32565. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32566. * 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)
  32567. */
  32568. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32569. /**
  32570. * This Observable will when a mesh has been imported into the scene.
  32571. */
  32572. onMeshImportedObservable: Observable<AbstractMesh>;
  32573. /**
  32574. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32575. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32576. */
  32577. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32578. /** @hidden */
  32579. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32580. /**
  32581. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32582. */
  32583. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32584. /**
  32585. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32586. */
  32587. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32588. /**
  32589. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32590. */
  32591. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32592. private _onPointerMove;
  32593. private _onPointerDown;
  32594. private _onPointerUp;
  32595. /** Callback called when a pointer move is detected */
  32596. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32597. /** Callback called when a pointer down is detected */
  32598. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32599. /** Callback called when a pointer up is detected */
  32600. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32601. /** Callback called when a pointer pick is detected */
  32602. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32603. /**
  32604. * 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).
  32605. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32606. */
  32607. onPrePointerObservable: Observable<PointerInfoPre>;
  32608. /**
  32609. * Observable event triggered each time an input event is received from the rendering canvas
  32610. */
  32611. onPointerObservable: Observable<PointerInfo>;
  32612. /**
  32613. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32614. */
  32615. readonly unTranslatedPointer: Vector2;
  32616. /** The distance in pixel that you have to move to prevent some events */
  32617. static DragMovementThreshold: number;
  32618. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32619. static LongPressDelay: number;
  32620. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32621. static DoubleClickDelay: number;
  32622. /** If you need to check double click without raising a single click at first click, enable this flag */
  32623. static ExclusiveDoubleClickMode: boolean;
  32624. private _initClickEvent;
  32625. private _initActionManager;
  32626. private _delayedSimpleClick;
  32627. private _delayedSimpleClickTimeout;
  32628. private _previousDelayedSimpleClickTimeout;
  32629. private _meshPickProceed;
  32630. private _previousButtonPressed;
  32631. private _currentPickResult;
  32632. private _previousPickResult;
  32633. private _totalPointersPressed;
  32634. private _doubleClickOccured;
  32635. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32636. cameraToUseForPointers: Nullable<Camera>;
  32637. private _pointerX;
  32638. private _pointerY;
  32639. private _unTranslatedPointerX;
  32640. private _unTranslatedPointerY;
  32641. private _startingPointerPosition;
  32642. private _previousStartingPointerPosition;
  32643. private _startingPointerTime;
  32644. private _previousStartingPointerTime;
  32645. private _pointerCaptures;
  32646. private _timeAccumulator;
  32647. private _currentStepId;
  32648. private _currentInternalStep;
  32649. /** @hidden */
  32650. _mirroredCameraPosition: Nullable<Vector3>;
  32651. /**
  32652. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32653. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32654. */
  32655. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32656. /**
  32657. * Observable event triggered each time an keyboard event is received from the hosting window
  32658. */
  32659. onKeyboardObservable: Observable<KeyboardInfo>;
  32660. private _onKeyDown;
  32661. private _onKeyUp;
  32662. private _onCanvasFocusObserver;
  32663. private _onCanvasBlurObserver;
  32664. private _useRightHandedSystem;
  32665. /**
  32666. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32667. */
  32668. useRightHandedSystem: boolean;
  32669. /**
  32670. * Sets the step Id used by deterministic lock step
  32671. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32672. * @param newStepId defines the step Id
  32673. */
  32674. setStepId(newStepId: number): void;
  32675. /**
  32676. * Gets the step Id used by deterministic lock step
  32677. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32678. * @returns the step Id
  32679. */
  32680. getStepId(): number;
  32681. /**
  32682. * Gets the internal step used by deterministic lock step
  32683. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32684. * @returns the internal step
  32685. */
  32686. getInternalStep(): number;
  32687. private _fogEnabled;
  32688. /**
  32689. * Gets or sets a boolean indicating if fog is enabled on this scene
  32690. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32691. * (Default is true)
  32692. */
  32693. fogEnabled: boolean;
  32694. private _fogMode;
  32695. /**
  32696. * Gets or sets the fog mode to use
  32697. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32698. * | mode | value |
  32699. * | --- | --- |
  32700. * | FOGMODE_NONE | 0 |
  32701. * | FOGMODE_EXP | 1 |
  32702. * | FOGMODE_EXP2 | 2 |
  32703. * | FOGMODE_LINEAR | 3 |
  32704. */
  32705. fogMode: number;
  32706. /**
  32707. * Gets or sets the fog color to use
  32708. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32709. * (Default is Color3(0.2, 0.2, 0.3))
  32710. */
  32711. fogColor: Color3;
  32712. /**
  32713. * Gets or sets the fog density to use
  32714. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32715. * (Default is 0.1)
  32716. */
  32717. fogDensity: number;
  32718. /**
  32719. * Gets or sets the fog start distance to use
  32720. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32721. * (Default is 0)
  32722. */
  32723. fogStart: number;
  32724. /**
  32725. * Gets or sets the fog end distance to use
  32726. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32727. * (Default is 1000)
  32728. */
  32729. fogEnd: number;
  32730. private _shadowsEnabled;
  32731. /**
  32732. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32733. */
  32734. shadowsEnabled: boolean;
  32735. private _lightsEnabled;
  32736. /**
  32737. * Gets or sets a boolean indicating if lights are enabled on this scene
  32738. */
  32739. lightsEnabled: boolean;
  32740. /** All of the active cameras added to this scene. */
  32741. activeCameras: Camera[];
  32742. private _activeCamera;
  32743. /** Gets or sets the current active camera */
  32744. activeCamera: Nullable<Camera>;
  32745. private _defaultMaterial;
  32746. /** The default material used on meshes when no material is affected */
  32747. /** The default material used on meshes when no material is affected */
  32748. defaultMaterial: Material;
  32749. private _texturesEnabled;
  32750. /**
  32751. * Gets or sets a boolean indicating if textures are enabled on this scene
  32752. */
  32753. texturesEnabled: boolean;
  32754. /**
  32755. * Gets or sets a boolean indicating if particles are enabled on this scene
  32756. */
  32757. particlesEnabled: boolean;
  32758. /**
  32759. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32760. */
  32761. spritesEnabled: boolean;
  32762. private _skeletonsEnabled;
  32763. /**
  32764. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32765. */
  32766. skeletonsEnabled: boolean;
  32767. /**
  32768. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32769. */
  32770. lensFlaresEnabled: boolean;
  32771. /**
  32772. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32773. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32774. */
  32775. collisionsEnabled: boolean;
  32776. private _collisionCoordinator;
  32777. /** @hidden */
  32778. readonly collisionCoordinator: ICollisionCoordinator;
  32779. /**
  32780. * Defines the gravity applied to this scene (used only for collisions)
  32781. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32782. */
  32783. gravity: Vector3;
  32784. /**
  32785. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32786. */
  32787. postProcessesEnabled: boolean;
  32788. /**
  32789. * The list of postprocesses added to the scene
  32790. */
  32791. postProcesses: PostProcess[];
  32792. /**
  32793. * Gets the current postprocess manager
  32794. */
  32795. postProcessManager: PostProcessManager;
  32796. /**
  32797. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32798. */
  32799. renderTargetsEnabled: boolean;
  32800. /**
  32801. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32802. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32803. */
  32804. dumpNextRenderTargets: boolean;
  32805. /**
  32806. * The list of user defined render targets added to the scene
  32807. */
  32808. customRenderTargets: RenderTargetTexture[];
  32809. /**
  32810. * Defines if texture loading must be delayed
  32811. * If true, textures will only be loaded when they need to be rendered
  32812. */
  32813. useDelayedTextureLoading: boolean;
  32814. /**
  32815. * Gets the list of meshes imported to the scene through SceneLoader
  32816. */
  32817. importedMeshesFiles: String[];
  32818. /**
  32819. * Gets or sets a boolean indicating if probes are enabled on this scene
  32820. */
  32821. probesEnabled: boolean;
  32822. /**
  32823. * Gets or sets the current offline provider to use to store scene data
  32824. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32825. */
  32826. offlineProvider: IOfflineProvider;
  32827. /**
  32828. * Gets or sets the action manager associated with the scene
  32829. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32830. */
  32831. actionManager: AbstractActionManager;
  32832. private _meshesForIntersections;
  32833. /**
  32834. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32835. */
  32836. proceduralTexturesEnabled: boolean;
  32837. private _engine;
  32838. private _totalVertices;
  32839. /** @hidden */
  32840. _activeIndices: PerfCounter;
  32841. /** @hidden */
  32842. _activeParticles: PerfCounter;
  32843. /** @hidden */
  32844. _activeBones: PerfCounter;
  32845. private _animationRatio;
  32846. /** @hidden */
  32847. _animationTimeLast: number;
  32848. /** @hidden */
  32849. _animationTime: number;
  32850. /**
  32851. * Gets or sets a general scale for animation speed
  32852. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32853. */
  32854. animationTimeScale: number;
  32855. /** @hidden */
  32856. _cachedMaterial: Nullable<Material>;
  32857. /** @hidden */
  32858. _cachedEffect: Nullable<Effect>;
  32859. /** @hidden */
  32860. _cachedVisibility: Nullable<number>;
  32861. private _renderId;
  32862. private _frameId;
  32863. private _executeWhenReadyTimeoutId;
  32864. private _intermediateRendering;
  32865. private _viewUpdateFlag;
  32866. private _projectionUpdateFlag;
  32867. private _alternateViewUpdateFlag;
  32868. private _alternateProjectionUpdateFlag;
  32869. /** @hidden */
  32870. _toBeDisposed: Nullable<IDisposable>[];
  32871. private _activeRequests;
  32872. /** @hidden */
  32873. _pendingData: any[];
  32874. private _isDisposed;
  32875. /**
  32876. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32877. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32878. */
  32879. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32880. private _activeMeshes;
  32881. private _processedMaterials;
  32882. private _renderTargets;
  32883. /** @hidden */
  32884. _activeParticleSystems: SmartArray<IParticleSystem>;
  32885. private _activeSkeletons;
  32886. private _softwareSkinnedMeshes;
  32887. private _renderingManager;
  32888. /** @hidden */
  32889. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32890. private _transformMatrix;
  32891. private _sceneUbo;
  32892. private _alternateSceneUbo;
  32893. private _viewMatrix;
  32894. private _projectionMatrix;
  32895. private _alternateViewMatrix;
  32896. private _alternateProjectionMatrix;
  32897. private _alternateTransformMatrix;
  32898. private _useAlternateCameraConfiguration;
  32899. private _alternateRendering;
  32900. private _wheelEventName;
  32901. /** @hidden */
  32902. _forcedViewPosition: Nullable<Vector3>;
  32903. /** @hidden */
  32904. readonly _isAlternateRenderingEnabled: boolean;
  32905. private _frustumPlanes;
  32906. /**
  32907. * Gets the list of frustum planes (built from the active camera)
  32908. */
  32909. readonly frustumPlanes: Plane[];
  32910. /**
  32911. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32912. * This is useful if there are more lights that the maximum simulteanous authorized
  32913. */
  32914. requireLightSorting: boolean;
  32915. /** @hidden */
  32916. readonly useMaterialMeshMap: boolean;
  32917. /** @hidden */
  32918. readonly useClonedMeshhMap: boolean;
  32919. private _pointerOverMesh;
  32920. private _pickedDownMesh;
  32921. private _pickedUpMesh;
  32922. private _externalData;
  32923. private _uid;
  32924. /**
  32925. * @hidden
  32926. * Backing store of defined scene components.
  32927. */
  32928. _components: ISceneComponent[];
  32929. /**
  32930. * @hidden
  32931. * Backing store of defined scene components.
  32932. */
  32933. _serializableComponents: ISceneSerializableComponent[];
  32934. /**
  32935. * List of components to register on the next registration step.
  32936. */
  32937. private _transientComponents;
  32938. /**
  32939. * Registers the transient components if needed.
  32940. */
  32941. private _registerTransientComponents;
  32942. /**
  32943. * @hidden
  32944. * Add a component to the scene.
  32945. * Note that the ccomponent could be registered on th next frame if this is called after
  32946. * the register component stage.
  32947. * @param component Defines the component to add to the scene
  32948. */
  32949. _addComponent(component: ISceneComponent): void;
  32950. /**
  32951. * @hidden
  32952. * Gets a component from the scene.
  32953. * @param name defines the name of the component to retrieve
  32954. * @returns the component or null if not present
  32955. */
  32956. _getComponent(name: string): Nullable<ISceneComponent>;
  32957. /**
  32958. * @hidden
  32959. * Defines the actions happening before camera updates.
  32960. */
  32961. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32962. /**
  32963. * @hidden
  32964. * Defines the actions happening before clear the canvas.
  32965. */
  32966. _beforeClearStage: Stage<SimpleStageAction>;
  32967. /**
  32968. * @hidden
  32969. * Defines the actions when collecting render targets for the frame.
  32970. */
  32971. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32972. /**
  32973. * @hidden
  32974. * Defines the actions happening for one camera in the frame.
  32975. */
  32976. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32977. /**
  32978. * @hidden
  32979. * Defines the actions happening during the per mesh ready checks.
  32980. */
  32981. _isReadyForMeshStage: Stage<MeshStageAction>;
  32982. /**
  32983. * @hidden
  32984. * Defines the actions happening before evaluate active mesh checks.
  32985. */
  32986. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32987. /**
  32988. * @hidden
  32989. * Defines the actions happening during the evaluate sub mesh checks.
  32990. */
  32991. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32992. /**
  32993. * @hidden
  32994. * Defines the actions happening during the active mesh stage.
  32995. */
  32996. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32997. /**
  32998. * @hidden
  32999. * Defines the actions happening during the per camera render target step.
  33000. */
  33001. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  33002. /**
  33003. * @hidden
  33004. * Defines the actions happening just before the active camera is drawing.
  33005. */
  33006. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33007. /**
  33008. * @hidden
  33009. * Defines the actions happening just before a render target is drawing.
  33010. */
  33011. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33012. /**
  33013. * @hidden
  33014. * Defines the actions happening just before a rendering group is drawing.
  33015. */
  33016. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33017. /**
  33018. * @hidden
  33019. * Defines the actions happening just before a mesh is drawing.
  33020. */
  33021. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33022. /**
  33023. * @hidden
  33024. * Defines the actions happening just after a mesh has been drawn.
  33025. */
  33026. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33027. /**
  33028. * @hidden
  33029. * Defines the actions happening just after a rendering group has been drawn.
  33030. */
  33031. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33032. /**
  33033. * @hidden
  33034. * Defines the actions happening just after the active camera has been drawn.
  33035. */
  33036. _afterCameraDrawStage: Stage<CameraStageAction>;
  33037. /**
  33038. * @hidden
  33039. * Defines the actions happening just after a render target has been drawn.
  33040. */
  33041. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33042. /**
  33043. * @hidden
  33044. * Defines the actions happening just after rendering all cameras and computing intersections.
  33045. */
  33046. _afterRenderStage: Stage<SimpleStageAction>;
  33047. /**
  33048. * @hidden
  33049. * Defines the actions happening when a pointer move event happens.
  33050. */
  33051. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33052. /**
  33053. * @hidden
  33054. * Defines the actions happening when a pointer down event happens.
  33055. */
  33056. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33057. /**
  33058. * @hidden
  33059. * Defines the actions happening when a pointer up event happens.
  33060. */
  33061. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33062. /**
  33063. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33064. */
  33065. private geometriesByUniqueId;
  33066. /**
  33067. * Creates a new Scene
  33068. * @param engine defines the engine to use to render this scene
  33069. * @param options defines the scene options
  33070. */
  33071. constructor(engine: Engine, options?: SceneOptions);
  33072. private _defaultMeshCandidates;
  33073. /**
  33074. * @hidden
  33075. */
  33076. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33077. private _defaultSubMeshCandidates;
  33078. /**
  33079. * @hidden
  33080. */
  33081. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33082. /**
  33083. * Sets the default candidate providers for the scene.
  33084. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33085. * and getCollidingSubMeshCandidates to their default function
  33086. */
  33087. setDefaultCandidateProviders(): void;
  33088. /**
  33089. * Gets the mesh that is currently under the pointer
  33090. */
  33091. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33092. /**
  33093. * Gets or sets the current on-screen X position of the pointer
  33094. */
  33095. pointerX: number;
  33096. /**
  33097. * Gets or sets the current on-screen Y position of the pointer
  33098. */
  33099. pointerY: number;
  33100. /**
  33101. * Gets the cached material (ie. the latest rendered one)
  33102. * @returns the cached material
  33103. */
  33104. getCachedMaterial(): Nullable<Material>;
  33105. /**
  33106. * Gets the cached effect (ie. the latest rendered one)
  33107. * @returns the cached effect
  33108. */
  33109. getCachedEffect(): Nullable<Effect>;
  33110. /**
  33111. * Gets the cached visibility state (ie. the latest rendered one)
  33112. * @returns the cached visibility state
  33113. */
  33114. getCachedVisibility(): Nullable<number>;
  33115. /**
  33116. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33117. * @param material defines the current material
  33118. * @param effect defines the current effect
  33119. * @param visibility defines the current visibility state
  33120. * @returns true if one parameter is not cached
  33121. */
  33122. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33123. /**
  33124. * Gets the engine associated with the scene
  33125. * @returns an Engine
  33126. */
  33127. getEngine(): Engine;
  33128. /**
  33129. * Gets the total number of vertices rendered per frame
  33130. * @returns the total number of vertices rendered per frame
  33131. */
  33132. getTotalVertices(): number;
  33133. /**
  33134. * Gets the performance counter for total vertices
  33135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33136. */
  33137. readonly totalVerticesPerfCounter: PerfCounter;
  33138. /**
  33139. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33140. * @returns the total number of active indices rendered per frame
  33141. */
  33142. getActiveIndices(): number;
  33143. /**
  33144. * Gets the performance counter for active indices
  33145. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33146. */
  33147. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33148. /**
  33149. * Gets the total number of active particles rendered per frame
  33150. * @returns the total number of active particles rendered per frame
  33151. */
  33152. getActiveParticles(): number;
  33153. /**
  33154. * Gets the performance counter for active particles
  33155. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33156. */
  33157. readonly activeParticlesPerfCounter: PerfCounter;
  33158. /**
  33159. * Gets the total number of active bones rendered per frame
  33160. * @returns the total number of active bones rendered per frame
  33161. */
  33162. getActiveBones(): number;
  33163. /**
  33164. * Gets the performance counter for active bones
  33165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33166. */
  33167. readonly activeBonesPerfCounter: PerfCounter;
  33168. /**
  33169. * Gets the array of active meshes
  33170. * @returns an array of AbstractMesh
  33171. */
  33172. getActiveMeshes(): SmartArray<AbstractMesh>;
  33173. /**
  33174. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33175. * @returns a number
  33176. */
  33177. getAnimationRatio(): number;
  33178. /**
  33179. * Gets an unique Id for the current render phase
  33180. * @returns a number
  33181. */
  33182. getRenderId(): number;
  33183. /**
  33184. * Gets an unique Id for the current frame
  33185. * @returns a number
  33186. */
  33187. getFrameId(): number;
  33188. /** Call this function if you want to manually increment the render Id*/
  33189. incrementRenderId(): void;
  33190. private _updatePointerPosition;
  33191. private _createUbo;
  33192. private _createAlternateUbo;
  33193. private _setRayOnPointerInfo;
  33194. /**
  33195. * Use this method to simulate a pointer move on a mesh
  33196. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33197. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33198. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33199. * @returns the current scene
  33200. */
  33201. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33202. private _processPointerMove;
  33203. private _checkPrePointerObservable;
  33204. /**
  33205. * Use this method to simulate a pointer down on a mesh
  33206. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33207. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33208. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33209. * @returns the current scene
  33210. */
  33211. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33212. private _processPointerDown;
  33213. /**
  33214. * Use this method to simulate a pointer up on a mesh
  33215. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33216. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33217. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33218. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33219. * @returns the current scene
  33220. */
  33221. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33222. private _processPointerUp;
  33223. /**
  33224. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33225. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33226. * @returns true if the pointer was captured
  33227. */
  33228. isPointerCaptured(pointerId?: number): boolean;
  33229. /** @hidden */
  33230. _isPointerSwiping(): boolean;
  33231. /**
  33232. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33233. * @param attachUp defines if you want to attach events to pointerup
  33234. * @param attachDown defines if you want to attach events to pointerdown
  33235. * @param attachMove defines if you want to attach events to pointermove
  33236. */
  33237. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33238. /** Detaches all event handlers*/
  33239. detachControl(): void;
  33240. /**
  33241. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33242. * Delay loaded resources are not taking in account
  33243. * @return true if all required resources are ready
  33244. */
  33245. isReady(): boolean;
  33246. /** Resets all cached information relative to material (including effect and visibility) */
  33247. resetCachedMaterial(): void;
  33248. /**
  33249. * Registers a function to be called before every frame render
  33250. * @param func defines the function to register
  33251. */
  33252. registerBeforeRender(func: () => void): void;
  33253. /**
  33254. * Unregisters a function called before every frame render
  33255. * @param func defines the function to unregister
  33256. */
  33257. unregisterBeforeRender(func: () => void): void;
  33258. /**
  33259. * Registers a function to be called after every frame render
  33260. * @param func defines the function to register
  33261. */
  33262. registerAfterRender(func: () => void): void;
  33263. /**
  33264. * Unregisters a function called after every frame render
  33265. * @param func defines the function to unregister
  33266. */
  33267. unregisterAfterRender(func: () => void): void;
  33268. private _executeOnceBeforeRender;
  33269. /**
  33270. * The provided function will run before render once and will be disposed afterwards.
  33271. * A timeout delay can be provided so that the function will be executed in N ms.
  33272. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33273. * @param func The function to be executed.
  33274. * @param timeout optional delay in ms
  33275. */
  33276. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33277. /** @hidden */
  33278. _addPendingData(data: any): void;
  33279. /** @hidden */
  33280. _removePendingData(data: any): void;
  33281. /**
  33282. * Returns the number of items waiting to be loaded
  33283. * @returns the number of items waiting to be loaded
  33284. */
  33285. getWaitingItemsCount(): number;
  33286. /**
  33287. * Returns a boolean indicating if the scene is still loading data
  33288. */
  33289. readonly isLoading: boolean;
  33290. /**
  33291. * Registers a function to be executed when the scene is ready
  33292. * @param {Function} func - the function to be executed
  33293. */
  33294. executeWhenReady(func: () => void): void;
  33295. /**
  33296. * Returns a promise that resolves when the scene is ready
  33297. * @returns A promise that resolves when the scene is ready
  33298. */
  33299. whenReadyAsync(): Promise<void>;
  33300. /** @hidden */
  33301. _checkIsReady(): void;
  33302. /**
  33303. * Gets all animatable attached to the scene
  33304. */
  33305. readonly animatables: Animatable[];
  33306. /**
  33307. * Resets the last animation time frame.
  33308. * Useful to override when animations start running when loading a scene for the first time.
  33309. */
  33310. resetLastAnimationTimeFrame(): void;
  33311. /** @hidden */
  33312. _switchToAlternateCameraConfiguration(active: boolean): void;
  33313. /**
  33314. * Gets the current view matrix
  33315. * @returns a Matrix
  33316. */
  33317. getViewMatrix(): Matrix;
  33318. /**
  33319. * Gets the current projection matrix
  33320. * @returns a Matrix
  33321. */
  33322. getProjectionMatrix(): Matrix;
  33323. /**
  33324. * Gets the current transform matrix
  33325. * @returns a Matrix made of View * Projection
  33326. */
  33327. getTransformMatrix(): Matrix;
  33328. /**
  33329. * Sets the current transform matrix
  33330. * @param view defines the View matrix to use
  33331. * @param projection defines the Projection matrix to use
  33332. */
  33333. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33334. /** @hidden */
  33335. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33336. /**
  33337. * Gets the uniform buffer used to store scene data
  33338. * @returns a UniformBuffer
  33339. */
  33340. getSceneUniformBuffer(): UniformBuffer;
  33341. /**
  33342. * Gets an unique (relatively to the current scene) Id
  33343. * @returns an unique number for the scene
  33344. */
  33345. getUniqueId(): number;
  33346. /**
  33347. * Add a mesh to the list of scene's meshes
  33348. * @param newMesh defines the mesh to add
  33349. * @param recursive if all child meshes should also be added to the scene
  33350. */
  33351. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33352. /**
  33353. * Remove a mesh for the list of scene's meshes
  33354. * @param toRemove defines the mesh to remove
  33355. * @param recursive if all child meshes should also be removed from the scene
  33356. * @returns the index where the mesh was in the mesh list
  33357. */
  33358. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33359. /**
  33360. * Add a transform node to the list of scene's transform nodes
  33361. * @param newTransformNode defines the transform node to add
  33362. */
  33363. addTransformNode(newTransformNode: TransformNode): void;
  33364. /**
  33365. * Remove a transform node for the list of scene's transform nodes
  33366. * @param toRemove defines the transform node to remove
  33367. * @returns the index where the transform node was in the transform node list
  33368. */
  33369. removeTransformNode(toRemove: TransformNode): number;
  33370. /**
  33371. * Remove a skeleton for the list of scene's skeletons
  33372. * @param toRemove defines the skeleton to remove
  33373. * @returns the index where the skeleton was in the skeleton list
  33374. */
  33375. removeSkeleton(toRemove: Skeleton): number;
  33376. /**
  33377. * Remove a morph target for the list of scene's morph targets
  33378. * @param toRemove defines the morph target to remove
  33379. * @returns the index where the morph target was in the morph target list
  33380. */
  33381. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33382. /**
  33383. * Remove a light for the list of scene's lights
  33384. * @param toRemove defines the light to remove
  33385. * @returns the index where the light was in the light list
  33386. */
  33387. removeLight(toRemove: Light): number;
  33388. /**
  33389. * Remove a camera for the list of scene's cameras
  33390. * @param toRemove defines the camera to remove
  33391. * @returns the index where the camera was in the camera list
  33392. */
  33393. removeCamera(toRemove: Camera): number;
  33394. /**
  33395. * Remove a particle system for the list of scene's particle systems
  33396. * @param toRemove defines the particle system to remove
  33397. * @returns the index where the particle system was in the particle system list
  33398. */
  33399. removeParticleSystem(toRemove: IParticleSystem): number;
  33400. /**
  33401. * Remove a animation for the list of scene's animations
  33402. * @param toRemove defines the animation to remove
  33403. * @returns the index where the animation was in the animation list
  33404. */
  33405. removeAnimation(toRemove: Animation): number;
  33406. /**
  33407. * Removes the given animation group from this scene.
  33408. * @param toRemove The animation group to remove
  33409. * @returns The index of the removed animation group
  33410. */
  33411. removeAnimationGroup(toRemove: AnimationGroup): number;
  33412. /**
  33413. * Removes the given multi-material from this scene.
  33414. * @param toRemove The multi-material to remove
  33415. * @returns The index of the removed multi-material
  33416. */
  33417. removeMultiMaterial(toRemove: MultiMaterial): number;
  33418. /**
  33419. * Removes the given material from this scene.
  33420. * @param toRemove The material to remove
  33421. * @returns The index of the removed material
  33422. */
  33423. removeMaterial(toRemove: Material): number;
  33424. /**
  33425. * Removes the given action manager from this scene.
  33426. * @param toRemove The action manager to remove
  33427. * @returns The index of the removed action manager
  33428. */
  33429. removeActionManager(toRemove: AbstractActionManager): number;
  33430. /**
  33431. * Removes the given texture from this scene.
  33432. * @param toRemove The texture to remove
  33433. * @returns The index of the removed texture
  33434. */
  33435. removeTexture(toRemove: BaseTexture): number;
  33436. /**
  33437. * Adds the given light to this scene
  33438. * @param newLight The light to add
  33439. */
  33440. addLight(newLight: Light): void;
  33441. /**
  33442. * Sorts the list list based on light priorities
  33443. */
  33444. sortLightsByPriority(): void;
  33445. /**
  33446. * Adds the given camera to this scene
  33447. * @param newCamera The camera to add
  33448. */
  33449. addCamera(newCamera: Camera): void;
  33450. /**
  33451. * Adds the given skeleton to this scene
  33452. * @param newSkeleton The skeleton to add
  33453. */
  33454. addSkeleton(newSkeleton: Skeleton): void;
  33455. /**
  33456. * Adds the given particle system to this scene
  33457. * @param newParticleSystem The particle system to add
  33458. */
  33459. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33460. /**
  33461. * Adds the given animation to this scene
  33462. * @param newAnimation The animation to add
  33463. */
  33464. addAnimation(newAnimation: Animation): void;
  33465. /**
  33466. * Adds the given animation group to this scene.
  33467. * @param newAnimationGroup The animation group to add
  33468. */
  33469. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33470. /**
  33471. * Adds the given multi-material to this scene
  33472. * @param newMultiMaterial The multi-material to add
  33473. */
  33474. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33475. /**
  33476. * Adds the given material to this scene
  33477. * @param newMaterial The material to add
  33478. */
  33479. addMaterial(newMaterial: Material): void;
  33480. /**
  33481. * Adds the given morph target to this scene
  33482. * @param newMorphTargetManager The morph target to add
  33483. */
  33484. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33485. /**
  33486. * Adds the given geometry to this scene
  33487. * @param newGeometry The geometry to add
  33488. */
  33489. addGeometry(newGeometry: Geometry): void;
  33490. /**
  33491. * Adds the given action manager to this scene
  33492. * @param newActionManager The action manager to add
  33493. */
  33494. addActionManager(newActionManager: AbstractActionManager): void;
  33495. /**
  33496. * Adds the given texture to this scene.
  33497. * @param newTexture The texture to add
  33498. */
  33499. addTexture(newTexture: BaseTexture): void;
  33500. /**
  33501. * Switch active camera
  33502. * @param newCamera defines the new active camera
  33503. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33504. */
  33505. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33506. /**
  33507. * sets the active camera of the scene using its ID
  33508. * @param id defines the camera's ID
  33509. * @return the new active camera or null if none found.
  33510. */
  33511. setActiveCameraByID(id: string): Nullable<Camera>;
  33512. /**
  33513. * sets the active camera of the scene using its name
  33514. * @param name defines the camera's name
  33515. * @returns the new active camera or null if none found.
  33516. */
  33517. setActiveCameraByName(name: string): Nullable<Camera>;
  33518. /**
  33519. * get an animation group using its name
  33520. * @param name defines the material's name
  33521. * @return the animation group or null if none found.
  33522. */
  33523. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33524. /**
  33525. * Get a material using its unique id
  33526. * @param uniqueId defines the material's unique id
  33527. * @return the material or null if none found.
  33528. */
  33529. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33530. /**
  33531. * get a material using its id
  33532. * @param id defines the material's ID
  33533. * @return the material or null if none found.
  33534. */
  33535. getMaterialByID(id: string): Nullable<Material>;
  33536. /**
  33537. * Gets a material using its name
  33538. * @param name defines the material's name
  33539. * @return the material or null if none found.
  33540. */
  33541. getMaterialByName(name: string): Nullable<Material>;
  33542. /**
  33543. * Gets a camera using its id
  33544. * @param id defines the id to look for
  33545. * @returns the camera or null if not found
  33546. */
  33547. getCameraByID(id: string): Nullable<Camera>;
  33548. /**
  33549. * Gets a camera using its unique id
  33550. * @param uniqueId defines the unique id to look for
  33551. * @returns the camera or null if not found
  33552. */
  33553. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33554. /**
  33555. * Gets a camera using its name
  33556. * @param name defines the camera's name
  33557. * @return the camera or null if none found.
  33558. */
  33559. getCameraByName(name: string): Nullable<Camera>;
  33560. /**
  33561. * Gets a bone using its id
  33562. * @param id defines the bone's id
  33563. * @return the bone or null if not found
  33564. */
  33565. getBoneByID(id: string): Nullable<Bone>;
  33566. /**
  33567. * Gets a bone using its id
  33568. * @param name defines the bone's name
  33569. * @return the bone or null if not found
  33570. */
  33571. getBoneByName(name: string): Nullable<Bone>;
  33572. /**
  33573. * Gets a light node using its name
  33574. * @param name defines the the light's name
  33575. * @return the light or null if none found.
  33576. */
  33577. getLightByName(name: string): Nullable<Light>;
  33578. /**
  33579. * Gets a light node using its id
  33580. * @param id defines the light's id
  33581. * @return the light or null if none found.
  33582. */
  33583. getLightByID(id: string): Nullable<Light>;
  33584. /**
  33585. * Gets a light node using its scene-generated unique ID
  33586. * @param uniqueId defines the light's unique id
  33587. * @return the light or null if none found.
  33588. */
  33589. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33590. /**
  33591. * Gets a particle system by id
  33592. * @param id defines the particle system id
  33593. * @return the corresponding system or null if none found
  33594. */
  33595. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33596. /**
  33597. * Gets a geometry using its ID
  33598. * @param id defines the geometry's id
  33599. * @return the geometry or null if none found.
  33600. */
  33601. getGeometryByID(id: string): Nullable<Geometry>;
  33602. private _getGeometryByUniqueID;
  33603. /**
  33604. * Add a new geometry to this scene
  33605. * @param geometry defines the geometry to be added to the scene.
  33606. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33607. * @return a boolean defining if the geometry was added or not
  33608. */
  33609. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33610. /**
  33611. * Removes an existing geometry
  33612. * @param geometry defines the geometry to be removed from the scene
  33613. * @return a boolean defining if the geometry was removed or not
  33614. */
  33615. removeGeometry(geometry: Geometry): boolean;
  33616. /**
  33617. * Gets the list of geometries attached to the scene
  33618. * @returns an array of Geometry
  33619. */
  33620. getGeometries(): Geometry[];
  33621. /**
  33622. * Gets the first added mesh found of a given ID
  33623. * @param id defines the id to search for
  33624. * @return the mesh found or null if not found at all
  33625. */
  33626. getMeshByID(id: string): Nullable<AbstractMesh>;
  33627. /**
  33628. * Gets a list of meshes using their id
  33629. * @param id defines the id to search for
  33630. * @returns a list of meshes
  33631. */
  33632. getMeshesByID(id: string): Array<AbstractMesh>;
  33633. /**
  33634. * Gets the first added transform node found of a given ID
  33635. * @param id defines the id to search for
  33636. * @return the found transform node or null if not found at all.
  33637. */
  33638. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33639. /**
  33640. * Gets a transform node with its auto-generated unique id
  33641. * @param uniqueId efines the unique id to search for
  33642. * @return the found transform node or null if not found at all.
  33643. */
  33644. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33645. /**
  33646. * Gets a list of transform nodes using their id
  33647. * @param id defines the id to search for
  33648. * @returns a list of transform nodes
  33649. */
  33650. getTransformNodesByID(id: string): Array<TransformNode>;
  33651. /**
  33652. * Gets a mesh with its auto-generated unique id
  33653. * @param uniqueId defines the unique id to search for
  33654. * @return the found mesh or null if not found at all.
  33655. */
  33656. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33657. /**
  33658. * Gets a the last added mesh using a given id
  33659. * @param id defines the id to search for
  33660. * @return the found mesh or null if not found at all.
  33661. */
  33662. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33663. /**
  33664. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33665. * @param id defines the id to search for
  33666. * @return the found node or null if not found at all
  33667. */
  33668. getLastEntryByID(id: string): Nullable<Node>;
  33669. /**
  33670. * Gets a node (Mesh, Camera, Light) using a given id
  33671. * @param id defines the id to search for
  33672. * @return the found node or null if not found at all
  33673. */
  33674. getNodeByID(id: string): Nullable<Node>;
  33675. /**
  33676. * Gets a node (Mesh, Camera, Light) using a given name
  33677. * @param name defines the name to search for
  33678. * @return the found node or null if not found at all.
  33679. */
  33680. getNodeByName(name: string): Nullable<Node>;
  33681. /**
  33682. * Gets a mesh using a given name
  33683. * @param name defines the name to search for
  33684. * @return the found mesh or null if not found at all.
  33685. */
  33686. getMeshByName(name: string): Nullable<AbstractMesh>;
  33687. /**
  33688. * Gets a transform node using a given name
  33689. * @param name defines the name to search for
  33690. * @return the found transform node or null if not found at all.
  33691. */
  33692. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33693. /**
  33694. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33695. * @param id defines the id to search for
  33696. * @return the found skeleton or null if not found at all.
  33697. */
  33698. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33699. /**
  33700. * Gets a skeleton using a given auto generated unique id
  33701. * @param uniqueId defines the unique id to search for
  33702. * @return the found skeleton or null if not found at all.
  33703. */
  33704. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33705. /**
  33706. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33707. * @param id defines the id to search for
  33708. * @return the found skeleton or null if not found at all.
  33709. */
  33710. getSkeletonById(id: string): Nullable<Skeleton>;
  33711. /**
  33712. * Gets a skeleton using a given name
  33713. * @param name defines the name to search for
  33714. * @return the found skeleton or null if not found at all.
  33715. */
  33716. getSkeletonByName(name: string): Nullable<Skeleton>;
  33717. /**
  33718. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33719. * @param id defines the id to search for
  33720. * @return the found morph target manager or null if not found at all.
  33721. */
  33722. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33723. /**
  33724. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33725. * @param id defines the id to search for
  33726. * @return the found morph target or null if not found at all.
  33727. */
  33728. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33729. /**
  33730. * Gets a boolean indicating if the given mesh is active
  33731. * @param mesh defines the mesh to look for
  33732. * @returns true if the mesh is in the active list
  33733. */
  33734. isActiveMesh(mesh: AbstractMesh): boolean;
  33735. /**
  33736. * Return a unique id as a string which can serve as an identifier for the scene
  33737. */
  33738. readonly uid: string;
  33739. /**
  33740. * Add an externaly attached data from its key.
  33741. * This method call will fail and return false, if such key already exists.
  33742. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33743. * @param key the unique key that identifies the data
  33744. * @param data the data object to associate to the key for this Engine instance
  33745. * @return true if no such key were already present and the data was added successfully, false otherwise
  33746. */
  33747. addExternalData<T>(key: string, data: T): boolean;
  33748. /**
  33749. * Get an externaly attached data from its key
  33750. * @param key the unique key that identifies the data
  33751. * @return the associated data, if present (can be null), or undefined if not present
  33752. */
  33753. getExternalData<T>(key: string): Nullable<T>;
  33754. /**
  33755. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33756. * @param key the unique key that identifies the data
  33757. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33758. * @return the associated data, can be null if the factory returned null.
  33759. */
  33760. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33761. /**
  33762. * Remove an externaly attached data from the Engine instance
  33763. * @param key the unique key that identifies the data
  33764. * @return true if the data was successfully removed, false if it doesn't exist
  33765. */
  33766. removeExternalData(key: string): boolean;
  33767. private _evaluateSubMesh;
  33768. /**
  33769. * Clear the processed materials smart array preventing retention point in material dispose.
  33770. */
  33771. freeProcessedMaterials(): void;
  33772. private _preventFreeActiveMeshesAndRenderingGroups;
  33773. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33774. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33775. * when disposing several meshes in a row or a hierarchy of meshes.
  33776. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33777. */
  33778. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33779. /**
  33780. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33781. */
  33782. freeActiveMeshes(): void;
  33783. /**
  33784. * Clear the info related to rendering groups preventing retention points during dispose.
  33785. */
  33786. freeRenderingGroups(): void;
  33787. /** @hidden */
  33788. _isInIntermediateRendering(): boolean;
  33789. /**
  33790. * Lambda returning the list of potentially active meshes.
  33791. */
  33792. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33793. /**
  33794. * Lambda returning the list of potentially active sub meshes.
  33795. */
  33796. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33797. /**
  33798. * Lambda returning the list of potentially intersecting sub meshes.
  33799. */
  33800. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33801. /**
  33802. * Lambda returning the list of potentially colliding sub meshes.
  33803. */
  33804. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33805. private _activeMeshesFrozen;
  33806. /**
  33807. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33808. * @returns the current scene
  33809. */
  33810. freezeActiveMeshes(): Scene;
  33811. /**
  33812. * Use this function to restart evaluating active meshes on every frame
  33813. * @returns the current scene
  33814. */
  33815. unfreezeActiveMeshes(): Scene;
  33816. private _evaluateActiveMeshes;
  33817. private _activeMesh;
  33818. /**
  33819. * Update the transform matrix to update from the current active camera
  33820. * @param force defines a boolean used to force the update even if cache is up to date
  33821. */
  33822. updateTransformMatrix(force?: boolean): void;
  33823. /**
  33824. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  33825. * @param alternateCamera defines the camera to use
  33826. */
  33827. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33828. /** @hidden */
  33829. _allowPostProcessClearColor: boolean;
  33830. private _renderForCamera;
  33831. private _processSubCameras;
  33832. private _checkIntersections;
  33833. /** @hidden */
  33834. _advancePhysicsEngineStep(step: number): void;
  33835. /**
  33836. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33837. */
  33838. getDeterministicFrameTime: () => number;
  33839. /** @hidden */
  33840. _animate(): void;
  33841. /**
  33842. * Render the scene
  33843. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33844. */
  33845. render(updateCameras?: boolean): void;
  33846. /**
  33847. * Freeze all materials
  33848. * A frozen material will not be updatable but should be faster to render
  33849. */
  33850. freezeMaterials(): void;
  33851. /**
  33852. * Unfreeze all materials
  33853. * A frozen material will not be updatable but should be faster to render
  33854. */
  33855. unfreezeMaterials(): void;
  33856. /**
  33857. * Releases all held ressources
  33858. */
  33859. dispose(): void;
  33860. /**
  33861. * Gets if the scene is already disposed
  33862. */
  33863. readonly isDisposed: boolean;
  33864. /**
  33865. * Call this function to reduce memory footprint of the scene.
  33866. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33867. */
  33868. clearCachedVertexData(): void;
  33869. /**
  33870. * This function will remove the local cached buffer data from texture.
  33871. * It will save memory but will prevent the texture from being rebuilt
  33872. */
  33873. cleanCachedTextureBuffer(): void;
  33874. /**
  33875. * Get the world extend vectors with an optional filter
  33876. *
  33877. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33878. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33879. */
  33880. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33881. min: Vector3;
  33882. max: Vector3;
  33883. };
  33884. /**
  33885. * Creates a ray that can be used to pick in the scene
  33886. * @param x defines the x coordinate of the origin (on-screen)
  33887. * @param y defines the y coordinate of the origin (on-screen)
  33888. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33889. * @param camera defines the camera to use for the picking
  33890. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33891. * @returns a Ray
  33892. */
  33893. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33894. /**
  33895. * Creates a ray that can be used to pick in the scene
  33896. * @param x defines the x coordinate of the origin (on-screen)
  33897. * @param y defines the y coordinate of the origin (on-screen)
  33898. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33899. * @param result defines the ray where to store the picking ray
  33900. * @param camera defines the camera to use for the picking
  33901. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33902. * @returns the current scene
  33903. */
  33904. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33905. /**
  33906. * Creates a ray that can be used to pick in the scene
  33907. * @param x defines the x coordinate of the origin (on-screen)
  33908. * @param y defines the y coordinate of the origin (on-screen)
  33909. * @param camera defines the camera to use for the picking
  33910. * @returns a Ray
  33911. */
  33912. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33913. /**
  33914. * Creates a ray that can be used to pick in the scene
  33915. * @param x defines the x coordinate of the origin (on-screen)
  33916. * @param y defines the y coordinate of the origin (on-screen)
  33917. * @param result defines the ray where to store the picking ray
  33918. * @param camera defines the camera to use for the picking
  33919. * @returns the current scene
  33920. */
  33921. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33922. /** Launch a ray to try to pick a mesh in the scene
  33923. * @param x position on screen
  33924. * @param y position on screen
  33925. * @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
  33926. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33927. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33928. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33929. * @returns a PickingInfo
  33930. */
  33931. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33932. /** Use the given ray to pick a mesh in the scene
  33933. * @param ray The ray to use to pick meshes
  33934. * @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
  33935. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33936. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33937. * @returns a PickingInfo
  33938. */
  33939. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33940. /**
  33941. * Launch a ray to try to pick a mesh in the scene
  33942. * @param x X position on screen
  33943. * @param y Y position on screen
  33944. * @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
  33945. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33946. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33947. * @returns an array of PickingInfo
  33948. */
  33949. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33950. /**
  33951. * Launch a ray to try to pick a mesh in the scene
  33952. * @param ray Ray to use
  33953. * @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
  33954. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33955. * @returns an array of PickingInfo
  33956. */
  33957. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33958. /**
  33959. * Force the value of meshUnderPointer
  33960. * @param mesh defines the mesh to use
  33961. */
  33962. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33963. /**
  33964. * Gets the mesh under the pointer
  33965. * @returns a Mesh or null if no mesh is under the pointer
  33966. */
  33967. getPointerOverMesh(): Nullable<AbstractMesh>;
  33968. /** @hidden */
  33969. _rebuildGeometries(): void;
  33970. /** @hidden */
  33971. _rebuildTextures(): void;
  33972. private _getByTags;
  33973. /**
  33974. * Get a list of meshes by tags
  33975. * @param tagsQuery defines the tags query to use
  33976. * @param forEach defines a predicate used to filter results
  33977. * @returns an array of Mesh
  33978. */
  33979. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33980. /**
  33981. * Get a list of cameras by tags
  33982. * @param tagsQuery defines the tags query to use
  33983. * @param forEach defines a predicate used to filter results
  33984. * @returns an array of Camera
  33985. */
  33986. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33987. /**
  33988. * Get a list of lights by tags
  33989. * @param tagsQuery defines the tags query to use
  33990. * @param forEach defines a predicate used to filter results
  33991. * @returns an array of Light
  33992. */
  33993. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33994. /**
  33995. * Get a list of materials by tags
  33996. * @param tagsQuery defines the tags query to use
  33997. * @param forEach defines a predicate used to filter results
  33998. * @returns an array of Material
  33999. */
  34000. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34001. /**
  34002. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34003. * This allowed control for front to back rendering or reversly depending of the special needs.
  34004. *
  34005. * @param renderingGroupId The rendering group id corresponding to its index
  34006. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34007. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34008. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34009. */
  34010. 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;
  34011. /**
  34012. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34013. *
  34014. * @param renderingGroupId The rendering group id corresponding to its index
  34015. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34016. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34017. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34018. */
  34019. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34020. /**
  34021. * Gets the current auto clear configuration for one rendering group of the rendering
  34022. * manager.
  34023. * @param index the rendering group index to get the information for
  34024. * @returns The auto clear setup for the requested rendering group
  34025. */
  34026. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34027. private _blockMaterialDirtyMechanism;
  34028. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34029. blockMaterialDirtyMechanism: boolean;
  34030. /**
  34031. * Will flag all materials as dirty to trigger new shader compilation
  34032. * @param flag defines the flag used to specify which material part must be marked as dirty
  34033. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34034. */
  34035. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34036. /** @hidden */
  34037. _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;
  34038. /** @hidden */
  34039. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34040. }
  34041. }
  34042. declare module "babylonjs/assetContainer" {
  34043. import { AbstractScene } from "babylonjs/abstractScene";
  34044. import { Scene } from "babylonjs/scene";
  34045. import { Mesh } from "babylonjs/Meshes/mesh";
  34046. /**
  34047. * Set of assets to keep when moving a scene into an asset container.
  34048. */
  34049. export class KeepAssets extends AbstractScene {
  34050. }
  34051. /**
  34052. * Container with a set of assets that can be added or removed from a scene.
  34053. */
  34054. export class AssetContainer extends AbstractScene {
  34055. /**
  34056. * The scene the AssetContainer belongs to.
  34057. */
  34058. scene: Scene;
  34059. /**
  34060. * Instantiates an AssetContainer.
  34061. * @param scene The scene the AssetContainer belongs to.
  34062. */
  34063. constructor(scene: Scene);
  34064. /**
  34065. * Adds all the assets from the container to the scene.
  34066. */
  34067. addAllToScene(): void;
  34068. /**
  34069. * Removes all the assets in the container from the scene
  34070. */
  34071. removeAllFromScene(): void;
  34072. /**
  34073. * Disposes all the assets in the container
  34074. */
  34075. dispose(): void;
  34076. private _moveAssets;
  34077. /**
  34078. * Removes all the assets contained in the scene and adds them to the container.
  34079. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34080. */
  34081. moveAllFromScene(keepAssets?: KeepAssets): void;
  34082. /**
  34083. * 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.
  34084. * @returns the root mesh
  34085. */
  34086. createRootMesh(): Mesh;
  34087. }
  34088. }
  34089. declare module "babylonjs/abstractScene" {
  34090. import { Scene } from "babylonjs/scene";
  34091. import { Nullable } from "babylonjs/types";
  34092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34093. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34094. import { Geometry } from "babylonjs/Meshes/geometry";
  34095. import { Skeleton } from "babylonjs/Bones/skeleton";
  34096. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34097. import { AssetContainer } from "babylonjs/assetContainer";
  34098. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34099. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34101. import { Material } from "babylonjs/Materials/material";
  34102. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34103. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34104. import { Camera } from "babylonjs/Cameras/camera";
  34105. import { Light } from "babylonjs/Lights/light";
  34106. import { Node } from "babylonjs/node";
  34107. import { Animation } from "babylonjs/Animations/animation";
  34108. /**
  34109. * Defines how the parser contract is defined.
  34110. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34111. */
  34112. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34113. /**
  34114. * Defines how the individual parser contract is defined.
  34115. * These parser can parse an individual asset
  34116. */
  34117. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34118. /**
  34119. * Base class of the scene acting as a container for the different elements composing a scene.
  34120. * This class is dynamically extended by the different components of the scene increasing
  34121. * flexibility and reducing coupling
  34122. */
  34123. export abstract class AbstractScene {
  34124. /**
  34125. * Stores the list of available parsers in the application.
  34126. */
  34127. private static _BabylonFileParsers;
  34128. /**
  34129. * Stores the list of available individual parsers in the application.
  34130. */
  34131. private static _IndividualBabylonFileParsers;
  34132. /**
  34133. * Adds a parser in the list of available ones
  34134. * @param name Defines the name of the parser
  34135. * @param parser Defines the parser to add
  34136. */
  34137. static AddParser(name: string, parser: BabylonFileParser): void;
  34138. /**
  34139. * Gets a general parser from the list of avaialble ones
  34140. * @param name Defines the name of the parser
  34141. * @returns the requested parser or null
  34142. */
  34143. static GetParser(name: string): Nullable<BabylonFileParser>;
  34144. /**
  34145. * Adds n individual parser in the list of available ones
  34146. * @param name Defines the name of the parser
  34147. * @param parser Defines the parser to add
  34148. */
  34149. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34150. /**
  34151. * Gets an individual parser from the list of avaialble ones
  34152. * @param name Defines the name of the parser
  34153. * @returns the requested parser or null
  34154. */
  34155. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34156. /**
  34157. * Parser json data and populate both a scene and its associated container object
  34158. * @param jsonData Defines the data to parse
  34159. * @param scene Defines the scene to parse the data for
  34160. * @param container Defines the container attached to the parsing sequence
  34161. * @param rootUrl Defines the root url of the data
  34162. */
  34163. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34164. /**
  34165. * Gets the list of root nodes (ie. nodes with no parent)
  34166. */
  34167. rootNodes: Node[];
  34168. /** All of the cameras added to this scene
  34169. * @see http://doc.babylonjs.com/babylon101/cameras
  34170. */
  34171. cameras: Camera[];
  34172. /**
  34173. * All of the lights added to this scene
  34174. * @see http://doc.babylonjs.com/babylon101/lights
  34175. */
  34176. lights: Light[];
  34177. /**
  34178. * All of the (abstract) meshes added to this scene
  34179. */
  34180. meshes: AbstractMesh[];
  34181. /**
  34182. * The list of skeletons added to the scene
  34183. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34184. */
  34185. skeletons: Skeleton[];
  34186. /**
  34187. * All of the particle systems added to this scene
  34188. * @see http://doc.babylonjs.com/babylon101/particles
  34189. */
  34190. particleSystems: IParticleSystem[];
  34191. /**
  34192. * Gets a list of Animations associated with the scene
  34193. */
  34194. animations: Animation[];
  34195. /**
  34196. * All of the animation groups added to this scene
  34197. * @see http://doc.babylonjs.com/how_to/group
  34198. */
  34199. animationGroups: AnimationGroup[];
  34200. /**
  34201. * All of the multi-materials added to this scene
  34202. * @see http://doc.babylonjs.com/how_to/multi_materials
  34203. */
  34204. multiMaterials: MultiMaterial[];
  34205. /**
  34206. * All of the materials added to this scene
  34207. * In the context of a Scene, it is not supposed to be modified manually.
  34208. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34209. * Note also that the order of the Material wihin the array is not significant and might change.
  34210. * @see http://doc.babylonjs.com/babylon101/materials
  34211. */
  34212. materials: Material[];
  34213. /**
  34214. * The list of morph target managers added to the scene
  34215. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34216. */
  34217. morphTargetManagers: MorphTargetManager[];
  34218. /**
  34219. * The list of geometries used in the scene.
  34220. */
  34221. geometries: Geometry[];
  34222. /**
  34223. * All of the tranform nodes added to this scene
  34224. * In the context of a Scene, it is not supposed to be modified manually.
  34225. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34226. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34227. * @see http://doc.babylonjs.com/how_to/transformnode
  34228. */
  34229. transformNodes: TransformNode[];
  34230. /**
  34231. * ActionManagers available on the scene.
  34232. */
  34233. actionManagers: AbstractActionManager[];
  34234. /**
  34235. * Textures to keep.
  34236. */
  34237. textures: BaseTexture[];
  34238. }
  34239. }
  34240. declare module "babylonjs/Audio/sound" {
  34241. import { Observable } from "babylonjs/Misc/observable";
  34242. import { Vector3 } from "babylonjs/Maths/math";
  34243. import { Nullable } from "babylonjs/types";
  34244. import { Scene } from "babylonjs/scene";
  34245. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34246. /**
  34247. * Defines a sound that can be played in the application.
  34248. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34250. */
  34251. export class Sound {
  34252. /**
  34253. * The name of the sound in the scene.
  34254. */
  34255. name: string;
  34256. /**
  34257. * Does the sound autoplay once loaded.
  34258. */
  34259. autoplay: boolean;
  34260. /**
  34261. * Does the sound loop after it finishes playing once.
  34262. */
  34263. loop: boolean;
  34264. /**
  34265. * Does the sound use a custom attenuation curve to simulate the falloff
  34266. * happening when the source gets further away from the camera.
  34267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34268. */
  34269. useCustomAttenuation: boolean;
  34270. /**
  34271. * The sound track id this sound belongs to.
  34272. */
  34273. soundTrackId: number;
  34274. /**
  34275. * Is this sound currently played.
  34276. */
  34277. isPlaying: boolean;
  34278. /**
  34279. * Is this sound currently paused.
  34280. */
  34281. isPaused: boolean;
  34282. /**
  34283. * Does this sound enables spatial sound.
  34284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34285. */
  34286. spatialSound: boolean;
  34287. /**
  34288. * Define the reference distance the sound should be heard perfectly.
  34289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34290. */
  34291. refDistance: number;
  34292. /**
  34293. * Define the roll off factor of spatial sounds.
  34294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34295. */
  34296. rolloffFactor: number;
  34297. /**
  34298. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34300. */
  34301. maxDistance: number;
  34302. /**
  34303. * Define the distance attenuation model the sound will follow.
  34304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34305. */
  34306. distanceModel: string;
  34307. /**
  34308. * @hidden
  34309. * Back Compat
  34310. **/
  34311. onended: () => any;
  34312. /**
  34313. * Observable event when the current playing sound finishes.
  34314. */
  34315. onEndedObservable: Observable<Sound>;
  34316. private _panningModel;
  34317. private _playbackRate;
  34318. private _streaming;
  34319. private _startTime;
  34320. private _startOffset;
  34321. private _position;
  34322. /** @hidden */
  34323. _positionInEmitterSpace: boolean;
  34324. private _localDirection;
  34325. private _volume;
  34326. private _isReadyToPlay;
  34327. private _isDirectional;
  34328. private _readyToPlayCallback;
  34329. private _audioBuffer;
  34330. private _soundSource;
  34331. private _streamingSource;
  34332. private _soundPanner;
  34333. private _soundGain;
  34334. private _inputAudioNode;
  34335. private _outputAudioNode;
  34336. private _coneInnerAngle;
  34337. private _coneOuterAngle;
  34338. private _coneOuterGain;
  34339. private _scene;
  34340. private _connectedTransformNode;
  34341. private _customAttenuationFunction;
  34342. private _registerFunc;
  34343. private _isOutputConnected;
  34344. private _htmlAudioElement;
  34345. private _urlType;
  34346. /** @hidden */
  34347. static _SceneComponentInitialization: (scene: Scene) => void;
  34348. /**
  34349. * Create a sound and attach it to a scene
  34350. * @param name Name of your sound
  34351. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34352. * @param scene defines the scene the sound belongs to
  34353. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34354. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34355. */
  34356. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34357. /**
  34358. * Release the sound and its associated resources
  34359. */
  34360. dispose(): void;
  34361. /**
  34362. * Gets if the sounds is ready to be played or not.
  34363. * @returns true if ready, otherwise false
  34364. */
  34365. isReady(): boolean;
  34366. private _soundLoaded;
  34367. /**
  34368. * Sets the data of the sound from an audiobuffer
  34369. * @param audioBuffer The audioBuffer containing the data
  34370. */
  34371. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34372. /**
  34373. * Updates the current sounds options such as maxdistance, loop...
  34374. * @param options A JSON object containing values named as the object properties
  34375. */
  34376. updateOptions(options: any): void;
  34377. private _createSpatialParameters;
  34378. private _updateSpatialParameters;
  34379. /**
  34380. * Switch the panning model to HRTF:
  34381. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34383. */
  34384. switchPanningModelToHRTF(): void;
  34385. /**
  34386. * Switch the panning model to Equal Power:
  34387. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34389. */
  34390. switchPanningModelToEqualPower(): void;
  34391. private _switchPanningModel;
  34392. /**
  34393. * Connect this sound to a sound track audio node like gain...
  34394. * @param soundTrackAudioNode the sound track audio node to connect to
  34395. */
  34396. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34397. /**
  34398. * Transform this sound into a directional source
  34399. * @param coneInnerAngle Size of the inner cone in degree
  34400. * @param coneOuterAngle Size of the outer cone in degree
  34401. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34402. */
  34403. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34404. /**
  34405. * Gets or sets the inner angle for the directional cone.
  34406. */
  34407. /**
  34408. * Gets or sets the inner angle for the directional cone.
  34409. */
  34410. directionalConeInnerAngle: number;
  34411. /**
  34412. * Gets or sets the outer angle for the directional cone.
  34413. */
  34414. /**
  34415. * Gets or sets the outer angle for the directional cone.
  34416. */
  34417. directionalConeOuterAngle: number;
  34418. /**
  34419. * Sets the position of the emitter if spatial sound is enabled
  34420. * @param newPosition Defines the new posisiton
  34421. */
  34422. setPosition(newPosition: Vector3): void;
  34423. /**
  34424. * Sets the local direction of the emitter if spatial sound is enabled
  34425. * @param newLocalDirection Defines the new local direction
  34426. */
  34427. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34428. private _updateDirection;
  34429. /** @hidden */
  34430. updateDistanceFromListener(): void;
  34431. /**
  34432. * Sets a new custom attenuation function for the sound.
  34433. * @param callback Defines the function used for the attenuation
  34434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34435. */
  34436. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34437. /**
  34438. * Play the sound
  34439. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34440. * @param offset (optional) Start the sound setting it at a specific time
  34441. */
  34442. play(time?: number, offset?: number): void;
  34443. private _onended;
  34444. /**
  34445. * Stop the sound
  34446. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34447. */
  34448. stop(time?: number): void;
  34449. /**
  34450. * Put the sound in pause
  34451. */
  34452. pause(): void;
  34453. /**
  34454. * Sets a dedicated volume for this sounds
  34455. * @param newVolume Define the new volume of the sound
  34456. * @param time Define in how long the sound should be at this value
  34457. */
  34458. setVolume(newVolume: number, time?: number): void;
  34459. /**
  34460. * Set the sound play back rate
  34461. * @param newPlaybackRate Define the playback rate the sound should be played at
  34462. */
  34463. setPlaybackRate(newPlaybackRate: number): void;
  34464. /**
  34465. * Gets the volume of the sound.
  34466. * @returns the volume of the sound
  34467. */
  34468. getVolume(): number;
  34469. /**
  34470. * Attach the sound to a dedicated mesh
  34471. * @param transformNode The transform node to connect the sound with
  34472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34473. */
  34474. attachToMesh(transformNode: TransformNode): void;
  34475. /**
  34476. * Detach the sound from the previously attached mesh
  34477. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34478. */
  34479. detachFromMesh(): void;
  34480. private _onRegisterAfterWorldMatrixUpdate;
  34481. /**
  34482. * Clone the current sound in the scene.
  34483. * @returns the new sound clone
  34484. */
  34485. clone(): Nullable<Sound>;
  34486. /**
  34487. * Gets the current underlying audio buffer containing the data
  34488. * @returns the audio buffer
  34489. */
  34490. getAudioBuffer(): Nullable<AudioBuffer>;
  34491. /**
  34492. * Serializes the Sound in a JSON representation
  34493. * @returns the JSON representation of the sound
  34494. */
  34495. serialize(): any;
  34496. /**
  34497. * Parse a JSON representation of a sound to innstantiate in a given scene
  34498. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34499. * @param scene Define the scene the new parsed sound should be created in
  34500. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34501. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34502. * @returns the newly parsed sound
  34503. */
  34504. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34505. }
  34506. }
  34507. declare module "babylonjs/Actions/directAudioActions" {
  34508. import { Action } from "babylonjs/Actions/action";
  34509. import { Condition } from "babylonjs/Actions/condition";
  34510. import { Sound } from "babylonjs/Audio/sound";
  34511. /**
  34512. * This defines an action helpful to play a defined sound on a triggered action.
  34513. */
  34514. export class PlaySoundAction extends Action {
  34515. private _sound;
  34516. /**
  34517. * Instantiate the action
  34518. * @param triggerOptions defines the trigger options
  34519. * @param sound defines the sound to play
  34520. * @param condition defines the trigger related conditions
  34521. */
  34522. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34523. /** @hidden */
  34524. _prepare(): void;
  34525. /**
  34526. * Execute the action and play the sound.
  34527. */
  34528. execute(): void;
  34529. /**
  34530. * Serializes the actions and its related information.
  34531. * @param parent defines the object to serialize in
  34532. * @returns the serialized object
  34533. */
  34534. serialize(parent: any): any;
  34535. }
  34536. /**
  34537. * This defines an action helpful to stop a defined sound on a triggered action.
  34538. */
  34539. export class StopSoundAction extends Action {
  34540. private _sound;
  34541. /**
  34542. * Instantiate the action
  34543. * @param triggerOptions defines the trigger options
  34544. * @param sound defines the sound to stop
  34545. * @param condition defines the trigger related conditions
  34546. */
  34547. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34548. /** @hidden */
  34549. _prepare(): void;
  34550. /**
  34551. * Execute the action and stop the sound.
  34552. */
  34553. execute(): void;
  34554. /**
  34555. * Serializes the actions and its related information.
  34556. * @param parent defines the object to serialize in
  34557. * @returns the serialized object
  34558. */
  34559. serialize(parent: any): any;
  34560. }
  34561. }
  34562. declare module "babylonjs/Actions/interpolateValueAction" {
  34563. import { Action } from "babylonjs/Actions/action";
  34564. import { Condition } from "babylonjs/Actions/condition";
  34565. import { Observable } from "babylonjs/Misc/observable";
  34566. /**
  34567. * This defines an action responsible to change the value of a property
  34568. * by interpolating between its current value and the newly set one once triggered.
  34569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34570. */
  34571. export class InterpolateValueAction extends Action {
  34572. /**
  34573. * Defines the path of the property where the value should be interpolated
  34574. */
  34575. propertyPath: string;
  34576. /**
  34577. * Defines the target value at the end of the interpolation.
  34578. */
  34579. value: any;
  34580. /**
  34581. * Defines the time it will take for the property to interpolate to the value.
  34582. */
  34583. duration: number;
  34584. /**
  34585. * Defines if the other scene animations should be stopped when the action has been triggered
  34586. */
  34587. stopOtherAnimations?: boolean;
  34588. /**
  34589. * Defines a callback raised once the interpolation animation has been done.
  34590. */
  34591. onInterpolationDone?: () => void;
  34592. /**
  34593. * Observable triggered once the interpolation animation has been done.
  34594. */
  34595. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34596. private _target;
  34597. private _effectiveTarget;
  34598. private _property;
  34599. /**
  34600. * Instantiate the action
  34601. * @param triggerOptions defines the trigger options
  34602. * @param target defines the object containing the value to interpolate
  34603. * @param propertyPath defines the path to the property in the target object
  34604. * @param value defines the target value at the end of the interpolation
  34605. * @param duration deines the time it will take for the property to interpolate to the value.
  34606. * @param condition defines the trigger related conditions
  34607. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34608. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34609. */
  34610. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34611. /** @hidden */
  34612. _prepare(): void;
  34613. /**
  34614. * Execute the action starts the value interpolation.
  34615. */
  34616. execute(): void;
  34617. /**
  34618. * Serializes the actions and its related information.
  34619. * @param parent defines the object to serialize in
  34620. * @returns the serialized object
  34621. */
  34622. serialize(parent: any): any;
  34623. }
  34624. }
  34625. declare module "babylonjs/Actions/index" {
  34626. export * from "babylonjs/Actions/action";
  34627. export * from "babylonjs/Actions/actionEvent";
  34628. export * from "babylonjs/Actions/actionManager";
  34629. export * from "babylonjs/Actions/condition";
  34630. export * from "babylonjs/Actions/directActions";
  34631. export * from "babylonjs/Actions/directAudioActions";
  34632. export * from "babylonjs/Actions/interpolateValueAction";
  34633. }
  34634. declare module "babylonjs/Animations/index" {
  34635. export * from "babylonjs/Animations/animatable";
  34636. export * from "babylonjs/Animations/animation";
  34637. export * from "babylonjs/Animations/animationGroup";
  34638. export * from "babylonjs/Animations/animationPropertiesOverride";
  34639. export * from "babylonjs/Animations/easing";
  34640. export * from "babylonjs/Animations/runtimeAnimation";
  34641. export * from "babylonjs/Animations/animationEvent";
  34642. export * from "babylonjs/Animations/animationGroup";
  34643. export * from "babylonjs/Animations/animationKey";
  34644. export * from "babylonjs/Animations/animationRange";
  34645. }
  34646. declare module "babylonjs/Audio/soundTrack" {
  34647. import { Sound } from "babylonjs/Audio/sound";
  34648. import { Analyser } from "babylonjs/Audio/analyser";
  34649. import { Scene } from "babylonjs/scene";
  34650. /**
  34651. * Options allowed during the creation of a sound track.
  34652. */
  34653. export interface ISoundTrackOptions {
  34654. /**
  34655. * The volume the sound track should take during creation
  34656. */
  34657. volume?: number;
  34658. /**
  34659. * Define if the sound track is the main sound track of the scene
  34660. */
  34661. mainTrack?: boolean;
  34662. }
  34663. /**
  34664. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34665. * It will be also used in a future release to apply effects on a specific track.
  34666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34667. */
  34668. export class SoundTrack {
  34669. /**
  34670. * The unique identifier of the sound track in the scene.
  34671. */
  34672. id: number;
  34673. /**
  34674. * The list of sounds included in the sound track.
  34675. */
  34676. soundCollection: Array<Sound>;
  34677. private _outputAudioNode;
  34678. private _scene;
  34679. private _isMainTrack;
  34680. private _connectedAnalyser;
  34681. private _options;
  34682. private _isInitialized;
  34683. /**
  34684. * Creates a new sound track.
  34685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34686. * @param scene Define the scene the sound track belongs to
  34687. * @param options
  34688. */
  34689. constructor(scene: Scene, options?: ISoundTrackOptions);
  34690. private _initializeSoundTrackAudioGraph;
  34691. /**
  34692. * Release the sound track and its associated resources
  34693. */
  34694. dispose(): void;
  34695. /**
  34696. * Adds a sound to this sound track
  34697. * @param sound define the cound to add
  34698. * @ignoreNaming
  34699. */
  34700. AddSound(sound: Sound): void;
  34701. /**
  34702. * Removes a sound to this sound track
  34703. * @param sound define the cound to remove
  34704. * @ignoreNaming
  34705. */
  34706. RemoveSound(sound: Sound): void;
  34707. /**
  34708. * Set a global volume for the full sound track.
  34709. * @param newVolume Define the new volume of the sound track
  34710. */
  34711. setVolume(newVolume: number): void;
  34712. /**
  34713. * Switch the panning model to HRTF:
  34714. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34716. */
  34717. switchPanningModelToHRTF(): void;
  34718. /**
  34719. * Switch the panning model to Equal Power:
  34720. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34722. */
  34723. switchPanningModelToEqualPower(): void;
  34724. /**
  34725. * Connect the sound track to an audio analyser allowing some amazing
  34726. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34728. * @param analyser The analyser to connect to the engine
  34729. */
  34730. connectToAnalyser(analyser: Analyser): void;
  34731. }
  34732. }
  34733. declare module "babylonjs/Audio/audioSceneComponent" {
  34734. import { Sound } from "babylonjs/Audio/sound";
  34735. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34736. import { Nullable } from "babylonjs/types";
  34737. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34738. import { Scene } from "babylonjs/scene";
  34739. import { AbstractScene } from "babylonjs/abstractScene";
  34740. module "babylonjs/abstractScene" {
  34741. interface AbstractScene {
  34742. /**
  34743. * The list of sounds used in the scene.
  34744. */
  34745. sounds: Nullable<Array<Sound>>;
  34746. }
  34747. }
  34748. module "babylonjs/scene" {
  34749. interface Scene {
  34750. /**
  34751. * @hidden
  34752. * Backing field
  34753. */
  34754. _mainSoundTrack: SoundTrack;
  34755. /**
  34756. * The main sound track played by the scene.
  34757. * It cotains your primary collection of sounds.
  34758. */
  34759. mainSoundTrack: SoundTrack;
  34760. /**
  34761. * The list of sound tracks added to the scene
  34762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34763. */
  34764. soundTracks: Nullable<Array<SoundTrack>>;
  34765. /**
  34766. * Gets a sound using a given name
  34767. * @param name defines the name to search for
  34768. * @return the found sound or null if not found at all.
  34769. */
  34770. getSoundByName(name: string): Nullable<Sound>;
  34771. /**
  34772. * Gets or sets if audio support is enabled
  34773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34774. */
  34775. audioEnabled: boolean;
  34776. /**
  34777. * Gets or sets if audio will be output to headphones
  34778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34779. */
  34780. headphone: boolean;
  34781. }
  34782. }
  34783. /**
  34784. * Defines the sound scene component responsible to manage any sounds
  34785. * in a given scene.
  34786. */
  34787. export class AudioSceneComponent implements ISceneSerializableComponent {
  34788. /**
  34789. * The component name helpfull to identify the component in the list of scene components.
  34790. */
  34791. readonly name: string;
  34792. /**
  34793. * The scene the component belongs to.
  34794. */
  34795. scene: Scene;
  34796. private _audioEnabled;
  34797. /**
  34798. * Gets whether audio is enabled or not.
  34799. * Please use related enable/disable method to switch state.
  34800. */
  34801. readonly audioEnabled: boolean;
  34802. private _headphone;
  34803. /**
  34804. * Gets whether audio is outputing to headphone or not.
  34805. * Please use the according Switch methods to change output.
  34806. */
  34807. readonly headphone: boolean;
  34808. /**
  34809. * Creates a new instance of the component for the given scene
  34810. * @param scene Defines the scene to register the component in
  34811. */
  34812. constructor(scene: Scene);
  34813. /**
  34814. * Registers the component in a given scene
  34815. */
  34816. register(): void;
  34817. /**
  34818. * Rebuilds the elements related to this component in case of
  34819. * context lost for instance.
  34820. */
  34821. rebuild(): void;
  34822. /**
  34823. * Serializes the component data to the specified json object
  34824. * @param serializationObject The object to serialize to
  34825. */
  34826. serialize(serializationObject: any): void;
  34827. /**
  34828. * Adds all the element from the container to the scene
  34829. * @param container the container holding the elements
  34830. */
  34831. addFromContainer(container: AbstractScene): void;
  34832. /**
  34833. * Removes all the elements in the container from the scene
  34834. * @param container contains the elements to remove
  34835. */
  34836. removeFromContainer(container: AbstractScene): void;
  34837. /**
  34838. * Disposes the component and the associated ressources.
  34839. */
  34840. dispose(): void;
  34841. /**
  34842. * Disables audio in the associated scene.
  34843. */
  34844. disableAudio(): void;
  34845. /**
  34846. * Enables audio in the associated scene.
  34847. */
  34848. enableAudio(): void;
  34849. /**
  34850. * Switch audio to headphone output.
  34851. */
  34852. switchAudioModeForHeadphones(): void;
  34853. /**
  34854. * Switch audio to normal speakers.
  34855. */
  34856. switchAudioModeForNormalSpeakers(): void;
  34857. private _afterRender;
  34858. }
  34859. }
  34860. declare module "babylonjs/Audio/weightedsound" {
  34861. import { Sound } from "babylonjs/Audio/sound";
  34862. /**
  34863. * Wraps one or more Sound objects and selects one with random weight for playback.
  34864. */
  34865. export class WeightedSound {
  34866. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34867. loop: boolean;
  34868. private _coneInnerAngle;
  34869. private _coneOuterAngle;
  34870. private _volume;
  34871. /** A Sound is currently playing. */
  34872. isPlaying: boolean;
  34873. /** A Sound is currently paused. */
  34874. isPaused: boolean;
  34875. private _sounds;
  34876. private _weights;
  34877. private _currentIndex?;
  34878. /**
  34879. * Creates a new WeightedSound from the list of sounds given.
  34880. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34881. * @param sounds Array of Sounds that will be selected from.
  34882. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34883. */
  34884. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34885. /**
  34886. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34887. */
  34888. /**
  34889. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34890. */
  34891. directionalConeInnerAngle: number;
  34892. /**
  34893. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34894. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34895. */
  34896. /**
  34897. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34898. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34899. */
  34900. directionalConeOuterAngle: number;
  34901. /**
  34902. * Playback volume.
  34903. */
  34904. /**
  34905. * Playback volume.
  34906. */
  34907. volume: number;
  34908. private _onended;
  34909. /**
  34910. * Suspend playback
  34911. */
  34912. pause(): void;
  34913. /**
  34914. * Stop playback
  34915. */
  34916. stop(): void;
  34917. /**
  34918. * Start playback.
  34919. * @param startOffset Position the clip head at a specific time in seconds.
  34920. */
  34921. play(startOffset?: number): void;
  34922. }
  34923. }
  34924. declare module "babylonjs/Audio/index" {
  34925. export * from "babylonjs/Audio/analyser";
  34926. export * from "babylonjs/Audio/audioEngine";
  34927. export * from "babylonjs/Audio/audioSceneComponent";
  34928. export * from "babylonjs/Audio/sound";
  34929. export * from "babylonjs/Audio/soundTrack";
  34930. export * from "babylonjs/Audio/weightedsound";
  34931. }
  34932. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34933. import { Behavior } from "babylonjs/Behaviors/behavior";
  34934. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34935. import { BackEase } from "babylonjs/Animations/easing";
  34936. /**
  34937. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34938. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34939. */
  34940. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34941. /**
  34942. * Gets the name of the behavior.
  34943. */
  34944. readonly name: string;
  34945. /**
  34946. * The easing function used by animations
  34947. */
  34948. static EasingFunction: BackEase;
  34949. /**
  34950. * The easing mode used by animations
  34951. */
  34952. static EasingMode: number;
  34953. /**
  34954. * The duration of the animation, in milliseconds
  34955. */
  34956. transitionDuration: number;
  34957. /**
  34958. * Length of the distance animated by the transition when lower radius is reached
  34959. */
  34960. lowerRadiusTransitionRange: number;
  34961. /**
  34962. * Length of the distance animated by the transition when upper radius is reached
  34963. */
  34964. upperRadiusTransitionRange: number;
  34965. private _autoTransitionRange;
  34966. /**
  34967. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34968. */
  34969. /**
  34970. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34971. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34972. */
  34973. autoTransitionRange: boolean;
  34974. private _attachedCamera;
  34975. private _onAfterCheckInputsObserver;
  34976. private _onMeshTargetChangedObserver;
  34977. /**
  34978. * Initializes the behavior.
  34979. */
  34980. init(): void;
  34981. /**
  34982. * Attaches the behavior to its arc rotate camera.
  34983. * @param camera Defines the camera to attach the behavior to
  34984. */
  34985. attach(camera: ArcRotateCamera): void;
  34986. /**
  34987. * Detaches the behavior from its current arc rotate camera.
  34988. */
  34989. detach(): void;
  34990. private _radiusIsAnimating;
  34991. private _radiusBounceTransition;
  34992. private _animatables;
  34993. private _cachedWheelPrecision;
  34994. /**
  34995. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34996. * @param radiusLimit The limit to check against.
  34997. * @return Bool to indicate if at limit.
  34998. */
  34999. private _isRadiusAtLimit;
  35000. /**
  35001. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35002. * @param radiusDelta The delta by which to animate to. Can be negative.
  35003. */
  35004. private _applyBoundRadiusAnimation;
  35005. /**
  35006. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35007. */
  35008. protected _clearAnimationLocks(): void;
  35009. /**
  35010. * Stops and removes all animations that have been applied to the camera
  35011. */
  35012. stopAllAnimations(): void;
  35013. }
  35014. }
  35015. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35016. import { Behavior } from "babylonjs/Behaviors/behavior";
  35017. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35018. import { ExponentialEase } from "babylonjs/Animations/easing";
  35019. import { Nullable } from "babylonjs/types";
  35020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35021. import { Vector3 } from "babylonjs/Maths/math";
  35022. /**
  35023. * 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.
  35024. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35025. */
  35026. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35027. /**
  35028. * Gets the name of the behavior.
  35029. */
  35030. readonly name: string;
  35031. private _mode;
  35032. private _radiusScale;
  35033. private _positionScale;
  35034. private _defaultElevation;
  35035. private _elevationReturnTime;
  35036. private _elevationReturnWaitTime;
  35037. private _zoomStopsAnimation;
  35038. private _framingTime;
  35039. /**
  35040. * The easing function used by animations
  35041. */
  35042. static EasingFunction: ExponentialEase;
  35043. /**
  35044. * The easing mode used by animations
  35045. */
  35046. static EasingMode: number;
  35047. /**
  35048. * Sets the current mode used by the behavior
  35049. */
  35050. /**
  35051. * Gets current mode used by the behavior.
  35052. */
  35053. mode: number;
  35054. /**
  35055. * Sets the scale applied to the radius (1 by default)
  35056. */
  35057. /**
  35058. * Gets the scale applied to the radius
  35059. */
  35060. radiusScale: number;
  35061. /**
  35062. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35063. */
  35064. /**
  35065. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35066. */
  35067. positionScale: number;
  35068. /**
  35069. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35070. * behaviour is triggered, in radians.
  35071. */
  35072. /**
  35073. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35074. * behaviour is triggered, in radians.
  35075. */
  35076. defaultElevation: number;
  35077. /**
  35078. * Sets the time (in milliseconds) taken to return to the default beta position.
  35079. * Negative value indicates camera should not return to default.
  35080. */
  35081. /**
  35082. * Gets the time (in milliseconds) taken to return to the default beta position.
  35083. * Negative value indicates camera should not return to default.
  35084. */
  35085. elevationReturnTime: number;
  35086. /**
  35087. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35088. */
  35089. /**
  35090. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35091. */
  35092. elevationReturnWaitTime: number;
  35093. /**
  35094. * Sets the flag that indicates if user zooming should stop animation.
  35095. */
  35096. /**
  35097. * Gets the flag that indicates if user zooming should stop animation.
  35098. */
  35099. zoomStopsAnimation: boolean;
  35100. /**
  35101. * Sets the transition time when framing the mesh, in milliseconds
  35102. */
  35103. /**
  35104. * Gets the transition time when framing the mesh, in milliseconds
  35105. */
  35106. framingTime: number;
  35107. /**
  35108. * Define if the behavior should automatically change the configured
  35109. * camera limits and sensibilities.
  35110. */
  35111. autoCorrectCameraLimitsAndSensibility: boolean;
  35112. private _onPrePointerObservableObserver;
  35113. private _onAfterCheckInputsObserver;
  35114. private _onMeshTargetChangedObserver;
  35115. private _attachedCamera;
  35116. private _isPointerDown;
  35117. private _lastInteractionTime;
  35118. /**
  35119. * Initializes the behavior.
  35120. */
  35121. init(): void;
  35122. /**
  35123. * Attaches the behavior to its arc rotate camera.
  35124. * @param camera Defines the camera to attach the behavior to
  35125. */
  35126. attach(camera: ArcRotateCamera): void;
  35127. /**
  35128. * Detaches the behavior from its current arc rotate camera.
  35129. */
  35130. detach(): void;
  35131. private _animatables;
  35132. private _betaIsAnimating;
  35133. private _betaTransition;
  35134. private _radiusTransition;
  35135. private _vectorTransition;
  35136. /**
  35137. * Targets the given mesh and updates zoom level accordingly.
  35138. * @param mesh The mesh to target.
  35139. * @param radius Optional. If a cached radius position already exists, overrides default.
  35140. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35141. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35142. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35143. */
  35144. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35145. /**
  35146. * Targets the given mesh with its children and updates zoom level accordingly.
  35147. * @param mesh The mesh to target.
  35148. * @param radius Optional. If a cached radius position already exists, overrides default.
  35149. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35150. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35151. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35152. */
  35153. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35154. /**
  35155. * Targets the given meshes with their children and updates zoom level accordingly.
  35156. * @param meshes The mesh to target.
  35157. * @param radius Optional. If a cached radius position already exists, overrides default.
  35158. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35159. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35160. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35161. */
  35162. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35163. /**
  35164. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35165. * @param minimumWorld Determines the smaller position of the bounding box extend
  35166. * @param maximumWorld Determines the bigger position of the bounding box extend
  35167. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35168. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35169. */
  35170. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35171. /**
  35172. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35173. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35174. * frustum width.
  35175. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35176. * to fully enclose the mesh in the viewing frustum.
  35177. */
  35178. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35179. /**
  35180. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35181. * is automatically returned to its default position (expected to be above ground plane).
  35182. */
  35183. private _maintainCameraAboveGround;
  35184. /**
  35185. * Returns the frustum slope based on the canvas ratio and camera FOV
  35186. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35187. */
  35188. private _getFrustumSlope;
  35189. /**
  35190. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35191. */
  35192. private _clearAnimationLocks;
  35193. /**
  35194. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35195. */
  35196. private _applyUserInteraction;
  35197. /**
  35198. * Stops and removes all animations that have been applied to the camera
  35199. */
  35200. stopAllAnimations(): void;
  35201. /**
  35202. * Gets a value indicating if the user is moving the camera
  35203. */
  35204. readonly isUserIsMoving: boolean;
  35205. /**
  35206. * The camera can move all the way towards the mesh.
  35207. */
  35208. static IgnoreBoundsSizeMode: number;
  35209. /**
  35210. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35211. */
  35212. static FitFrustumSidesMode: number;
  35213. }
  35214. }
  35215. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35216. import { Nullable } from "babylonjs/types";
  35217. import { Camera } from "babylonjs/Cameras/camera";
  35218. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35219. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35220. /**
  35221. * Base class for Camera Pointer Inputs.
  35222. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35223. * for example usage.
  35224. */
  35225. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35226. /**
  35227. * Defines the camera the input is attached to.
  35228. */
  35229. abstract camera: Camera;
  35230. /**
  35231. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35232. */
  35233. protected _altKey: boolean;
  35234. protected _ctrlKey: boolean;
  35235. protected _metaKey: boolean;
  35236. protected _shiftKey: boolean;
  35237. /**
  35238. * Which mouse buttons were pressed at time of last mouse event.
  35239. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35240. */
  35241. protected _buttonsPressed: number;
  35242. /**
  35243. * Defines the buttons associated with the input to handle camera move.
  35244. */
  35245. buttons: number[];
  35246. /**
  35247. * Attach the input controls to a specific dom element to get the input from.
  35248. * @param element Defines the element the controls should be listened from
  35249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35250. */
  35251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35252. /**
  35253. * Detach the current controls from the specified dom element.
  35254. * @param element Defines the element to stop listening the inputs from
  35255. */
  35256. detachControl(element: Nullable<HTMLElement>): void;
  35257. /**
  35258. * Gets the class name of the current input.
  35259. * @returns the class name
  35260. */
  35261. getClassName(): string;
  35262. /**
  35263. * Get the friendly name associated with the input class.
  35264. * @returns the input friendly name
  35265. */
  35266. getSimpleName(): string;
  35267. /**
  35268. * Called on pointer POINTERDOUBLETAP event.
  35269. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35270. */
  35271. protected onDoubleTap(type: string): void;
  35272. /**
  35273. * Called on pointer POINTERMOVE event if only a single touch is active.
  35274. * Override this method to provide functionality.
  35275. */
  35276. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35277. /**
  35278. * Called on pointer POINTERMOVE event if multiple touches are active.
  35279. * Override this method to provide functionality.
  35280. */
  35281. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35282. /**
  35283. * Called on JS contextmenu event.
  35284. * Override this method to provide functionality.
  35285. */
  35286. protected onContextMenu(evt: PointerEvent): void;
  35287. /**
  35288. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35289. * press.
  35290. * Override this method to provide functionality.
  35291. */
  35292. protected onButtonDown(evt: PointerEvent): void;
  35293. /**
  35294. * Called each time a new POINTERUP event occurs. Ie, for each button
  35295. * release.
  35296. * Override this method to provide functionality.
  35297. */
  35298. protected onButtonUp(evt: PointerEvent): void;
  35299. /**
  35300. * Called when window becomes inactive.
  35301. * Override this method to provide functionality.
  35302. */
  35303. protected onLostFocus(): void;
  35304. private _pointerInput;
  35305. private _observer;
  35306. private _onLostFocus;
  35307. private pointA;
  35308. private pointB;
  35309. }
  35310. }
  35311. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35312. import { Nullable } from "babylonjs/types";
  35313. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35314. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35315. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35316. /**
  35317. * Manage the pointers inputs to control an arc rotate camera.
  35318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35319. */
  35320. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35321. /**
  35322. * Defines the camera the input is attached to.
  35323. */
  35324. camera: ArcRotateCamera;
  35325. /**
  35326. * Gets the class name of the current input.
  35327. * @returns the class name
  35328. */
  35329. getClassName(): string;
  35330. /**
  35331. * Defines the buttons associated with the input to handle camera move.
  35332. */
  35333. buttons: number[];
  35334. /**
  35335. * Defines the pointer angular sensibility along the X axis or how fast is
  35336. * the camera rotating.
  35337. */
  35338. angularSensibilityX: number;
  35339. /**
  35340. * Defines the pointer angular sensibility along the Y axis or how fast is
  35341. * the camera rotating.
  35342. */
  35343. angularSensibilityY: number;
  35344. /**
  35345. * Defines the pointer pinch precision or how fast is the camera zooming.
  35346. */
  35347. pinchPrecision: number;
  35348. /**
  35349. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35350. * from 0.
  35351. * It defines the percentage of current camera.radius to use as delta when
  35352. * pinch zoom is used.
  35353. */
  35354. pinchDeltaPercentage: number;
  35355. /**
  35356. * Defines the pointer panning sensibility or how fast is the camera moving.
  35357. */
  35358. panningSensibility: number;
  35359. /**
  35360. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35361. */
  35362. multiTouchPanning: boolean;
  35363. /**
  35364. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35365. * zoom (pinch) through multitouch.
  35366. */
  35367. multiTouchPanAndZoom: boolean;
  35368. /**
  35369. * Revers pinch action direction.
  35370. */
  35371. pinchInwards: boolean;
  35372. private _isPanClick;
  35373. private _twoFingerActivityCount;
  35374. private _isPinching;
  35375. /**
  35376. * Called on pointer POINTERMOVE event if only a single touch is active.
  35377. */
  35378. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35379. /**
  35380. * Called on pointer POINTERDOUBLETAP event.
  35381. */
  35382. protected onDoubleTap(type: string): void;
  35383. /**
  35384. * Called on pointer POINTERMOVE event if multiple touches are active.
  35385. */
  35386. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35387. /**
  35388. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35389. * press.
  35390. */
  35391. protected onButtonDown(evt: PointerEvent): void;
  35392. /**
  35393. * Called each time a new POINTERUP event occurs. Ie, for each button
  35394. * release.
  35395. */
  35396. protected onButtonUp(evt: PointerEvent): void;
  35397. /**
  35398. * Called when window becomes inactive.
  35399. */
  35400. protected onLostFocus(): void;
  35401. }
  35402. }
  35403. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35404. import { Nullable } from "babylonjs/types";
  35405. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35406. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35407. /**
  35408. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35410. */
  35411. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35412. /**
  35413. * Defines the camera the input is attached to.
  35414. */
  35415. camera: ArcRotateCamera;
  35416. /**
  35417. * Defines the list of key codes associated with the up action (increase alpha)
  35418. */
  35419. keysUp: number[];
  35420. /**
  35421. * Defines the list of key codes associated with the down action (decrease alpha)
  35422. */
  35423. keysDown: number[];
  35424. /**
  35425. * Defines the list of key codes associated with the left action (increase beta)
  35426. */
  35427. keysLeft: number[];
  35428. /**
  35429. * Defines the list of key codes associated with the right action (decrease beta)
  35430. */
  35431. keysRight: number[];
  35432. /**
  35433. * Defines the list of key codes associated with the reset action.
  35434. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35435. */
  35436. keysReset: number[];
  35437. /**
  35438. * Defines the panning sensibility of the inputs.
  35439. * (How fast is the camera paning)
  35440. */
  35441. panningSensibility: number;
  35442. /**
  35443. * Defines the zooming sensibility of the inputs.
  35444. * (How fast is the camera zooming)
  35445. */
  35446. zoomingSensibility: number;
  35447. /**
  35448. * Defines wether maintaining the alt key down switch the movement mode from
  35449. * orientation to zoom.
  35450. */
  35451. useAltToZoom: boolean;
  35452. /**
  35453. * Rotation speed of the camera
  35454. */
  35455. angularSpeed: number;
  35456. private _keys;
  35457. private _ctrlPressed;
  35458. private _altPressed;
  35459. private _onCanvasBlurObserver;
  35460. private _onKeyboardObserver;
  35461. private _engine;
  35462. private _scene;
  35463. /**
  35464. * Attach the input controls to a specific dom element to get the input from.
  35465. * @param element Defines the element the controls should be listened from
  35466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35467. */
  35468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35469. /**
  35470. * Detach the current controls from the specified dom element.
  35471. * @param element Defines the element to stop listening the inputs from
  35472. */
  35473. detachControl(element: Nullable<HTMLElement>): void;
  35474. /**
  35475. * Update the current camera state depending on the inputs that have been used this frame.
  35476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35477. */
  35478. checkInputs(): void;
  35479. /**
  35480. * Gets the class name of the current intput.
  35481. * @returns the class name
  35482. */
  35483. getClassName(): string;
  35484. /**
  35485. * Get the friendly name associated with the input class.
  35486. * @returns the input friendly name
  35487. */
  35488. getSimpleName(): string;
  35489. }
  35490. }
  35491. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35492. import { Nullable } from "babylonjs/types";
  35493. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35495. /**
  35496. * Manage the mouse wheel inputs to control an arc rotate camera.
  35497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35498. */
  35499. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35500. /**
  35501. * Defines the camera the input is attached to.
  35502. */
  35503. camera: ArcRotateCamera;
  35504. /**
  35505. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35506. */
  35507. wheelPrecision: number;
  35508. /**
  35509. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35510. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35511. */
  35512. wheelDeltaPercentage: number;
  35513. private _wheel;
  35514. private _observer;
  35515. /**
  35516. * Attach the input controls to a specific dom element to get the input from.
  35517. * @param element Defines the element the controls should be listened from
  35518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35519. */
  35520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35521. /**
  35522. * Detach the current controls from the specified dom element.
  35523. * @param element Defines the element to stop listening the inputs from
  35524. */
  35525. detachControl(element: Nullable<HTMLElement>): void;
  35526. /**
  35527. * Gets the class name of the current intput.
  35528. * @returns the class name
  35529. */
  35530. getClassName(): string;
  35531. /**
  35532. * Get the friendly name associated with the input class.
  35533. * @returns the input friendly name
  35534. */
  35535. getSimpleName(): string;
  35536. }
  35537. }
  35538. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35539. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35540. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35541. /**
  35542. * Default Inputs manager for the ArcRotateCamera.
  35543. * It groups all the default supported inputs for ease of use.
  35544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35545. */
  35546. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35547. /**
  35548. * Instantiates a new ArcRotateCameraInputsManager.
  35549. * @param camera Defines the camera the inputs belong to
  35550. */
  35551. constructor(camera: ArcRotateCamera);
  35552. /**
  35553. * Add mouse wheel input support to the input manager.
  35554. * @returns the current input manager
  35555. */
  35556. addMouseWheel(): ArcRotateCameraInputsManager;
  35557. /**
  35558. * Add pointers input support to the input manager.
  35559. * @returns the current input manager
  35560. */
  35561. addPointers(): ArcRotateCameraInputsManager;
  35562. /**
  35563. * Add keyboard input support to the input manager.
  35564. * @returns the current input manager
  35565. */
  35566. addKeyboard(): ArcRotateCameraInputsManager;
  35567. }
  35568. }
  35569. declare module "babylonjs/Cameras/arcRotateCamera" {
  35570. import { Observable } from "babylonjs/Misc/observable";
  35571. import { Nullable } from "babylonjs/types";
  35572. import { Scene } from "babylonjs/scene";
  35573. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35575. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35576. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35577. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35578. import { Camera } from "babylonjs/Cameras/camera";
  35579. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35580. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35581. import { Collider } from "babylonjs/Collisions/collider";
  35582. /**
  35583. * This represents an orbital type of camera.
  35584. *
  35585. * 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.
  35586. * 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.
  35587. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35588. */
  35589. export class ArcRotateCamera extends TargetCamera {
  35590. /**
  35591. * Defines the rotation angle of the camera along the longitudinal axis.
  35592. */
  35593. alpha: number;
  35594. /**
  35595. * Defines the rotation angle of the camera along the latitudinal axis.
  35596. */
  35597. beta: number;
  35598. /**
  35599. * Defines the radius of the camera from it s target point.
  35600. */
  35601. radius: number;
  35602. protected _target: Vector3;
  35603. protected _targetHost: Nullable<AbstractMesh>;
  35604. /**
  35605. * Defines the target point of the camera.
  35606. * The camera looks towards it form the radius distance.
  35607. */
  35608. target: Vector3;
  35609. /**
  35610. * Define the current local position of the camera in the scene
  35611. */
  35612. position: Vector3;
  35613. /**
  35614. * Current inertia value on the longitudinal axis.
  35615. * The bigger this number the longer it will take for the camera to stop.
  35616. */
  35617. inertialAlphaOffset: number;
  35618. /**
  35619. * Current inertia value on the latitudinal axis.
  35620. * The bigger this number the longer it will take for the camera to stop.
  35621. */
  35622. inertialBetaOffset: number;
  35623. /**
  35624. * Current inertia value on the radius axis.
  35625. * The bigger this number the longer it will take for the camera to stop.
  35626. */
  35627. inertialRadiusOffset: number;
  35628. /**
  35629. * Minimum allowed angle on the longitudinal axis.
  35630. * This can help limiting how the Camera is able to move in the scene.
  35631. */
  35632. lowerAlphaLimit: Nullable<number>;
  35633. /**
  35634. * Maximum allowed angle on the longitudinal axis.
  35635. * This can help limiting how the Camera is able to move in the scene.
  35636. */
  35637. upperAlphaLimit: Nullable<number>;
  35638. /**
  35639. * Minimum allowed angle on the latitudinal axis.
  35640. * This can help limiting how the Camera is able to move in the scene.
  35641. */
  35642. lowerBetaLimit: number;
  35643. /**
  35644. * Maximum allowed angle on the latitudinal axis.
  35645. * This can help limiting how the Camera is able to move in the scene.
  35646. */
  35647. upperBetaLimit: number;
  35648. /**
  35649. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35650. * This can help limiting how the Camera is able to move in the scene.
  35651. */
  35652. lowerRadiusLimit: Nullable<number>;
  35653. /**
  35654. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35655. * This can help limiting how the Camera is able to move in the scene.
  35656. */
  35657. upperRadiusLimit: Nullable<number>;
  35658. /**
  35659. * Defines the current inertia value used during panning of the camera along the X axis.
  35660. */
  35661. inertialPanningX: number;
  35662. /**
  35663. * Defines the current inertia value used during panning of the camera along the Y axis.
  35664. */
  35665. inertialPanningY: number;
  35666. /**
  35667. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35668. * Basically if your fingers moves away from more than this distance you will be considered
  35669. * in pinch mode.
  35670. */
  35671. pinchToPanMaxDistance: number;
  35672. /**
  35673. * Defines the maximum distance the camera can pan.
  35674. * This could help keeping the cammera always in your scene.
  35675. */
  35676. panningDistanceLimit: Nullable<number>;
  35677. /**
  35678. * Defines the target of the camera before paning.
  35679. */
  35680. panningOriginTarget: Vector3;
  35681. /**
  35682. * Defines the value of the inertia used during panning.
  35683. * 0 would mean stop inertia and one would mean no decelleration at all.
  35684. */
  35685. panningInertia: number;
  35686. /**
  35687. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35688. */
  35689. angularSensibilityX: number;
  35690. /**
  35691. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35692. */
  35693. angularSensibilityY: number;
  35694. /**
  35695. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35696. */
  35697. pinchPrecision: number;
  35698. /**
  35699. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35700. * It will be used instead of pinchDeltaPrecision if different from 0.
  35701. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35702. */
  35703. pinchDeltaPercentage: number;
  35704. /**
  35705. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35706. */
  35707. panningSensibility: number;
  35708. /**
  35709. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35710. */
  35711. keysUp: number[];
  35712. /**
  35713. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35714. */
  35715. keysDown: number[];
  35716. /**
  35717. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35718. */
  35719. keysLeft: number[];
  35720. /**
  35721. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35722. */
  35723. keysRight: number[];
  35724. /**
  35725. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35726. */
  35727. wheelPrecision: number;
  35728. /**
  35729. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35730. * It will be used instead of pinchDeltaPrecision if different from 0.
  35731. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35732. */
  35733. wheelDeltaPercentage: number;
  35734. /**
  35735. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35736. */
  35737. zoomOnFactor: number;
  35738. /**
  35739. * Defines a screen offset for the camera position.
  35740. */
  35741. targetScreenOffset: Vector2;
  35742. /**
  35743. * Allows the camera to be completely reversed.
  35744. * If false the camera can not arrive upside down.
  35745. */
  35746. allowUpsideDown: boolean;
  35747. /**
  35748. * Define if double tap/click is used to restore the previously saved state of the camera.
  35749. */
  35750. useInputToRestoreState: boolean;
  35751. /** @hidden */
  35752. _viewMatrix: Matrix;
  35753. /** @hidden */
  35754. _useCtrlForPanning: boolean;
  35755. /** @hidden */
  35756. _panningMouseButton: number;
  35757. /**
  35758. * Defines the input associated to the camera.
  35759. */
  35760. inputs: ArcRotateCameraInputsManager;
  35761. /** @hidden */
  35762. _reset: () => void;
  35763. /**
  35764. * Defines the allowed panning axis.
  35765. */
  35766. panningAxis: Vector3;
  35767. protected _localDirection: Vector3;
  35768. protected _transformedDirection: Vector3;
  35769. private _bouncingBehavior;
  35770. /**
  35771. * Gets the bouncing behavior of the camera if it has been enabled.
  35772. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35773. */
  35774. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35775. /**
  35776. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35777. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35778. */
  35779. useBouncingBehavior: boolean;
  35780. private _framingBehavior;
  35781. /**
  35782. * Gets the framing behavior of the camera if it has been enabled.
  35783. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35784. */
  35785. readonly framingBehavior: Nullable<FramingBehavior>;
  35786. /**
  35787. * Defines if the framing behavior of the camera is enabled on the camera.
  35788. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35789. */
  35790. useFramingBehavior: boolean;
  35791. private _autoRotationBehavior;
  35792. /**
  35793. * Gets the auto rotation behavior of the camera if it has been enabled.
  35794. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35795. */
  35796. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35797. /**
  35798. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35799. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35800. */
  35801. useAutoRotationBehavior: boolean;
  35802. /**
  35803. * Observable triggered when the mesh target has been changed on the camera.
  35804. */
  35805. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35806. /**
  35807. * Event raised when the camera is colliding with a mesh.
  35808. */
  35809. onCollide: (collidedMesh: AbstractMesh) => void;
  35810. /**
  35811. * Defines whether the camera should check collision with the objects oh the scene.
  35812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35813. */
  35814. checkCollisions: boolean;
  35815. /**
  35816. * Defines the collision radius of the camera.
  35817. * This simulates a sphere around the camera.
  35818. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35819. */
  35820. collisionRadius: Vector3;
  35821. protected _collider: Collider;
  35822. protected _previousPosition: Vector3;
  35823. protected _collisionVelocity: Vector3;
  35824. protected _newPosition: Vector3;
  35825. protected _previousAlpha: number;
  35826. protected _previousBeta: number;
  35827. protected _previousRadius: number;
  35828. protected _collisionTriggered: boolean;
  35829. protected _targetBoundingCenter: Nullable<Vector3>;
  35830. private _computationVector;
  35831. private _tempAxisVector;
  35832. private _tempAxisRotationMatrix;
  35833. /**
  35834. * Instantiates a new ArcRotateCamera in a given scene
  35835. * @param name Defines the name of the camera
  35836. * @param alpha Defines the camera rotation along the logitudinal axis
  35837. * @param beta Defines the camera rotation along the latitudinal axis
  35838. * @param radius Defines the camera distance from its target
  35839. * @param target Defines the camera target
  35840. * @param scene Defines the scene the camera belongs to
  35841. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35842. */
  35843. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35844. /** @hidden */
  35845. _initCache(): void;
  35846. /** @hidden */
  35847. _updateCache(ignoreParentClass?: boolean): void;
  35848. protected _getTargetPosition(): Vector3;
  35849. private _storedAlpha;
  35850. private _storedBeta;
  35851. private _storedRadius;
  35852. private _storedTarget;
  35853. /**
  35854. * Stores the current state of the camera (alpha, beta, radius and target)
  35855. * @returns the camera itself
  35856. */
  35857. storeState(): Camera;
  35858. /**
  35859. * @hidden
  35860. * Restored camera state. You must call storeState() first
  35861. */
  35862. _restoreStateValues(): boolean;
  35863. /** @hidden */
  35864. _isSynchronizedViewMatrix(): boolean;
  35865. /**
  35866. * Attached controls to the current camera.
  35867. * @param element Defines the element the controls should be listened from
  35868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35869. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35870. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35871. */
  35872. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35873. /**
  35874. * Detach the current controls from the camera.
  35875. * The camera will stop reacting to inputs.
  35876. * @param element Defines the element to stop listening the inputs from
  35877. */
  35878. detachControl(element: HTMLElement): void;
  35879. /** @hidden */
  35880. _checkInputs(): void;
  35881. protected _checkLimits(): void;
  35882. /**
  35883. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35884. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35885. */
  35886. rebuildAnglesAndRadius(updateView?: boolean): void;
  35887. /**
  35888. * Use a position to define the current camera related information like aplha, beta and radius
  35889. * @param position Defines the position to set the camera at
  35890. */
  35891. setPosition(position: Vector3): void;
  35892. /**
  35893. * Defines the target the camera should look at.
  35894. * This will automatically adapt alpha beta and radius to fit within the new target.
  35895. * @param target Defines the new target as a Vector or a mesh
  35896. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35897. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35898. */
  35899. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35900. /** @hidden */
  35901. _getViewMatrix(): Matrix;
  35902. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35903. /**
  35904. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35905. * @param meshes Defines the mesh to zoom on
  35906. * @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)
  35907. */
  35908. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35909. /**
  35910. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35911. * The target will be changed but the radius
  35912. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35913. * @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)
  35914. */
  35915. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35916. min: Vector3;
  35917. max: Vector3;
  35918. distance: number;
  35919. }, doNotUpdateMaxZ?: boolean): void;
  35920. /**
  35921. * @override
  35922. * Override Camera.createRigCamera
  35923. */
  35924. createRigCamera(name: string, cameraIndex: number): Camera;
  35925. /**
  35926. * @hidden
  35927. * @override
  35928. * Override Camera._updateRigCameras
  35929. */
  35930. _updateRigCameras(): void;
  35931. /**
  35932. * Destroy the camera and release the current resources hold by it.
  35933. */
  35934. dispose(): void;
  35935. /**
  35936. * Gets the current object class name.
  35937. * @return the class name
  35938. */
  35939. getClassName(): string;
  35940. }
  35941. }
  35942. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35943. import { Behavior } from "babylonjs/Behaviors/behavior";
  35944. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35945. /**
  35946. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35948. */
  35949. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35950. /**
  35951. * Gets the name of the behavior.
  35952. */
  35953. readonly name: string;
  35954. private _zoomStopsAnimation;
  35955. private _idleRotationSpeed;
  35956. private _idleRotationWaitTime;
  35957. private _idleRotationSpinupTime;
  35958. /**
  35959. * Sets the flag that indicates if user zooming should stop animation.
  35960. */
  35961. /**
  35962. * Gets the flag that indicates if user zooming should stop animation.
  35963. */
  35964. zoomStopsAnimation: boolean;
  35965. /**
  35966. * Sets the default speed at which the camera rotates around the model.
  35967. */
  35968. /**
  35969. * Gets the default speed at which the camera rotates around the model.
  35970. */
  35971. idleRotationSpeed: number;
  35972. /**
  35973. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35974. */
  35975. /**
  35976. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35977. */
  35978. idleRotationWaitTime: number;
  35979. /**
  35980. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35981. */
  35982. /**
  35983. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35984. */
  35985. idleRotationSpinupTime: number;
  35986. /**
  35987. * Gets a value indicating if the camera is currently rotating because of this behavior
  35988. */
  35989. readonly rotationInProgress: boolean;
  35990. private _onPrePointerObservableObserver;
  35991. private _onAfterCheckInputsObserver;
  35992. private _attachedCamera;
  35993. private _isPointerDown;
  35994. private _lastFrameTime;
  35995. private _lastInteractionTime;
  35996. private _cameraRotationSpeed;
  35997. /**
  35998. * Initializes the behavior.
  35999. */
  36000. init(): void;
  36001. /**
  36002. * Attaches the behavior to its arc rotate camera.
  36003. * @param camera Defines the camera to attach the behavior to
  36004. */
  36005. attach(camera: ArcRotateCamera): void;
  36006. /**
  36007. * Detaches the behavior from its current arc rotate camera.
  36008. */
  36009. detach(): void;
  36010. /**
  36011. * Returns true if user is scrolling.
  36012. * @return true if user is scrolling.
  36013. */
  36014. private _userIsZooming;
  36015. private _lastFrameRadius;
  36016. private _shouldAnimationStopForInteraction;
  36017. /**
  36018. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36019. */
  36020. private _applyUserInteraction;
  36021. private _userIsMoving;
  36022. }
  36023. }
  36024. declare module "babylonjs/Behaviors/Cameras/index" {
  36025. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36026. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36027. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36028. }
  36029. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36030. import { Mesh } from "babylonjs/Meshes/mesh";
  36031. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36032. import { Behavior } from "babylonjs/Behaviors/behavior";
  36033. /**
  36034. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36035. */
  36036. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36037. private ui;
  36038. /**
  36039. * The name of the behavior
  36040. */
  36041. name: string;
  36042. /**
  36043. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36044. */
  36045. distanceAwayFromFace: number;
  36046. /**
  36047. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36048. */
  36049. distanceAwayFromBottomOfFace: number;
  36050. private _faceVectors;
  36051. private _target;
  36052. private _scene;
  36053. private _onRenderObserver;
  36054. private _tmpMatrix;
  36055. private _tmpVector;
  36056. /**
  36057. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36058. * @param ui The transform node that should be attched to the mesh
  36059. */
  36060. constructor(ui: TransformNode);
  36061. /**
  36062. * Initializes the behavior
  36063. */
  36064. init(): void;
  36065. private _closestFace;
  36066. private _zeroVector;
  36067. private _lookAtTmpMatrix;
  36068. private _lookAtToRef;
  36069. /**
  36070. * Attaches the AttachToBoxBehavior to the passed in mesh
  36071. * @param target The mesh that the specified node will be attached to
  36072. */
  36073. attach(target: Mesh): void;
  36074. /**
  36075. * Detaches the behavior from the mesh
  36076. */
  36077. detach(): void;
  36078. }
  36079. }
  36080. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36081. import { Behavior } from "babylonjs/Behaviors/behavior";
  36082. import { Mesh } from "babylonjs/Meshes/mesh";
  36083. /**
  36084. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36085. */
  36086. export class FadeInOutBehavior implements Behavior<Mesh> {
  36087. /**
  36088. * Time in milliseconds to delay before fading in (Default: 0)
  36089. */
  36090. delay: number;
  36091. /**
  36092. * Time in milliseconds for the mesh to fade in (Default: 300)
  36093. */
  36094. fadeInTime: number;
  36095. private _millisecondsPerFrame;
  36096. private _hovered;
  36097. private _hoverValue;
  36098. private _ownerNode;
  36099. /**
  36100. * Instatiates the FadeInOutBehavior
  36101. */
  36102. constructor();
  36103. /**
  36104. * The name of the behavior
  36105. */
  36106. readonly name: string;
  36107. /**
  36108. * Initializes the behavior
  36109. */
  36110. init(): void;
  36111. /**
  36112. * Attaches the fade behavior on the passed in mesh
  36113. * @param ownerNode The mesh that will be faded in/out once attached
  36114. */
  36115. attach(ownerNode: Mesh): void;
  36116. /**
  36117. * Detaches the behavior from the mesh
  36118. */
  36119. detach(): void;
  36120. /**
  36121. * Triggers the mesh to begin fading in or out
  36122. * @param value if the object should fade in or out (true to fade in)
  36123. */
  36124. fadeIn(value: boolean): void;
  36125. private _update;
  36126. private _setAllVisibility;
  36127. }
  36128. }
  36129. declare module "babylonjs/Misc/pivotTools" {
  36130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36131. /**
  36132. * Class containing a set of static utilities functions for managing Pivots
  36133. * @hidden
  36134. */
  36135. export class PivotTools {
  36136. private static _PivotCached;
  36137. private static _OldPivotPoint;
  36138. private static _PivotTranslation;
  36139. private static _PivotTmpVector;
  36140. /** @hidden */
  36141. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36142. /** @hidden */
  36143. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36144. }
  36145. }
  36146. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36147. import { Scene } from "babylonjs/scene";
  36148. import { Vector4, Plane } from "babylonjs/Maths/math";
  36149. import { Mesh } from "babylonjs/Meshes/mesh";
  36150. /**
  36151. * Class containing static functions to help procedurally build meshes
  36152. */
  36153. export class PlaneBuilder {
  36154. /**
  36155. * Creates a plane mesh
  36156. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36157. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36158. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36162. * @param name defines the name of the mesh
  36163. * @param options defines the options used to create the mesh
  36164. * @param scene defines the hosting scene
  36165. * @returns the plane mesh
  36166. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36167. */
  36168. static CreatePlane(name: string, options: {
  36169. size?: number;
  36170. width?: number;
  36171. height?: number;
  36172. sideOrientation?: number;
  36173. frontUVs?: Vector4;
  36174. backUVs?: Vector4;
  36175. updatable?: boolean;
  36176. sourcePlane?: Plane;
  36177. }, scene: Scene): Mesh;
  36178. }
  36179. }
  36180. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36181. import { Behavior } from "babylonjs/Behaviors/behavior";
  36182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36183. import { Observable } from "babylonjs/Misc/observable";
  36184. import { Vector3 } from "babylonjs/Maths/math";
  36185. import { Ray } from "babylonjs/Culling/ray";
  36186. import "babylonjs/Meshes/Builders/planeBuilder";
  36187. /**
  36188. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36189. */
  36190. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36191. private static _AnyMouseID;
  36192. private _attachedNode;
  36193. private _dragPlane;
  36194. private _scene;
  36195. private _pointerObserver;
  36196. private _beforeRenderObserver;
  36197. private static _planeScene;
  36198. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36199. /**
  36200. * 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)
  36201. */
  36202. maxDragAngle: number;
  36203. /**
  36204. * @hidden
  36205. */
  36206. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36207. /**
  36208. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36209. */
  36210. currentDraggingPointerID: number;
  36211. /**
  36212. * The last position where the pointer hit the drag plane in world space
  36213. */
  36214. lastDragPosition: Vector3;
  36215. /**
  36216. * If the behavior is currently in a dragging state
  36217. */
  36218. dragging: boolean;
  36219. /**
  36220. * 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)
  36221. */
  36222. dragDeltaRatio: number;
  36223. /**
  36224. * If the drag plane orientation should be updated during the dragging (Default: true)
  36225. */
  36226. updateDragPlane: boolean;
  36227. private _debugMode;
  36228. private _moving;
  36229. /**
  36230. * Fires each time the attached mesh is dragged with the pointer
  36231. * * delta between last drag position and current drag position in world space
  36232. * * dragDistance along the drag axis
  36233. * * dragPlaneNormal normal of the current drag plane used during the drag
  36234. * * dragPlanePoint in world space where the drag intersects the drag plane
  36235. */
  36236. onDragObservable: Observable<{
  36237. delta: Vector3;
  36238. dragPlanePoint: Vector3;
  36239. dragPlaneNormal: Vector3;
  36240. dragDistance: number;
  36241. pointerId: number;
  36242. }>;
  36243. /**
  36244. * Fires each time a drag begins (eg. mouse down on mesh)
  36245. */
  36246. onDragStartObservable: Observable<{
  36247. dragPlanePoint: Vector3;
  36248. pointerId: number;
  36249. }>;
  36250. /**
  36251. * Fires each time a drag ends (eg. mouse release after drag)
  36252. */
  36253. onDragEndObservable: Observable<{
  36254. dragPlanePoint: Vector3;
  36255. pointerId: number;
  36256. }>;
  36257. /**
  36258. * If the attached mesh should be moved when dragged
  36259. */
  36260. moveAttached: boolean;
  36261. /**
  36262. * If the drag behavior will react to drag events (Default: true)
  36263. */
  36264. enabled: boolean;
  36265. /**
  36266. * If camera controls should be detached during the drag
  36267. */
  36268. detachCameraControls: boolean;
  36269. /**
  36270. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36271. */
  36272. useObjectOrienationForDragging: boolean;
  36273. private _options;
  36274. /**
  36275. * Creates a pointer drag behavior that can be attached to a mesh
  36276. * @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)
  36277. */
  36278. constructor(options?: {
  36279. dragAxis?: Vector3;
  36280. dragPlaneNormal?: Vector3;
  36281. });
  36282. /**
  36283. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36284. */
  36285. validateDrag: (targetPosition: Vector3) => boolean;
  36286. /**
  36287. * The name of the behavior
  36288. */
  36289. readonly name: string;
  36290. /**
  36291. * Initializes the behavior
  36292. */
  36293. init(): void;
  36294. private _tmpVector;
  36295. private _alternatePickedPoint;
  36296. private _worldDragAxis;
  36297. private _targetPosition;
  36298. private _attachedElement;
  36299. /**
  36300. * Attaches the drag behavior the passed in mesh
  36301. * @param ownerNode The mesh that will be dragged around once attached
  36302. */
  36303. attach(ownerNode: AbstractMesh): void;
  36304. /**
  36305. * Force relase the drag action by code.
  36306. */
  36307. releaseDrag(): void;
  36308. private _startDragRay;
  36309. private _lastPointerRay;
  36310. /**
  36311. * Simulates the start of a pointer drag event on the behavior
  36312. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36313. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36314. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36315. */
  36316. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36317. private _startDrag;
  36318. private _dragDelta;
  36319. private _moveDrag;
  36320. private _pickWithRayOnDragPlane;
  36321. private _pointA;
  36322. private _pointB;
  36323. private _pointC;
  36324. private _lineA;
  36325. private _lineB;
  36326. private _localAxis;
  36327. private _lookAt;
  36328. private _updateDragPlanePosition;
  36329. /**
  36330. * Detaches the behavior from the mesh
  36331. */
  36332. detach(): void;
  36333. }
  36334. }
  36335. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36336. import { Mesh } from "babylonjs/Meshes/mesh";
  36337. import { Behavior } from "babylonjs/Behaviors/behavior";
  36338. /**
  36339. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36340. */
  36341. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36342. private _dragBehaviorA;
  36343. private _dragBehaviorB;
  36344. private _startDistance;
  36345. private _initialScale;
  36346. private _targetScale;
  36347. private _ownerNode;
  36348. private _sceneRenderObserver;
  36349. /**
  36350. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36351. */
  36352. constructor();
  36353. /**
  36354. * The name of the behavior
  36355. */
  36356. readonly name: string;
  36357. /**
  36358. * Initializes the behavior
  36359. */
  36360. init(): void;
  36361. private _getCurrentDistance;
  36362. /**
  36363. * Attaches the scale behavior the passed in mesh
  36364. * @param ownerNode The mesh that will be scaled around once attached
  36365. */
  36366. attach(ownerNode: Mesh): void;
  36367. /**
  36368. * Detaches the behavior from the mesh
  36369. */
  36370. detach(): void;
  36371. }
  36372. }
  36373. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36374. import { Behavior } from "babylonjs/Behaviors/behavior";
  36375. import { Mesh } from "babylonjs/Meshes/mesh";
  36376. import { Observable } from "babylonjs/Misc/observable";
  36377. /**
  36378. * 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
  36379. */
  36380. export class SixDofDragBehavior implements Behavior<Mesh> {
  36381. private static _virtualScene;
  36382. private _ownerNode;
  36383. private _sceneRenderObserver;
  36384. private _scene;
  36385. private _targetPosition;
  36386. private _virtualOriginMesh;
  36387. private _virtualDragMesh;
  36388. private _pointerObserver;
  36389. private _moving;
  36390. private _startingOrientation;
  36391. /**
  36392. * 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)
  36393. */
  36394. private zDragFactor;
  36395. /**
  36396. * If the object should rotate to face the drag origin
  36397. */
  36398. rotateDraggedObject: boolean;
  36399. /**
  36400. * If the behavior is currently in a dragging state
  36401. */
  36402. dragging: boolean;
  36403. /**
  36404. * 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)
  36405. */
  36406. dragDeltaRatio: number;
  36407. /**
  36408. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36409. */
  36410. currentDraggingPointerID: number;
  36411. /**
  36412. * If camera controls should be detached during the drag
  36413. */
  36414. detachCameraControls: boolean;
  36415. /**
  36416. * Fires each time a drag starts
  36417. */
  36418. onDragStartObservable: Observable<{}>;
  36419. /**
  36420. * Fires each time a drag ends (eg. mouse release after drag)
  36421. */
  36422. onDragEndObservable: Observable<{}>;
  36423. /**
  36424. * 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
  36425. */
  36426. constructor();
  36427. /**
  36428. * The name of the behavior
  36429. */
  36430. readonly name: string;
  36431. /**
  36432. * Initializes the behavior
  36433. */
  36434. init(): void;
  36435. /**
  36436. * Attaches the scale behavior the passed in mesh
  36437. * @param ownerNode The mesh that will be scaled around once attached
  36438. */
  36439. attach(ownerNode: Mesh): void;
  36440. /**
  36441. * Detaches the behavior from the mesh
  36442. */
  36443. detach(): void;
  36444. }
  36445. }
  36446. declare module "babylonjs/Behaviors/Meshes/index" {
  36447. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36448. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36449. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36450. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36451. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36452. }
  36453. declare module "babylonjs/Behaviors/index" {
  36454. export * from "babylonjs/Behaviors/behavior";
  36455. export * from "babylonjs/Behaviors/Cameras/index";
  36456. export * from "babylonjs/Behaviors/Meshes/index";
  36457. }
  36458. declare module "babylonjs/Bones/boneIKController" {
  36459. import { Bone } from "babylonjs/Bones/bone";
  36460. import { Vector3 } from "babylonjs/Maths/math";
  36461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36462. import { Nullable } from "babylonjs/types";
  36463. /**
  36464. * Class used to apply inverse kinematics to bones
  36465. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36466. */
  36467. export class BoneIKController {
  36468. private static _tmpVecs;
  36469. private static _tmpQuat;
  36470. private static _tmpMats;
  36471. /**
  36472. * Gets or sets the target mesh
  36473. */
  36474. targetMesh: AbstractMesh;
  36475. /** Gets or sets the mesh used as pole */
  36476. poleTargetMesh: AbstractMesh;
  36477. /**
  36478. * Gets or sets the bone used as pole
  36479. */
  36480. poleTargetBone: Nullable<Bone>;
  36481. /**
  36482. * Gets or sets the target position
  36483. */
  36484. targetPosition: Vector3;
  36485. /**
  36486. * Gets or sets the pole target position
  36487. */
  36488. poleTargetPosition: Vector3;
  36489. /**
  36490. * Gets or sets the pole target local offset
  36491. */
  36492. poleTargetLocalOffset: Vector3;
  36493. /**
  36494. * Gets or sets the pole angle
  36495. */
  36496. poleAngle: number;
  36497. /**
  36498. * Gets or sets the mesh associated with the controller
  36499. */
  36500. mesh: AbstractMesh;
  36501. /**
  36502. * 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)
  36503. */
  36504. slerpAmount: number;
  36505. private _bone1Quat;
  36506. private _bone1Mat;
  36507. private _bone2Ang;
  36508. private _bone1;
  36509. private _bone2;
  36510. private _bone1Length;
  36511. private _bone2Length;
  36512. private _maxAngle;
  36513. private _maxReach;
  36514. private _rightHandedSystem;
  36515. private _bendAxis;
  36516. private _slerping;
  36517. private _adjustRoll;
  36518. /**
  36519. * Gets or sets maximum allowed angle
  36520. */
  36521. maxAngle: number;
  36522. /**
  36523. * Creates a new BoneIKController
  36524. * @param mesh defines the mesh to control
  36525. * @param bone defines the bone to control
  36526. * @param options defines options to set up the controller
  36527. */
  36528. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36529. targetMesh?: AbstractMesh;
  36530. poleTargetMesh?: AbstractMesh;
  36531. poleTargetBone?: Bone;
  36532. poleTargetLocalOffset?: Vector3;
  36533. poleAngle?: number;
  36534. bendAxis?: Vector3;
  36535. maxAngle?: number;
  36536. slerpAmount?: number;
  36537. });
  36538. private _setMaxAngle;
  36539. /**
  36540. * Force the controller to update the bones
  36541. */
  36542. update(): void;
  36543. }
  36544. }
  36545. declare module "babylonjs/Bones/boneLookController" {
  36546. import { Vector3, Space } from "babylonjs/Maths/math";
  36547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36548. import { Bone } from "babylonjs/Bones/bone";
  36549. /**
  36550. * Class used to make a bone look toward a point in space
  36551. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36552. */
  36553. export class BoneLookController {
  36554. private static _tmpVecs;
  36555. private static _tmpQuat;
  36556. private static _tmpMats;
  36557. /**
  36558. * The target Vector3 that the bone will look at
  36559. */
  36560. target: Vector3;
  36561. /**
  36562. * The mesh that the bone is attached to
  36563. */
  36564. mesh: AbstractMesh;
  36565. /**
  36566. * The bone that will be looking to the target
  36567. */
  36568. bone: Bone;
  36569. /**
  36570. * The up axis of the coordinate system that is used when the bone is rotated
  36571. */
  36572. upAxis: Vector3;
  36573. /**
  36574. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36575. */
  36576. upAxisSpace: Space;
  36577. /**
  36578. * Used to make an adjustment to the yaw of the bone
  36579. */
  36580. adjustYaw: number;
  36581. /**
  36582. * Used to make an adjustment to the pitch of the bone
  36583. */
  36584. adjustPitch: number;
  36585. /**
  36586. * Used to make an adjustment to the roll of the bone
  36587. */
  36588. adjustRoll: number;
  36589. /**
  36590. * 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)
  36591. */
  36592. slerpAmount: number;
  36593. private _minYaw;
  36594. private _maxYaw;
  36595. private _minPitch;
  36596. private _maxPitch;
  36597. private _minYawSin;
  36598. private _minYawCos;
  36599. private _maxYawSin;
  36600. private _maxYawCos;
  36601. private _midYawConstraint;
  36602. private _minPitchTan;
  36603. private _maxPitchTan;
  36604. private _boneQuat;
  36605. private _slerping;
  36606. private _transformYawPitch;
  36607. private _transformYawPitchInv;
  36608. private _firstFrameSkipped;
  36609. private _yawRange;
  36610. private _fowardAxis;
  36611. /**
  36612. * Gets or sets the minimum yaw angle that the bone can look to
  36613. */
  36614. minYaw: number;
  36615. /**
  36616. * Gets or sets the maximum yaw angle that the bone can look to
  36617. */
  36618. maxYaw: number;
  36619. /**
  36620. * Gets or sets the minimum pitch angle that the bone can look to
  36621. */
  36622. minPitch: number;
  36623. /**
  36624. * Gets or sets the maximum pitch angle that the bone can look to
  36625. */
  36626. maxPitch: number;
  36627. /**
  36628. * Create a BoneLookController
  36629. * @param mesh the mesh that the bone belongs to
  36630. * @param bone the bone that will be looking to the target
  36631. * @param target the target Vector3 to look at
  36632. * @param options optional settings:
  36633. * * maxYaw: the maximum angle the bone will yaw to
  36634. * * minYaw: the minimum angle the bone will yaw to
  36635. * * maxPitch: the maximum angle the bone will pitch to
  36636. * * minPitch: the minimum angle the bone will yaw to
  36637. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36638. * * upAxis: the up axis of the coordinate system
  36639. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36640. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36641. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36642. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36643. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36644. * * adjustRoll: used to make an adjustment to the roll of the bone
  36645. **/
  36646. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36647. maxYaw?: number;
  36648. minYaw?: number;
  36649. maxPitch?: number;
  36650. minPitch?: number;
  36651. slerpAmount?: number;
  36652. upAxis?: Vector3;
  36653. upAxisSpace?: Space;
  36654. yawAxis?: Vector3;
  36655. pitchAxis?: Vector3;
  36656. adjustYaw?: number;
  36657. adjustPitch?: number;
  36658. adjustRoll?: number;
  36659. });
  36660. /**
  36661. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36662. */
  36663. update(): void;
  36664. private _getAngleDiff;
  36665. private _getAngleBetween;
  36666. private _isAngleBetween;
  36667. }
  36668. }
  36669. declare module "babylonjs/Bones/index" {
  36670. export * from "babylonjs/Bones/bone";
  36671. export * from "babylonjs/Bones/boneIKController";
  36672. export * from "babylonjs/Bones/boneLookController";
  36673. export * from "babylonjs/Bones/skeleton";
  36674. }
  36675. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36676. import { Nullable } from "babylonjs/types";
  36677. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36678. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36679. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36680. /**
  36681. * Manage the gamepad inputs to control an arc rotate camera.
  36682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36683. */
  36684. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36685. /**
  36686. * Defines the camera the input is attached to.
  36687. */
  36688. camera: ArcRotateCamera;
  36689. /**
  36690. * Defines the gamepad the input is gathering event from.
  36691. */
  36692. gamepad: Nullable<Gamepad>;
  36693. /**
  36694. * Defines the gamepad rotation sensiblity.
  36695. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36696. */
  36697. gamepadRotationSensibility: number;
  36698. /**
  36699. * Defines the gamepad move sensiblity.
  36700. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36701. */
  36702. gamepadMoveSensibility: number;
  36703. private _onGamepadConnectedObserver;
  36704. private _onGamepadDisconnectedObserver;
  36705. /**
  36706. * Attach the input controls to a specific dom element to get the input from.
  36707. * @param element Defines the element the controls should be listened from
  36708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36709. */
  36710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36711. /**
  36712. * Detach the current controls from the specified dom element.
  36713. * @param element Defines the element to stop listening the inputs from
  36714. */
  36715. detachControl(element: Nullable<HTMLElement>): void;
  36716. /**
  36717. * Update the current camera state depending on the inputs that have been used this frame.
  36718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36719. */
  36720. checkInputs(): void;
  36721. /**
  36722. * Gets the class name of the current intput.
  36723. * @returns the class name
  36724. */
  36725. getClassName(): string;
  36726. /**
  36727. * Get the friendly name associated with the input class.
  36728. * @returns the input friendly name
  36729. */
  36730. getSimpleName(): string;
  36731. }
  36732. }
  36733. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36734. import { Nullable } from "babylonjs/types";
  36735. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36737. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36738. interface ArcRotateCameraInputsManager {
  36739. /**
  36740. * Add orientation input support to the input manager.
  36741. * @returns the current input manager
  36742. */
  36743. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36744. }
  36745. }
  36746. /**
  36747. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36748. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36749. */
  36750. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36751. /**
  36752. * Defines the camera the input is attached to.
  36753. */
  36754. camera: ArcRotateCamera;
  36755. /**
  36756. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36757. */
  36758. alphaCorrection: number;
  36759. /**
  36760. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36761. */
  36762. gammaCorrection: number;
  36763. private _alpha;
  36764. private _gamma;
  36765. private _dirty;
  36766. private _deviceOrientationHandler;
  36767. /**
  36768. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36769. */
  36770. constructor();
  36771. /**
  36772. * Attach the input controls to a specific dom element to get the input from.
  36773. * @param element Defines the element the controls should be listened from
  36774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36775. */
  36776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36777. /** @hidden */
  36778. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36779. /**
  36780. * Update the current camera state depending on the inputs that have been used this frame.
  36781. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36782. */
  36783. checkInputs(): void;
  36784. /**
  36785. * Detach the current controls from the specified dom element.
  36786. * @param element Defines the element to stop listening the inputs from
  36787. */
  36788. detachControl(element: Nullable<HTMLElement>): void;
  36789. /**
  36790. * Gets the class name of the current intput.
  36791. * @returns the class name
  36792. */
  36793. getClassName(): string;
  36794. /**
  36795. * Get the friendly name associated with the input class.
  36796. * @returns the input friendly name
  36797. */
  36798. getSimpleName(): string;
  36799. }
  36800. }
  36801. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36802. import { Nullable } from "babylonjs/types";
  36803. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36804. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36805. /**
  36806. * Listen to mouse events to control the camera.
  36807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36808. */
  36809. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36810. /**
  36811. * Defines the camera the input is attached to.
  36812. */
  36813. camera: FlyCamera;
  36814. /**
  36815. * Defines if touch is enabled. (Default is true.)
  36816. */
  36817. touchEnabled: boolean;
  36818. /**
  36819. * Defines the buttons associated with the input to handle camera rotation.
  36820. */
  36821. buttons: number[];
  36822. /**
  36823. * Assign buttons for Yaw control.
  36824. */
  36825. buttonsYaw: number[];
  36826. /**
  36827. * Assign buttons for Pitch control.
  36828. */
  36829. buttonsPitch: number[];
  36830. /**
  36831. * Assign buttons for Roll control.
  36832. */
  36833. buttonsRoll: number[];
  36834. /**
  36835. * Detect if any button is being pressed while mouse is moved.
  36836. * -1 = Mouse locked.
  36837. * 0 = Left button.
  36838. * 1 = Middle Button.
  36839. * 2 = Right Button.
  36840. */
  36841. activeButton: number;
  36842. /**
  36843. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36844. * Higher values reduce its sensitivity.
  36845. */
  36846. angularSensibility: number;
  36847. private _mousemoveCallback;
  36848. private _observer;
  36849. private _rollObserver;
  36850. private previousPosition;
  36851. private noPreventDefault;
  36852. private element;
  36853. /**
  36854. * Listen to mouse events to control the camera.
  36855. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36857. */
  36858. constructor(touchEnabled?: boolean);
  36859. /**
  36860. * Attach the mouse control to the HTML DOM element.
  36861. * @param element Defines the element that listens to the input events.
  36862. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36863. */
  36864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36865. /**
  36866. * Detach the current controls from the specified dom element.
  36867. * @param element Defines the element to stop listening the inputs from
  36868. */
  36869. detachControl(element: Nullable<HTMLElement>): void;
  36870. /**
  36871. * Gets the class name of the current input.
  36872. * @returns the class name.
  36873. */
  36874. getClassName(): string;
  36875. /**
  36876. * Get the friendly name associated with the input class.
  36877. * @returns the input's friendly name.
  36878. */
  36879. getSimpleName(): string;
  36880. private _pointerInput;
  36881. private _onMouseMove;
  36882. /**
  36883. * Rotate camera by mouse offset.
  36884. */
  36885. private rotateCamera;
  36886. }
  36887. }
  36888. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36889. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36890. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36891. /**
  36892. * Default Inputs manager for the FlyCamera.
  36893. * It groups all the default supported inputs for ease of use.
  36894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36895. */
  36896. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36897. /**
  36898. * Instantiates a new FlyCameraInputsManager.
  36899. * @param camera Defines the camera the inputs belong to.
  36900. */
  36901. constructor(camera: FlyCamera);
  36902. /**
  36903. * Add keyboard input support to the input manager.
  36904. * @returns the new FlyCameraKeyboardMoveInput().
  36905. */
  36906. addKeyboard(): FlyCameraInputsManager;
  36907. /**
  36908. * Add mouse input support to the input manager.
  36909. * @param touchEnabled Enable touch screen support.
  36910. * @returns the new FlyCameraMouseInput().
  36911. */
  36912. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36913. }
  36914. }
  36915. declare module "babylonjs/Cameras/flyCamera" {
  36916. import { Scene } from "babylonjs/scene";
  36917. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36919. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36920. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36921. /**
  36922. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36923. * such as in a 3D Space Shooter or a Flight Simulator.
  36924. */
  36925. export class FlyCamera extends TargetCamera {
  36926. /**
  36927. * Define the collision ellipsoid of the camera.
  36928. * This is helpful for simulating a camera body, like a player's body.
  36929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36930. */
  36931. ellipsoid: Vector3;
  36932. /**
  36933. * Define an offset for the position of the ellipsoid around the camera.
  36934. * This can be helpful if the camera is attached away from the player's body center,
  36935. * such as at its head.
  36936. */
  36937. ellipsoidOffset: Vector3;
  36938. /**
  36939. * Enable or disable collisions of the camera with the rest of the scene objects.
  36940. */
  36941. checkCollisions: boolean;
  36942. /**
  36943. * Enable or disable gravity on the camera.
  36944. */
  36945. applyGravity: boolean;
  36946. /**
  36947. * Define the current direction the camera is moving to.
  36948. */
  36949. cameraDirection: Vector3;
  36950. /**
  36951. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36952. * This overrides and empties cameraRotation.
  36953. */
  36954. rotationQuaternion: Quaternion;
  36955. /**
  36956. * Track Roll to maintain the wanted Rolling when looking around.
  36957. */
  36958. _trackRoll: number;
  36959. /**
  36960. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36961. */
  36962. rollCorrect: number;
  36963. /**
  36964. * Mimic a banked turn, Rolling the camera when Yawing.
  36965. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36966. */
  36967. bankedTurn: boolean;
  36968. /**
  36969. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36970. */
  36971. bankedTurnLimit: number;
  36972. /**
  36973. * Value of 0 disables the banked Roll.
  36974. * Value of 1 is equal to the Yaw angle in radians.
  36975. */
  36976. bankedTurnMultiplier: number;
  36977. /**
  36978. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36979. */
  36980. inputs: FlyCameraInputsManager;
  36981. /**
  36982. * Gets the input sensibility for mouse input.
  36983. * Higher values reduce sensitivity.
  36984. */
  36985. /**
  36986. * Sets the input sensibility for a mouse input.
  36987. * Higher values reduce sensitivity.
  36988. */
  36989. angularSensibility: number;
  36990. /**
  36991. * Get the keys for camera movement forward.
  36992. */
  36993. /**
  36994. * Set the keys for camera movement forward.
  36995. */
  36996. keysForward: number[];
  36997. /**
  36998. * Get the keys for camera movement backward.
  36999. */
  37000. keysBackward: number[];
  37001. /**
  37002. * Get the keys for camera movement up.
  37003. */
  37004. /**
  37005. * Set the keys for camera movement up.
  37006. */
  37007. keysUp: number[];
  37008. /**
  37009. * Get the keys for camera movement down.
  37010. */
  37011. /**
  37012. * Set the keys for camera movement down.
  37013. */
  37014. keysDown: number[];
  37015. /**
  37016. * Get the keys for camera movement left.
  37017. */
  37018. /**
  37019. * Set the keys for camera movement left.
  37020. */
  37021. keysLeft: number[];
  37022. /**
  37023. * Set the keys for camera movement right.
  37024. */
  37025. /**
  37026. * Set the keys for camera movement right.
  37027. */
  37028. keysRight: number[];
  37029. /**
  37030. * Event raised when the camera collides with a mesh in the scene.
  37031. */
  37032. onCollide: (collidedMesh: AbstractMesh) => void;
  37033. private _collider;
  37034. private _needMoveForGravity;
  37035. private _oldPosition;
  37036. private _diffPosition;
  37037. private _newPosition;
  37038. /** @hidden */
  37039. _localDirection: Vector3;
  37040. /** @hidden */
  37041. _transformedDirection: Vector3;
  37042. /**
  37043. * Instantiates a FlyCamera.
  37044. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37045. * such as in a 3D Space Shooter or a Flight Simulator.
  37046. * @param name Define the name of the camera in the scene.
  37047. * @param position Define the starting position of the camera in the scene.
  37048. * @param scene Define the scene the camera belongs to.
  37049. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37050. */
  37051. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37052. /**
  37053. * Attach a control to the HTML DOM element.
  37054. * @param element Defines the element that listens to the input events.
  37055. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37056. */
  37057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37058. /**
  37059. * Detach a control from the HTML DOM element.
  37060. * The camera will stop reacting to that input.
  37061. * @param element Defines the element that listens to the input events.
  37062. */
  37063. detachControl(element: HTMLElement): void;
  37064. private _collisionMask;
  37065. /**
  37066. * Get the mask that the camera ignores in collision events.
  37067. */
  37068. /**
  37069. * Set the mask that the camera ignores in collision events.
  37070. */
  37071. collisionMask: number;
  37072. /** @hidden */
  37073. _collideWithWorld(displacement: Vector3): void;
  37074. /** @hidden */
  37075. private _onCollisionPositionChange;
  37076. /** @hidden */
  37077. _checkInputs(): void;
  37078. /** @hidden */
  37079. _decideIfNeedsToMove(): boolean;
  37080. /** @hidden */
  37081. _updatePosition(): void;
  37082. /**
  37083. * Restore the Roll to its target value at the rate specified.
  37084. * @param rate - Higher means slower restoring.
  37085. * @hidden
  37086. */
  37087. restoreRoll(rate: number): void;
  37088. /**
  37089. * Destroy the camera and release the current resources held by it.
  37090. */
  37091. dispose(): void;
  37092. /**
  37093. * Get the current object class name.
  37094. * @returns the class name.
  37095. */
  37096. getClassName(): string;
  37097. }
  37098. }
  37099. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37100. import { Nullable } from "babylonjs/types";
  37101. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37102. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37103. /**
  37104. * Listen to keyboard events to control the camera.
  37105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37106. */
  37107. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37108. /**
  37109. * Defines the camera the input is attached to.
  37110. */
  37111. camera: FlyCamera;
  37112. /**
  37113. * The list of keyboard keys used to control the forward move of the camera.
  37114. */
  37115. keysForward: number[];
  37116. /**
  37117. * The list of keyboard keys used to control the backward move of the camera.
  37118. */
  37119. keysBackward: number[];
  37120. /**
  37121. * The list of keyboard keys used to control the forward move of the camera.
  37122. */
  37123. keysUp: number[];
  37124. /**
  37125. * The list of keyboard keys used to control the backward move of the camera.
  37126. */
  37127. keysDown: number[];
  37128. /**
  37129. * The list of keyboard keys used to control the right strafe move of the camera.
  37130. */
  37131. keysRight: number[];
  37132. /**
  37133. * The list of keyboard keys used to control the left strafe move of the camera.
  37134. */
  37135. keysLeft: number[];
  37136. private _keys;
  37137. private _onCanvasBlurObserver;
  37138. private _onKeyboardObserver;
  37139. private _engine;
  37140. private _scene;
  37141. /**
  37142. * Attach the input controls to a specific dom element to get the input from.
  37143. * @param element Defines the element the controls should be listened from
  37144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37145. */
  37146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37147. /**
  37148. * Detach the current controls from the specified dom element.
  37149. * @param element Defines the element to stop listening the inputs from
  37150. */
  37151. detachControl(element: Nullable<HTMLElement>): void;
  37152. /**
  37153. * Gets the class name of the current intput.
  37154. * @returns the class name
  37155. */
  37156. getClassName(): string;
  37157. /** @hidden */
  37158. _onLostFocus(e: FocusEvent): void;
  37159. /**
  37160. * Get the friendly name associated with the input class.
  37161. * @returns the input friendly name
  37162. */
  37163. getSimpleName(): string;
  37164. /**
  37165. * Update the current camera state depending on the inputs that have been used this frame.
  37166. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37167. */
  37168. checkInputs(): void;
  37169. }
  37170. }
  37171. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37172. import { Nullable } from "babylonjs/types";
  37173. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37174. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37175. /**
  37176. * Manage the mouse wheel inputs to control a follow camera.
  37177. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37178. */
  37179. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37180. /**
  37181. * Defines the camera the input is attached to.
  37182. */
  37183. camera: FollowCamera;
  37184. /**
  37185. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37186. */
  37187. axisControlRadius: boolean;
  37188. /**
  37189. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37190. */
  37191. axisControlHeight: boolean;
  37192. /**
  37193. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37194. */
  37195. axisControlRotation: boolean;
  37196. /**
  37197. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37198. * relation to mouseWheel events.
  37199. */
  37200. wheelPrecision: number;
  37201. /**
  37202. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37203. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37204. */
  37205. wheelDeltaPercentage: number;
  37206. private _wheel;
  37207. private _observer;
  37208. /**
  37209. * Attach the input controls to a specific dom element to get the input from.
  37210. * @param element Defines the element the controls should be listened from
  37211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37212. */
  37213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37214. /**
  37215. * Detach the current controls from the specified dom element.
  37216. * @param element Defines the element to stop listening the inputs from
  37217. */
  37218. detachControl(element: Nullable<HTMLElement>): void;
  37219. /**
  37220. * Gets the class name of the current intput.
  37221. * @returns the class name
  37222. */
  37223. getClassName(): string;
  37224. /**
  37225. * Get the friendly name associated with the input class.
  37226. * @returns the input friendly name
  37227. */
  37228. getSimpleName(): string;
  37229. }
  37230. }
  37231. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37232. import { Nullable } from "babylonjs/types";
  37233. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37234. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37235. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37236. /**
  37237. * Manage the pointers inputs to control an follow camera.
  37238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37239. */
  37240. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37241. /**
  37242. * Defines the camera the input is attached to.
  37243. */
  37244. camera: FollowCamera;
  37245. /**
  37246. * Gets the class name of the current input.
  37247. * @returns the class name
  37248. */
  37249. getClassName(): string;
  37250. /**
  37251. * Defines the pointer angular sensibility along the X axis or how fast is
  37252. * the camera rotating.
  37253. * A negative number will reverse the axis direction.
  37254. */
  37255. angularSensibilityX: number;
  37256. /**
  37257. * Defines the pointer angular sensibility along the Y axis or how fast is
  37258. * the camera rotating.
  37259. * A negative number will reverse the axis direction.
  37260. */
  37261. angularSensibilityY: number;
  37262. /**
  37263. * Defines the pointer pinch precision or how fast is the camera zooming.
  37264. * A negative number will reverse the axis direction.
  37265. */
  37266. pinchPrecision: number;
  37267. /**
  37268. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37269. * from 0.
  37270. * It defines the percentage of current camera.radius to use as delta when
  37271. * pinch zoom is used.
  37272. */
  37273. pinchDeltaPercentage: number;
  37274. /**
  37275. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37276. */
  37277. axisXControlRadius: boolean;
  37278. /**
  37279. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37280. */
  37281. axisXControlHeight: boolean;
  37282. /**
  37283. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37284. */
  37285. axisXControlRotation: boolean;
  37286. /**
  37287. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37288. */
  37289. axisYControlRadius: boolean;
  37290. /**
  37291. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37292. */
  37293. axisYControlHeight: boolean;
  37294. /**
  37295. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37296. */
  37297. axisYControlRotation: boolean;
  37298. /**
  37299. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37300. */
  37301. axisPinchControlRadius: boolean;
  37302. /**
  37303. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37304. */
  37305. axisPinchControlHeight: boolean;
  37306. /**
  37307. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37308. */
  37309. axisPinchControlRotation: boolean;
  37310. /**
  37311. * Log error messages if basic misconfiguration has occurred.
  37312. */
  37313. warningEnable: boolean;
  37314. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37315. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37316. private _warningCounter;
  37317. private _warning;
  37318. }
  37319. }
  37320. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37321. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37322. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37323. /**
  37324. * Default Inputs manager for the FollowCamera.
  37325. * It groups all the default supported inputs for ease of use.
  37326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37327. */
  37328. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37329. /**
  37330. * Instantiates a new FollowCameraInputsManager.
  37331. * @param camera Defines the camera the inputs belong to
  37332. */
  37333. constructor(camera: FollowCamera);
  37334. /**
  37335. * Add keyboard input support to the input manager.
  37336. * @returns the current input manager
  37337. */
  37338. addKeyboard(): FollowCameraInputsManager;
  37339. /**
  37340. * Add mouse wheel input support to the input manager.
  37341. * @returns the current input manager
  37342. */
  37343. addMouseWheel(): FollowCameraInputsManager;
  37344. /**
  37345. * Add pointers input support to the input manager.
  37346. * @returns the current input manager
  37347. */
  37348. addPointers(): FollowCameraInputsManager;
  37349. /**
  37350. * Add orientation input support to the input manager.
  37351. * @returns the current input manager
  37352. */
  37353. addVRDeviceOrientation(): FollowCameraInputsManager;
  37354. }
  37355. }
  37356. declare module "babylonjs/Cameras/followCamera" {
  37357. import { Nullable } from "babylonjs/types";
  37358. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37359. import { Scene } from "babylonjs/scene";
  37360. import { Vector3 } from "babylonjs/Maths/math";
  37361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37362. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37363. /**
  37364. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37365. * an arc rotate version arcFollowCamera are available.
  37366. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37367. */
  37368. export class FollowCamera extends TargetCamera {
  37369. /**
  37370. * Distance the follow camera should follow an object at
  37371. */
  37372. radius: number;
  37373. /**
  37374. * Minimum allowed distance of the camera to the axis of rotation
  37375. * (The camera can not get closer).
  37376. * This can help limiting how the Camera is able to move in the scene.
  37377. */
  37378. lowerRadiusLimit: Nullable<number>;
  37379. /**
  37380. * Maximum allowed distance of the camera to the axis of rotation
  37381. * (The camera can not get further).
  37382. * This can help limiting how the Camera is able to move in the scene.
  37383. */
  37384. upperRadiusLimit: Nullable<number>;
  37385. /**
  37386. * Define a rotation offset between the camera and the object it follows
  37387. */
  37388. rotationOffset: number;
  37389. /**
  37390. * Minimum allowed angle to camera position relative to target object.
  37391. * This can help limiting how the Camera is able to move in the scene.
  37392. */
  37393. lowerRotationOffsetLimit: Nullable<number>;
  37394. /**
  37395. * Maximum allowed angle to camera position relative to target object.
  37396. * This can help limiting how the Camera is able to move in the scene.
  37397. */
  37398. upperRotationOffsetLimit: Nullable<number>;
  37399. /**
  37400. * Define a height offset between the camera and the object it follows.
  37401. * It can help following an object from the top (like a car chaing a plane)
  37402. */
  37403. heightOffset: number;
  37404. /**
  37405. * Minimum allowed height of camera position relative to target object.
  37406. * This can help limiting how the Camera is able to move in the scene.
  37407. */
  37408. lowerHeightOffsetLimit: Nullable<number>;
  37409. /**
  37410. * Maximum allowed height of camera position relative to target object.
  37411. * This can help limiting how the Camera is able to move in the scene.
  37412. */
  37413. upperHeightOffsetLimit: Nullable<number>;
  37414. /**
  37415. * Define how fast the camera can accelerate to follow it s target.
  37416. */
  37417. cameraAcceleration: number;
  37418. /**
  37419. * Define the speed limit of the camera following an object.
  37420. */
  37421. maxCameraSpeed: number;
  37422. /**
  37423. * Define the target of the camera.
  37424. */
  37425. lockedTarget: Nullable<AbstractMesh>;
  37426. /**
  37427. * Defines the input associated with the camera.
  37428. */
  37429. inputs: FollowCameraInputsManager;
  37430. /**
  37431. * Instantiates the follow camera.
  37432. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37433. * @param name Define the name of the camera in the scene
  37434. * @param position Define the position of the camera
  37435. * @param scene Define the scene the camera belong to
  37436. * @param lockedTarget Define the target of the camera
  37437. */
  37438. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37439. private _follow;
  37440. /**
  37441. * Attached controls to the current camera.
  37442. * @param element Defines the element the controls should be listened from
  37443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37444. */
  37445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37446. /**
  37447. * Detach the current controls from the camera.
  37448. * The camera will stop reacting to inputs.
  37449. * @param element Defines the element to stop listening the inputs from
  37450. */
  37451. detachControl(element: HTMLElement): void;
  37452. /** @hidden */
  37453. _checkInputs(): void;
  37454. private _checkLimits;
  37455. /**
  37456. * Gets the camera class name.
  37457. * @returns the class name
  37458. */
  37459. getClassName(): string;
  37460. }
  37461. /**
  37462. * Arc Rotate version of the follow camera.
  37463. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37464. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37465. */
  37466. export class ArcFollowCamera extends TargetCamera {
  37467. /** The longitudinal angle of the camera */
  37468. alpha: number;
  37469. /** The latitudinal angle of the camera */
  37470. beta: number;
  37471. /** The radius of the camera from its target */
  37472. radius: number;
  37473. /** Define the camera target (the messh it should follow) */
  37474. target: Nullable<AbstractMesh>;
  37475. private _cartesianCoordinates;
  37476. /**
  37477. * Instantiates a new ArcFollowCamera
  37478. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37479. * @param name Define the name of the camera
  37480. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37481. * @param beta Define the rotation angle of the camera around the elevation axis
  37482. * @param radius Define the radius of the camera from its target point
  37483. * @param target Define the target of the camera
  37484. * @param scene Define the scene the camera belongs to
  37485. */
  37486. constructor(name: string,
  37487. /** The longitudinal angle of the camera */
  37488. alpha: number,
  37489. /** The latitudinal angle of the camera */
  37490. beta: number,
  37491. /** The radius of the camera from its target */
  37492. radius: number,
  37493. /** Define the camera target (the messh it should follow) */
  37494. target: Nullable<AbstractMesh>, scene: Scene);
  37495. private _follow;
  37496. /** @hidden */
  37497. _checkInputs(): void;
  37498. /**
  37499. * Returns the class name of the object.
  37500. * It is mostly used internally for serialization purposes.
  37501. */
  37502. getClassName(): string;
  37503. }
  37504. }
  37505. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37507. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37508. import { Nullable } from "babylonjs/types";
  37509. /**
  37510. * Manage the keyboard inputs to control the movement of a follow camera.
  37511. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37512. */
  37513. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37514. /**
  37515. * Defines the camera the input is attached to.
  37516. */
  37517. camera: FollowCamera;
  37518. /**
  37519. * Defines the list of key codes associated with the up action (increase heightOffset)
  37520. */
  37521. keysHeightOffsetIncr: number[];
  37522. /**
  37523. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37524. */
  37525. keysHeightOffsetDecr: number[];
  37526. /**
  37527. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37528. */
  37529. keysHeightOffsetModifierAlt: boolean;
  37530. /**
  37531. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37532. */
  37533. keysHeightOffsetModifierCtrl: boolean;
  37534. /**
  37535. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37536. */
  37537. keysHeightOffsetModifierShift: boolean;
  37538. /**
  37539. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37540. */
  37541. keysRotationOffsetIncr: number[];
  37542. /**
  37543. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37544. */
  37545. keysRotationOffsetDecr: number[];
  37546. /**
  37547. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37548. */
  37549. keysRotationOffsetModifierAlt: boolean;
  37550. /**
  37551. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37552. */
  37553. keysRotationOffsetModifierCtrl: boolean;
  37554. /**
  37555. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37556. */
  37557. keysRotationOffsetModifierShift: boolean;
  37558. /**
  37559. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37560. */
  37561. keysRadiusIncr: number[];
  37562. /**
  37563. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37564. */
  37565. keysRadiusDecr: number[];
  37566. /**
  37567. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37568. */
  37569. keysRadiusModifierAlt: boolean;
  37570. /**
  37571. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37572. */
  37573. keysRadiusModifierCtrl: boolean;
  37574. /**
  37575. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37576. */
  37577. keysRadiusModifierShift: boolean;
  37578. /**
  37579. * Defines the rate of change of heightOffset.
  37580. */
  37581. heightSensibility: number;
  37582. /**
  37583. * Defines the rate of change of rotationOffset.
  37584. */
  37585. rotationSensibility: number;
  37586. /**
  37587. * Defines the rate of change of radius.
  37588. */
  37589. radiusSensibility: number;
  37590. private _keys;
  37591. private _ctrlPressed;
  37592. private _altPressed;
  37593. private _shiftPressed;
  37594. private _onCanvasBlurObserver;
  37595. private _onKeyboardObserver;
  37596. private _engine;
  37597. private _scene;
  37598. /**
  37599. * Attach the input controls to a specific dom element to get the input from.
  37600. * @param element Defines the element the controls should be listened from
  37601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37602. */
  37603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37604. /**
  37605. * Detach the current controls from the specified dom element.
  37606. * @param element Defines the element to stop listening the inputs from
  37607. */
  37608. detachControl(element: Nullable<HTMLElement>): void;
  37609. /**
  37610. * Update the current camera state depending on the inputs that have been used this frame.
  37611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37612. */
  37613. checkInputs(): void;
  37614. /**
  37615. * Gets the class name of the current input.
  37616. * @returns the class name
  37617. */
  37618. getClassName(): string;
  37619. /**
  37620. * Get the friendly name associated with the input class.
  37621. * @returns the input friendly name
  37622. */
  37623. getSimpleName(): string;
  37624. /**
  37625. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37626. * allow modification of the heightOffset value.
  37627. */
  37628. private _modifierHeightOffset;
  37629. /**
  37630. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37631. * allow modification of the rotationOffset value.
  37632. */
  37633. private _modifierRotationOffset;
  37634. /**
  37635. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37636. * allow modification of the radius value.
  37637. */
  37638. private _modifierRadius;
  37639. }
  37640. }
  37641. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37642. import { Nullable } from "babylonjs/types";
  37643. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37644. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37645. module "babylonjs/Cameras/freeCameraInputsManager" {
  37646. interface FreeCameraInputsManager {
  37647. /**
  37648. * Add orientation input support to the input manager.
  37649. * @returns the current input manager
  37650. */
  37651. addDeviceOrientation(): FreeCameraInputsManager;
  37652. }
  37653. }
  37654. /**
  37655. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37656. * Screen rotation is taken into account.
  37657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37658. */
  37659. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37660. private _camera;
  37661. private _screenOrientationAngle;
  37662. private _constantTranform;
  37663. private _screenQuaternion;
  37664. private _alpha;
  37665. private _beta;
  37666. private _gamma;
  37667. /**
  37668. * Instantiates a new input
  37669. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37670. */
  37671. constructor();
  37672. /**
  37673. * Define the camera controlled by the input.
  37674. */
  37675. camera: FreeCamera;
  37676. /**
  37677. * Attach the input controls to a specific dom element to get the input from.
  37678. * @param element Defines the element the controls should be listened from
  37679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37680. */
  37681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37682. private _orientationChanged;
  37683. private _deviceOrientation;
  37684. /**
  37685. * Detach the current controls from the specified dom element.
  37686. * @param element Defines the element to stop listening the inputs from
  37687. */
  37688. detachControl(element: Nullable<HTMLElement>): void;
  37689. /**
  37690. * Update the current camera state depending on the inputs that have been used this frame.
  37691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37692. */
  37693. checkInputs(): void;
  37694. /**
  37695. * Gets the class name of the current intput.
  37696. * @returns the class name
  37697. */
  37698. getClassName(): string;
  37699. /**
  37700. * Get the friendly name associated with the input class.
  37701. * @returns the input friendly name
  37702. */
  37703. getSimpleName(): string;
  37704. }
  37705. }
  37706. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37707. import { Nullable } from "babylonjs/types";
  37708. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37709. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37710. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37711. /**
  37712. * Manage the gamepad inputs to control a free camera.
  37713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37714. */
  37715. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37716. /**
  37717. * Define the camera the input is attached to.
  37718. */
  37719. camera: FreeCamera;
  37720. /**
  37721. * Define the Gamepad controlling the input
  37722. */
  37723. gamepad: Nullable<Gamepad>;
  37724. /**
  37725. * Defines the gamepad rotation sensiblity.
  37726. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37727. */
  37728. gamepadAngularSensibility: number;
  37729. /**
  37730. * Defines the gamepad move sensiblity.
  37731. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37732. */
  37733. gamepadMoveSensibility: number;
  37734. private _onGamepadConnectedObserver;
  37735. private _onGamepadDisconnectedObserver;
  37736. private _cameraTransform;
  37737. private _deltaTransform;
  37738. private _vector3;
  37739. private _vector2;
  37740. /**
  37741. * Attach the input controls to a specific dom element to get the input from.
  37742. * @param element Defines the element the controls should be listened from
  37743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37744. */
  37745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37746. /**
  37747. * Detach the current controls from the specified dom element.
  37748. * @param element Defines the element to stop listening the inputs from
  37749. */
  37750. detachControl(element: Nullable<HTMLElement>): void;
  37751. /**
  37752. * Update the current camera state depending on the inputs that have been used this frame.
  37753. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37754. */
  37755. checkInputs(): void;
  37756. /**
  37757. * Gets the class name of the current intput.
  37758. * @returns the class name
  37759. */
  37760. getClassName(): string;
  37761. /**
  37762. * Get the friendly name associated with the input class.
  37763. * @returns the input friendly name
  37764. */
  37765. getSimpleName(): string;
  37766. }
  37767. }
  37768. declare module "babylonjs/Misc/virtualJoystick" {
  37769. import { Nullable } from "babylonjs/types";
  37770. import { Vector3 } from "babylonjs/Maths/math";
  37771. /**
  37772. * Defines the potential axis of a Joystick
  37773. */
  37774. export enum JoystickAxis {
  37775. /** X axis */
  37776. X = 0,
  37777. /** Y axis */
  37778. Y = 1,
  37779. /** Z axis */
  37780. Z = 2
  37781. }
  37782. /**
  37783. * Class used to define virtual joystick (used in touch mode)
  37784. */
  37785. export class VirtualJoystick {
  37786. /**
  37787. * Gets or sets a boolean indicating that left and right values must be inverted
  37788. */
  37789. reverseLeftRight: boolean;
  37790. /**
  37791. * Gets or sets a boolean indicating that up and down values must be inverted
  37792. */
  37793. reverseUpDown: boolean;
  37794. /**
  37795. * Gets the offset value for the position (ie. the change of the position value)
  37796. */
  37797. deltaPosition: Vector3;
  37798. /**
  37799. * Gets a boolean indicating if the virtual joystick was pressed
  37800. */
  37801. pressed: boolean;
  37802. /**
  37803. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37804. */
  37805. static Canvas: Nullable<HTMLCanvasElement>;
  37806. private static _globalJoystickIndex;
  37807. private static vjCanvasContext;
  37808. private static vjCanvasWidth;
  37809. private static vjCanvasHeight;
  37810. private static halfWidth;
  37811. private _action;
  37812. private _axisTargetedByLeftAndRight;
  37813. private _axisTargetedByUpAndDown;
  37814. private _joystickSensibility;
  37815. private _inversedSensibility;
  37816. private _joystickPointerID;
  37817. private _joystickColor;
  37818. private _joystickPointerPos;
  37819. private _joystickPreviousPointerPos;
  37820. private _joystickPointerStartPos;
  37821. private _deltaJoystickVector;
  37822. private _leftJoystick;
  37823. private _touches;
  37824. private _onPointerDownHandlerRef;
  37825. private _onPointerMoveHandlerRef;
  37826. private _onPointerUpHandlerRef;
  37827. private _onResize;
  37828. /**
  37829. * Creates a new virtual joystick
  37830. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37831. */
  37832. constructor(leftJoystick?: boolean);
  37833. /**
  37834. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37835. * @param newJoystickSensibility defines the new sensibility
  37836. */
  37837. setJoystickSensibility(newJoystickSensibility: number): void;
  37838. private _onPointerDown;
  37839. private _onPointerMove;
  37840. private _onPointerUp;
  37841. /**
  37842. * Change the color of the virtual joystick
  37843. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37844. */
  37845. setJoystickColor(newColor: string): void;
  37846. /**
  37847. * Defines a callback to call when the joystick is touched
  37848. * @param action defines the callback
  37849. */
  37850. setActionOnTouch(action: () => any): void;
  37851. /**
  37852. * Defines which axis you'd like to control for left & right
  37853. * @param axis defines the axis to use
  37854. */
  37855. setAxisForLeftRight(axis: JoystickAxis): void;
  37856. /**
  37857. * Defines which axis you'd like to control for up & down
  37858. * @param axis defines the axis to use
  37859. */
  37860. setAxisForUpDown(axis: JoystickAxis): void;
  37861. private _drawVirtualJoystick;
  37862. /**
  37863. * Release internal HTML canvas
  37864. */
  37865. releaseCanvas(): void;
  37866. }
  37867. }
  37868. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37869. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37870. import { Nullable } from "babylonjs/types";
  37871. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37872. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37873. module "babylonjs/Cameras/freeCameraInputsManager" {
  37874. interface FreeCameraInputsManager {
  37875. /**
  37876. * Add virtual joystick input support to the input manager.
  37877. * @returns the current input manager
  37878. */
  37879. addVirtualJoystick(): FreeCameraInputsManager;
  37880. }
  37881. }
  37882. /**
  37883. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37885. */
  37886. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37887. /**
  37888. * Defines the camera the input is attached to.
  37889. */
  37890. camera: FreeCamera;
  37891. private _leftjoystick;
  37892. private _rightjoystick;
  37893. /**
  37894. * Gets the left stick of the virtual joystick.
  37895. * @returns The virtual Joystick
  37896. */
  37897. getLeftJoystick(): VirtualJoystick;
  37898. /**
  37899. * Gets the right stick of the virtual joystick.
  37900. * @returns The virtual Joystick
  37901. */
  37902. getRightJoystick(): VirtualJoystick;
  37903. /**
  37904. * Update the current camera state depending on the inputs that have been used this frame.
  37905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37906. */
  37907. checkInputs(): void;
  37908. /**
  37909. * Attach the input controls to a specific dom element to get the input from.
  37910. * @param element Defines the element the controls should be listened from
  37911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37912. */
  37913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37914. /**
  37915. * Detach the current controls from the specified dom element.
  37916. * @param element Defines the element to stop listening the inputs from
  37917. */
  37918. detachControl(element: Nullable<HTMLElement>): void;
  37919. /**
  37920. * Gets the class name of the current intput.
  37921. * @returns the class name
  37922. */
  37923. getClassName(): string;
  37924. /**
  37925. * Get the friendly name associated with the input class.
  37926. * @returns the input friendly name
  37927. */
  37928. getSimpleName(): string;
  37929. }
  37930. }
  37931. declare module "babylonjs/Cameras/Inputs/index" {
  37932. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37933. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37934. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37935. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37936. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37937. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37938. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37939. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37940. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37941. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37942. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37943. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37944. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37945. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37946. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37947. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37948. }
  37949. declare module "babylonjs/Cameras/touchCamera" {
  37950. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37951. import { Scene } from "babylonjs/scene";
  37952. import { Vector3 } from "babylonjs/Maths/math";
  37953. /**
  37954. * This represents a FPS type of camera controlled by touch.
  37955. * This is like a universal camera minus the Gamepad controls.
  37956. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37957. */
  37958. export class TouchCamera extends FreeCamera {
  37959. /**
  37960. * Defines the touch sensibility for rotation.
  37961. * The higher the faster.
  37962. */
  37963. touchAngularSensibility: number;
  37964. /**
  37965. * Defines the touch sensibility for move.
  37966. * The higher the faster.
  37967. */
  37968. touchMoveSensibility: number;
  37969. /**
  37970. * Instantiates a new touch camera.
  37971. * This represents a FPS type of camera controlled by touch.
  37972. * This is like a universal camera minus the Gamepad controls.
  37973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37974. * @param name Define the name of the camera in the scene
  37975. * @param position Define the start position of the camera in the scene
  37976. * @param scene Define the scene the camera belongs to
  37977. */
  37978. constructor(name: string, position: Vector3, scene: Scene);
  37979. /**
  37980. * Gets the current object class name.
  37981. * @return the class name
  37982. */
  37983. getClassName(): string;
  37984. /** @hidden */
  37985. _setupInputs(): void;
  37986. }
  37987. }
  37988. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37989. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37990. import { Scene } from "babylonjs/scene";
  37991. import { Vector3, Axis } from "babylonjs/Maths/math";
  37992. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37993. /**
  37994. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37995. * being tilted forward or back and left or right.
  37996. */
  37997. export class DeviceOrientationCamera extends FreeCamera {
  37998. private _initialQuaternion;
  37999. private _quaternionCache;
  38000. /**
  38001. * Creates a new device orientation camera
  38002. * @param name The name of the camera
  38003. * @param position The start position camera
  38004. * @param scene The scene the camera belongs to
  38005. */
  38006. constructor(name: string, position: Vector3, scene: Scene);
  38007. /**
  38008. * Gets the current instance class name ("DeviceOrientationCamera").
  38009. * This helps avoiding instanceof at run time.
  38010. * @returns the class name
  38011. */
  38012. getClassName(): string;
  38013. /**
  38014. * @hidden
  38015. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38016. */
  38017. _checkInputs(): void;
  38018. /**
  38019. * Reset the camera to its default orientation on the specified axis only.
  38020. * @param axis The axis to reset
  38021. */
  38022. resetToCurrentRotation(axis?: Axis): void;
  38023. }
  38024. }
  38025. declare module "babylonjs/Cameras/universalCamera" {
  38026. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38027. import { Scene } from "babylonjs/scene";
  38028. import { Vector3 } from "babylonjs/Maths/math";
  38029. /**
  38030. * 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,
  38031. * which still works and will still be found in many Playgrounds.
  38032. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38033. */
  38034. export class UniversalCamera extends TouchCamera {
  38035. /**
  38036. * Defines the gamepad rotation sensiblity.
  38037. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38038. */
  38039. gamepadAngularSensibility: number;
  38040. /**
  38041. * Defines the gamepad move sensiblity.
  38042. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38043. */
  38044. gamepadMoveSensibility: number;
  38045. /**
  38046. * 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,
  38047. * which still works and will still be found in many Playgrounds.
  38048. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38049. * @param name Define the name of the camera in the scene
  38050. * @param position Define the start position of the camera in the scene
  38051. * @param scene Define the scene the camera belongs to
  38052. */
  38053. constructor(name: string, position: Vector3, scene: Scene);
  38054. /**
  38055. * Gets the current object class name.
  38056. * @return the class name
  38057. */
  38058. getClassName(): string;
  38059. }
  38060. }
  38061. declare module "babylonjs/Cameras/gamepadCamera" {
  38062. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38063. import { Scene } from "babylonjs/scene";
  38064. import { Vector3 } from "babylonjs/Maths/math";
  38065. /**
  38066. * This represents a FPS type of camera. This is only here for back compat purpose.
  38067. * Please use the UniversalCamera instead as both are identical.
  38068. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38069. */
  38070. export class GamepadCamera extends UniversalCamera {
  38071. /**
  38072. * Instantiates a new Gamepad Camera
  38073. * This represents a FPS type of camera. This is only here for back compat purpose.
  38074. * Please use the UniversalCamera instead as both are identical.
  38075. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38076. * @param name Define the name of the camera in the scene
  38077. * @param position Define the start position of the camera in the scene
  38078. * @param scene Define the scene the camera belongs to
  38079. */
  38080. constructor(name: string, position: Vector3, scene: Scene);
  38081. /**
  38082. * Gets the current object class name.
  38083. * @return the class name
  38084. */
  38085. getClassName(): string;
  38086. }
  38087. }
  38088. declare module "babylonjs/Shaders/pass.fragment" {
  38089. /** @hidden */
  38090. export var passPixelShader: {
  38091. name: string;
  38092. shader: string;
  38093. };
  38094. }
  38095. declare module "babylonjs/Shaders/passCube.fragment" {
  38096. /** @hidden */
  38097. export var passCubePixelShader: {
  38098. name: string;
  38099. shader: string;
  38100. };
  38101. }
  38102. declare module "babylonjs/PostProcesses/passPostProcess" {
  38103. import { Nullable } from "babylonjs/types";
  38104. import { Camera } from "babylonjs/Cameras/camera";
  38105. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38106. import { Engine } from "babylonjs/Engines/engine";
  38107. import "babylonjs/Shaders/pass.fragment";
  38108. import "babylonjs/Shaders/passCube.fragment";
  38109. /**
  38110. * PassPostProcess which produces an output the same as it's input
  38111. */
  38112. export class PassPostProcess extends PostProcess {
  38113. /**
  38114. * Creates the PassPostProcess
  38115. * @param name The name of the effect.
  38116. * @param options The required width/height ratio to downsize to before computing the render pass.
  38117. * @param camera The camera to apply the render pass to.
  38118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38119. * @param engine The engine which the post process will be applied. (default: current engine)
  38120. * @param reusable If the post process can be reused on the same frame. (default: false)
  38121. * @param textureType The type of texture to be used when performing the post processing.
  38122. * @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)
  38123. */
  38124. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38125. }
  38126. /**
  38127. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38128. */
  38129. export class PassCubePostProcess extends PostProcess {
  38130. private _face;
  38131. /**
  38132. * Gets or sets the cube face to display.
  38133. * * 0 is +X
  38134. * * 1 is -X
  38135. * * 2 is +Y
  38136. * * 3 is -Y
  38137. * * 4 is +Z
  38138. * * 5 is -Z
  38139. */
  38140. face: number;
  38141. /**
  38142. * Creates the PassCubePostProcess
  38143. * @param name The name of the effect.
  38144. * @param options The required width/height ratio to downsize to before computing the render pass.
  38145. * @param camera The camera to apply the render pass to.
  38146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38147. * @param engine The engine which the post process will be applied. (default: current engine)
  38148. * @param reusable If the post process can be reused on the same frame. (default: false)
  38149. * @param textureType The type of texture to be used when performing the post processing.
  38150. * @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)
  38151. */
  38152. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38153. }
  38154. }
  38155. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38156. /** @hidden */
  38157. export var anaglyphPixelShader: {
  38158. name: string;
  38159. shader: string;
  38160. };
  38161. }
  38162. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38163. import { Engine } from "babylonjs/Engines/engine";
  38164. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38165. import { Camera } from "babylonjs/Cameras/camera";
  38166. import "babylonjs/Shaders/anaglyph.fragment";
  38167. /**
  38168. * Postprocess used to generate anaglyphic rendering
  38169. */
  38170. export class AnaglyphPostProcess extends PostProcess {
  38171. private _passedProcess;
  38172. /**
  38173. * Creates a new AnaglyphPostProcess
  38174. * @param name defines postprocess name
  38175. * @param options defines creation options or target ratio scale
  38176. * @param rigCameras defines cameras using this postprocess
  38177. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38178. * @param engine defines hosting engine
  38179. * @param reusable defines if the postprocess will be reused multiple times per frame
  38180. */
  38181. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38182. }
  38183. }
  38184. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38185. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38186. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38187. import { Scene } from "babylonjs/scene";
  38188. import { Vector3 } from "babylonjs/Maths/math";
  38189. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38190. /**
  38191. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38192. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38193. */
  38194. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38195. /**
  38196. * Creates a new AnaglyphArcRotateCamera
  38197. * @param name defines camera name
  38198. * @param alpha defines alpha angle (in radians)
  38199. * @param beta defines beta angle (in radians)
  38200. * @param radius defines radius
  38201. * @param target defines camera target
  38202. * @param interaxialDistance defines distance between each color axis
  38203. * @param scene defines the hosting scene
  38204. */
  38205. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38206. /**
  38207. * Gets camera class name
  38208. * @returns AnaglyphArcRotateCamera
  38209. */
  38210. getClassName(): string;
  38211. }
  38212. }
  38213. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38214. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38215. import { Scene } from "babylonjs/scene";
  38216. import { Vector3 } from "babylonjs/Maths/math";
  38217. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38218. /**
  38219. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38220. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38221. */
  38222. export class AnaglyphFreeCamera extends FreeCamera {
  38223. /**
  38224. * Creates a new AnaglyphFreeCamera
  38225. * @param name defines camera name
  38226. * @param position defines initial position
  38227. * @param interaxialDistance defines distance between each color axis
  38228. * @param scene defines the hosting scene
  38229. */
  38230. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38231. /**
  38232. * Gets camera class name
  38233. * @returns AnaglyphFreeCamera
  38234. */
  38235. getClassName(): string;
  38236. }
  38237. }
  38238. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38239. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38240. import { Scene } from "babylonjs/scene";
  38241. import { Vector3 } from "babylonjs/Maths/math";
  38242. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38243. /**
  38244. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38245. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38246. */
  38247. export class AnaglyphGamepadCamera extends GamepadCamera {
  38248. /**
  38249. * Creates a new AnaglyphGamepadCamera
  38250. * @param name defines camera name
  38251. * @param position defines initial position
  38252. * @param interaxialDistance defines distance between each color axis
  38253. * @param scene defines the hosting scene
  38254. */
  38255. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38256. /**
  38257. * Gets camera class name
  38258. * @returns AnaglyphGamepadCamera
  38259. */
  38260. getClassName(): string;
  38261. }
  38262. }
  38263. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38264. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38265. import { Scene } from "babylonjs/scene";
  38266. import { Vector3 } from "babylonjs/Maths/math";
  38267. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38268. /**
  38269. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38270. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38271. */
  38272. export class AnaglyphUniversalCamera extends UniversalCamera {
  38273. /**
  38274. * Creates a new AnaglyphUniversalCamera
  38275. * @param name defines camera name
  38276. * @param position defines initial position
  38277. * @param interaxialDistance defines distance between each color axis
  38278. * @param scene defines the hosting scene
  38279. */
  38280. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38281. /**
  38282. * Gets camera class name
  38283. * @returns AnaglyphUniversalCamera
  38284. */
  38285. getClassName(): string;
  38286. }
  38287. }
  38288. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38289. /** @hidden */
  38290. export var stereoscopicInterlacePixelShader: {
  38291. name: string;
  38292. shader: string;
  38293. };
  38294. }
  38295. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38296. import { Camera } from "babylonjs/Cameras/camera";
  38297. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38298. import { Engine } from "babylonjs/Engines/engine";
  38299. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38300. /**
  38301. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38302. */
  38303. export class StereoscopicInterlacePostProcess extends PostProcess {
  38304. private _stepSize;
  38305. private _passedProcess;
  38306. /**
  38307. * Initializes a StereoscopicInterlacePostProcess
  38308. * @param name The name of the effect.
  38309. * @param rigCameras The rig cameras to be appled to the post process
  38310. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38311. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38312. * @param engine The engine which the post process will be applied. (default: current engine)
  38313. * @param reusable If the post process can be reused on the same frame. (default: false)
  38314. */
  38315. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38316. }
  38317. }
  38318. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38319. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38320. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38321. import { Scene } from "babylonjs/scene";
  38322. import { Vector3 } from "babylonjs/Maths/math";
  38323. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38324. /**
  38325. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38326. * @see http://doc.babylonjs.com/features/cameras
  38327. */
  38328. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38329. /**
  38330. * Creates a new StereoscopicArcRotateCamera
  38331. * @param name defines camera name
  38332. * @param alpha defines alpha angle (in radians)
  38333. * @param beta defines beta angle (in radians)
  38334. * @param radius defines radius
  38335. * @param target defines camera target
  38336. * @param interaxialDistance defines distance between each color axis
  38337. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38338. * @param scene defines the hosting scene
  38339. */
  38340. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38341. /**
  38342. * Gets camera class name
  38343. * @returns StereoscopicArcRotateCamera
  38344. */
  38345. getClassName(): string;
  38346. }
  38347. }
  38348. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38349. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38350. import { Scene } from "babylonjs/scene";
  38351. import { Vector3 } from "babylonjs/Maths/math";
  38352. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38353. /**
  38354. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38355. * @see http://doc.babylonjs.com/features/cameras
  38356. */
  38357. export class StereoscopicFreeCamera extends FreeCamera {
  38358. /**
  38359. * Creates a new StereoscopicFreeCamera
  38360. * @param name defines camera name
  38361. * @param position defines initial position
  38362. * @param interaxialDistance defines distance between each color axis
  38363. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38364. * @param scene defines the hosting scene
  38365. */
  38366. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38367. /**
  38368. * Gets camera class name
  38369. * @returns StereoscopicFreeCamera
  38370. */
  38371. getClassName(): string;
  38372. }
  38373. }
  38374. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38375. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38376. import { Scene } from "babylonjs/scene";
  38377. import { Vector3 } from "babylonjs/Maths/math";
  38378. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38379. /**
  38380. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38381. * @see http://doc.babylonjs.com/features/cameras
  38382. */
  38383. export class StereoscopicGamepadCamera extends GamepadCamera {
  38384. /**
  38385. * Creates a new StereoscopicGamepadCamera
  38386. * @param name defines camera name
  38387. * @param position defines initial position
  38388. * @param interaxialDistance defines distance between each color axis
  38389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38390. * @param scene defines the hosting scene
  38391. */
  38392. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38393. /**
  38394. * Gets camera class name
  38395. * @returns StereoscopicGamepadCamera
  38396. */
  38397. getClassName(): string;
  38398. }
  38399. }
  38400. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38401. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38402. import { Scene } from "babylonjs/scene";
  38403. import { Vector3 } from "babylonjs/Maths/math";
  38404. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38405. /**
  38406. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38407. * @see http://doc.babylonjs.com/features/cameras
  38408. */
  38409. export class StereoscopicUniversalCamera extends UniversalCamera {
  38410. /**
  38411. * Creates a new StereoscopicUniversalCamera
  38412. * @param name defines camera name
  38413. * @param position defines initial position
  38414. * @param interaxialDistance defines distance between each color axis
  38415. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38416. * @param scene defines the hosting scene
  38417. */
  38418. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38419. /**
  38420. * Gets camera class name
  38421. * @returns StereoscopicUniversalCamera
  38422. */
  38423. getClassName(): string;
  38424. }
  38425. }
  38426. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38427. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38428. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38429. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38430. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38431. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38432. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38433. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38434. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38435. }
  38436. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38437. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38438. import { Scene } from "babylonjs/scene";
  38439. import { Vector3 } from "babylonjs/Maths/math";
  38440. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38441. /**
  38442. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38443. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38444. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38445. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38446. */
  38447. export class VirtualJoysticksCamera extends FreeCamera {
  38448. /**
  38449. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38450. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38451. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38452. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38453. * @param name Define the name of the camera in the scene
  38454. * @param position Define the start position of the camera in the scene
  38455. * @param scene Define the scene the camera belongs to
  38456. */
  38457. constructor(name: string, position: Vector3, scene: Scene);
  38458. /**
  38459. * Gets the current object class name.
  38460. * @return the class name
  38461. */
  38462. getClassName(): string;
  38463. }
  38464. }
  38465. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38466. import { Matrix } from "babylonjs/Maths/math";
  38467. /**
  38468. * This represents all the required metrics to create a VR camera.
  38469. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38470. */
  38471. export class VRCameraMetrics {
  38472. /**
  38473. * Define the horizontal resolution off the screen.
  38474. */
  38475. hResolution: number;
  38476. /**
  38477. * Define the vertical resolution off the screen.
  38478. */
  38479. vResolution: number;
  38480. /**
  38481. * Define the horizontal screen size.
  38482. */
  38483. hScreenSize: number;
  38484. /**
  38485. * Define the vertical screen size.
  38486. */
  38487. vScreenSize: number;
  38488. /**
  38489. * Define the vertical screen center position.
  38490. */
  38491. vScreenCenter: number;
  38492. /**
  38493. * Define the distance of the eyes to the screen.
  38494. */
  38495. eyeToScreenDistance: number;
  38496. /**
  38497. * Define the distance between both lenses
  38498. */
  38499. lensSeparationDistance: number;
  38500. /**
  38501. * Define the distance between both viewer's eyes.
  38502. */
  38503. interpupillaryDistance: number;
  38504. /**
  38505. * Define the distortion factor of the VR postprocess.
  38506. * Please, touch with care.
  38507. */
  38508. distortionK: number[];
  38509. /**
  38510. * Define the chromatic aberration correction factors for the VR post process.
  38511. */
  38512. chromaAbCorrection: number[];
  38513. /**
  38514. * Define the scale factor of the post process.
  38515. * The smaller the better but the slower.
  38516. */
  38517. postProcessScaleFactor: number;
  38518. /**
  38519. * Define an offset for the lens center.
  38520. */
  38521. lensCenterOffset: number;
  38522. /**
  38523. * Define if the current vr camera should compensate the distortion of the lense or not.
  38524. */
  38525. compensateDistortion: boolean;
  38526. /**
  38527. * Gets the rendering aspect ratio based on the provided resolutions.
  38528. */
  38529. readonly aspectRatio: number;
  38530. /**
  38531. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38532. */
  38533. readonly aspectRatioFov: number;
  38534. /**
  38535. * @hidden
  38536. */
  38537. readonly leftHMatrix: Matrix;
  38538. /**
  38539. * @hidden
  38540. */
  38541. readonly rightHMatrix: Matrix;
  38542. /**
  38543. * @hidden
  38544. */
  38545. readonly leftPreViewMatrix: Matrix;
  38546. /**
  38547. * @hidden
  38548. */
  38549. readonly rightPreViewMatrix: Matrix;
  38550. /**
  38551. * Get the default VRMetrics based on the most generic setup.
  38552. * @returns the default vr metrics
  38553. */
  38554. static GetDefault(): VRCameraMetrics;
  38555. }
  38556. }
  38557. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38558. /** @hidden */
  38559. export var vrDistortionCorrectionPixelShader: {
  38560. name: string;
  38561. shader: string;
  38562. };
  38563. }
  38564. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38565. import { Camera } from "babylonjs/Cameras/camera";
  38566. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38567. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38568. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38569. /**
  38570. * VRDistortionCorrectionPostProcess used for mobile VR
  38571. */
  38572. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38573. private _isRightEye;
  38574. private _distortionFactors;
  38575. private _postProcessScaleFactor;
  38576. private _lensCenterOffset;
  38577. private _scaleIn;
  38578. private _scaleFactor;
  38579. private _lensCenter;
  38580. /**
  38581. * Initializes the VRDistortionCorrectionPostProcess
  38582. * @param name The name of the effect.
  38583. * @param camera The camera to apply the render pass to.
  38584. * @param isRightEye If this is for the right eye distortion
  38585. * @param vrMetrics All the required metrics for the VR camera
  38586. */
  38587. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38588. }
  38589. }
  38590. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38591. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38592. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38593. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38594. import { Scene } from "babylonjs/scene";
  38595. import { Vector3 } from "babylonjs/Maths/math";
  38596. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38597. import "babylonjs/Cameras/RigModes/vrRigMode";
  38598. /**
  38599. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38600. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38601. */
  38602. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38603. /**
  38604. * Creates a new VRDeviceOrientationArcRotateCamera
  38605. * @param name defines camera name
  38606. * @param alpha defines the camera rotation along the logitudinal axis
  38607. * @param beta defines the camera rotation along the latitudinal axis
  38608. * @param radius defines the camera distance from its target
  38609. * @param target defines the camera target
  38610. * @param scene defines the scene the camera belongs to
  38611. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38612. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38613. */
  38614. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38615. /**
  38616. * Gets camera class name
  38617. * @returns VRDeviceOrientationArcRotateCamera
  38618. */
  38619. getClassName(): string;
  38620. }
  38621. }
  38622. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38623. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38624. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38625. import { Scene } from "babylonjs/scene";
  38626. import { Vector3 } from "babylonjs/Maths/math";
  38627. import "babylonjs/Cameras/RigModes/vrRigMode";
  38628. /**
  38629. * Camera used to simulate VR rendering (based on FreeCamera)
  38630. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38631. */
  38632. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38633. /**
  38634. * Creates a new VRDeviceOrientationFreeCamera
  38635. * @param name defines camera name
  38636. * @param position defines the start position of the camera
  38637. * @param scene defines the scene the camera belongs to
  38638. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38639. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38640. */
  38641. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38642. /**
  38643. * Gets camera class name
  38644. * @returns VRDeviceOrientationFreeCamera
  38645. */
  38646. getClassName(): string;
  38647. }
  38648. }
  38649. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38650. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38651. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38652. import { Scene } from "babylonjs/scene";
  38653. import { Vector3 } from "babylonjs/Maths/math";
  38654. /**
  38655. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38656. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38657. */
  38658. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38659. /**
  38660. * Creates a new VRDeviceOrientationGamepadCamera
  38661. * @param name defines camera name
  38662. * @param position defines the start position of the camera
  38663. * @param scene defines the scene the camera belongs to
  38664. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38665. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38666. */
  38667. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38668. /**
  38669. * Gets camera class name
  38670. * @returns VRDeviceOrientationGamepadCamera
  38671. */
  38672. getClassName(): string;
  38673. }
  38674. }
  38675. declare module "babylonjs/Gamepads/xboxGamepad" {
  38676. import { Observable } from "babylonjs/Misc/observable";
  38677. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38678. /**
  38679. * Defines supported buttons for XBox360 compatible gamepads
  38680. */
  38681. export enum Xbox360Button {
  38682. /** A */
  38683. A = 0,
  38684. /** B */
  38685. B = 1,
  38686. /** X */
  38687. X = 2,
  38688. /** Y */
  38689. Y = 3,
  38690. /** Start */
  38691. Start = 4,
  38692. /** Back */
  38693. Back = 5,
  38694. /** Left button */
  38695. LB = 6,
  38696. /** Right button */
  38697. RB = 7,
  38698. /** Left stick */
  38699. LeftStick = 8,
  38700. /** Right stick */
  38701. RightStick = 9
  38702. }
  38703. /** Defines values for XBox360 DPad */
  38704. export enum Xbox360Dpad {
  38705. /** Up */
  38706. Up = 0,
  38707. /** Down */
  38708. Down = 1,
  38709. /** Left */
  38710. Left = 2,
  38711. /** Right */
  38712. Right = 3
  38713. }
  38714. /**
  38715. * Defines a XBox360 gamepad
  38716. */
  38717. export class Xbox360Pad extends Gamepad {
  38718. private _leftTrigger;
  38719. private _rightTrigger;
  38720. private _onlefttriggerchanged;
  38721. private _onrighttriggerchanged;
  38722. private _onbuttondown;
  38723. private _onbuttonup;
  38724. private _ondpaddown;
  38725. private _ondpadup;
  38726. /** Observable raised when a button is pressed */
  38727. onButtonDownObservable: Observable<Xbox360Button>;
  38728. /** Observable raised when a button is released */
  38729. onButtonUpObservable: Observable<Xbox360Button>;
  38730. /** Observable raised when a pad is pressed */
  38731. onPadDownObservable: Observable<Xbox360Dpad>;
  38732. /** Observable raised when a pad is released */
  38733. onPadUpObservable: Observable<Xbox360Dpad>;
  38734. private _buttonA;
  38735. private _buttonB;
  38736. private _buttonX;
  38737. private _buttonY;
  38738. private _buttonBack;
  38739. private _buttonStart;
  38740. private _buttonLB;
  38741. private _buttonRB;
  38742. private _buttonLeftStick;
  38743. private _buttonRightStick;
  38744. private _dPadUp;
  38745. private _dPadDown;
  38746. private _dPadLeft;
  38747. private _dPadRight;
  38748. private _isXboxOnePad;
  38749. /**
  38750. * Creates a new XBox360 gamepad object
  38751. * @param id defines the id of this gamepad
  38752. * @param index defines its index
  38753. * @param gamepad defines the internal HTML gamepad object
  38754. * @param xboxOne defines if it is a XBox One gamepad
  38755. */
  38756. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38757. /**
  38758. * Defines the callback to call when left trigger is pressed
  38759. * @param callback defines the callback to use
  38760. */
  38761. onlefttriggerchanged(callback: (value: number) => void): void;
  38762. /**
  38763. * Defines the callback to call when right trigger is pressed
  38764. * @param callback defines the callback to use
  38765. */
  38766. onrighttriggerchanged(callback: (value: number) => void): void;
  38767. /**
  38768. * Gets the left trigger value
  38769. */
  38770. /**
  38771. * Sets the left trigger value
  38772. */
  38773. leftTrigger: number;
  38774. /**
  38775. * Gets the right trigger value
  38776. */
  38777. /**
  38778. * Sets the right trigger value
  38779. */
  38780. rightTrigger: number;
  38781. /**
  38782. * Defines the callback to call when a button is pressed
  38783. * @param callback defines the callback to use
  38784. */
  38785. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38786. /**
  38787. * Defines the callback to call when a button is released
  38788. * @param callback defines the callback to use
  38789. */
  38790. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38791. /**
  38792. * Defines the callback to call when a pad is pressed
  38793. * @param callback defines the callback to use
  38794. */
  38795. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38796. /**
  38797. * Defines the callback to call when a pad is released
  38798. * @param callback defines the callback to use
  38799. */
  38800. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38801. private _setButtonValue;
  38802. private _setDPadValue;
  38803. /**
  38804. * Gets the value of the `A` button
  38805. */
  38806. /**
  38807. * Sets the value of the `A` button
  38808. */
  38809. buttonA: number;
  38810. /**
  38811. * Gets the value of the `B` button
  38812. */
  38813. /**
  38814. * Sets the value of the `B` button
  38815. */
  38816. buttonB: number;
  38817. /**
  38818. * Gets the value of the `X` button
  38819. */
  38820. /**
  38821. * Sets the value of the `X` button
  38822. */
  38823. buttonX: number;
  38824. /**
  38825. * Gets the value of the `Y` button
  38826. */
  38827. /**
  38828. * Sets the value of the `Y` button
  38829. */
  38830. buttonY: number;
  38831. /**
  38832. * Gets the value of the `Start` button
  38833. */
  38834. /**
  38835. * Sets the value of the `Start` button
  38836. */
  38837. buttonStart: number;
  38838. /**
  38839. * Gets the value of the `Back` button
  38840. */
  38841. /**
  38842. * Sets the value of the `Back` button
  38843. */
  38844. buttonBack: number;
  38845. /**
  38846. * Gets the value of the `Left` button
  38847. */
  38848. /**
  38849. * Sets the value of the `Left` button
  38850. */
  38851. buttonLB: number;
  38852. /**
  38853. * Gets the value of the `Right` button
  38854. */
  38855. /**
  38856. * Sets the value of the `Right` button
  38857. */
  38858. buttonRB: number;
  38859. /**
  38860. * Gets the value of the Left joystick
  38861. */
  38862. /**
  38863. * Sets the value of the Left joystick
  38864. */
  38865. buttonLeftStick: number;
  38866. /**
  38867. * Gets the value of the Right joystick
  38868. */
  38869. /**
  38870. * Sets the value of the Right joystick
  38871. */
  38872. buttonRightStick: number;
  38873. /**
  38874. * Gets the value of D-pad up
  38875. */
  38876. /**
  38877. * Sets the value of D-pad up
  38878. */
  38879. dPadUp: number;
  38880. /**
  38881. * Gets the value of D-pad down
  38882. */
  38883. /**
  38884. * Sets the value of D-pad down
  38885. */
  38886. dPadDown: number;
  38887. /**
  38888. * Gets the value of D-pad left
  38889. */
  38890. /**
  38891. * Sets the value of D-pad left
  38892. */
  38893. dPadLeft: number;
  38894. /**
  38895. * Gets the value of D-pad right
  38896. */
  38897. /**
  38898. * Sets the value of D-pad right
  38899. */
  38900. dPadRight: number;
  38901. /**
  38902. * Force the gamepad to synchronize with device values
  38903. */
  38904. update(): void;
  38905. /**
  38906. * Disposes the gamepad
  38907. */
  38908. dispose(): void;
  38909. }
  38910. }
  38911. declare module "babylonjs/Materials/pushMaterial" {
  38912. import { Nullable } from "babylonjs/types";
  38913. import { Scene } from "babylonjs/scene";
  38914. import { Matrix } from "babylonjs/Maths/math";
  38915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38916. import { Mesh } from "babylonjs/Meshes/mesh";
  38917. import { Material } from "babylonjs/Materials/material";
  38918. import { Effect } from "babylonjs/Materials/effect";
  38919. /**
  38920. * Base class of materials working in push mode in babylon JS
  38921. * @hidden
  38922. */
  38923. export class PushMaterial extends Material {
  38924. protected _activeEffect: Effect;
  38925. protected _normalMatrix: Matrix;
  38926. /**
  38927. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38928. * This means that the material can keep using a previous shader while a new one is being compiled.
  38929. * This is mostly used when shader parallel compilation is supported (true by default)
  38930. */
  38931. allowShaderHotSwapping: boolean;
  38932. constructor(name: string, scene: Scene);
  38933. getEffect(): Effect;
  38934. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38935. /**
  38936. * Binds the given world matrix to the active effect
  38937. *
  38938. * @param world the matrix to bind
  38939. */
  38940. bindOnlyWorldMatrix(world: Matrix): void;
  38941. /**
  38942. * Binds the given normal matrix to the active effect
  38943. *
  38944. * @param normalMatrix the matrix to bind
  38945. */
  38946. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38947. bind(world: Matrix, mesh?: Mesh): void;
  38948. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38949. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38950. }
  38951. }
  38952. declare module "babylonjs/Materials/materialFlags" {
  38953. /**
  38954. * This groups all the flags used to control the materials channel.
  38955. */
  38956. export class MaterialFlags {
  38957. private static _DiffuseTextureEnabled;
  38958. /**
  38959. * Are diffuse textures enabled in the application.
  38960. */
  38961. static DiffuseTextureEnabled: boolean;
  38962. private static _AmbientTextureEnabled;
  38963. /**
  38964. * Are ambient textures enabled in the application.
  38965. */
  38966. static AmbientTextureEnabled: boolean;
  38967. private static _OpacityTextureEnabled;
  38968. /**
  38969. * Are opacity textures enabled in the application.
  38970. */
  38971. static OpacityTextureEnabled: boolean;
  38972. private static _ReflectionTextureEnabled;
  38973. /**
  38974. * Are reflection textures enabled in the application.
  38975. */
  38976. static ReflectionTextureEnabled: boolean;
  38977. private static _EmissiveTextureEnabled;
  38978. /**
  38979. * Are emissive textures enabled in the application.
  38980. */
  38981. static EmissiveTextureEnabled: boolean;
  38982. private static _SpecularTextureEnabled;
  38983. /**
  38984. * Are specular textures enabled in the application.
  38985. */
  38986. static SpecularTextureEnabled: boolean;
  38987. private static _BumpTextureEnabled;
  38988. /**
  38989. * Are bump textures enabled in the application.
  38990. */
  38991. static BumpTextureEnabled: boolean;
  38992. private static _LightmapTextureEnabled;
  38993. /**
  38994. * Are lightmap textures enabled in the application.
  38995. */
  38996. static LightmapTextureEnabled: boolean;
  38997. private static _RefractionTextureEnabled;
  38998. /**
  38999. * Are refraction textures enabled in the application.
  39000. */
  39001. static RefractionTextureEnabled: boolean;
  39002. private static _ColorGradingTextureEnabled;
  39003. /**
  39004. * Are color grading textures enabled in the application.
  39005. */
  39006. static ColorGradingTextureEnabled: boolean;
  39007. private static _FresnelEnabled;
  39008. /**
  39009. * Are fresnels enabled in the application.
  39010. */
  39011. static FresnelEnabled: boolean;
  39012. private static _ClearCoatTextureEnabled;
  39013. /**
  39014. * Are clear coat textures enabled in the application.
  39015. */
  39016. static ClearCoatTextureEnabled: boolean;
  39017. private static _ClearCoatBumpTextureEnabled;
  39018. /**
  39019. * Are clear coat bump textures enabled in the application.
  39020. */
  39021. static ClearCoatBumpTextureEnabled: boolean;
  39022. private static _ClearCoatTintTextureEnabled;
  39023. /**
  39024. * Are clear coat tint textures enabled in the application.
  39025. */
  39026. static ClearCoatTintTextureEnabled: boolean;
  39027. private static _SheenTextureEnabled;
  39028. /**
  39029. * Are sheen textures enabled in the application.
  39030. */
  39031. static SheenTextureEnabled: boolean;
  39032. private static _AnisotropicTextureEnabled;
  39033. /**
  39034. * Are anisotropic textures enabled in the application.
  39035. */
  39036. static AnisotropicTextureEnabled: boolean;
  39037. }
  39038. }
  39039. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39040. /** @hidden */
  39041. export var defaultFragmentDeclaration: {
  39042. name: string;
  39043. shader: string;
  39044. };
  39045. }
  39046. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39047. /** @hidden */
  39048. export var defaultUboDeclaration: {
  39049. name: string;
  39050. shader: string;
  39051. };
  39052. }
  39053. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39054. /** @hidden */
  39055. export var lightFragmentDeclaration: {
  39056. name: string;
  39057. shader: string;
  39058. };
  39059. }
  39060. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39061. /** @hidden */
  39062. export var lightUboDeclaration: {
  39063. name: string;
  39064. shader: string;
  39065. };
  39066. }
  39067. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39068. /** @hidden */
  39069. export var lightsFragmentFunctions: {
  39070. name: string;
  39071. shader: string;
  39072. };
  39073. }
  39074. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39075. /** @hidden */
  39076. export var shadowsFragmentFunctions: {
  39077. name: string;
  39078. shader: string;
  39079. };
  39080. }
  39081. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39082. /** @hidden */
  39083. export var fresnelFunction: {
  39084. name: string;
  39085. shader: string;
  39086. };
  39087. }
  39088. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39089. /** @hidden */
  39090. export var reflectionFunction: {
  39091. name: string;
  39092. shader: string;
  39093. };
  39094. }
  39095. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39096. /** @hidden */
  39097. export var bumpFragmentFunctions: {
  39098. name: string;
  39099. shader: string;
  39100. };
  39101. }
  39102. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39103. /** @hidden */
  39104. export var logDepthDeclaration: {
  39105. name: string;
  39106. shader: string;
  39107. };
  39108. }
  39109. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39110. /** @hidden */
  39111. export var bumpFragment: {
  39112. name: string;
  39113. shader: string;
  39114. };
  39115. }
  39116. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39117. /** @hidden */
  39118. export var depthPrePass: {
  39119. name: string;
  39120. shader: string;
  39121. };
  39122. }
  39123. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39124. /** @hidden */
  39125. export var lightFragment: {
  39126. name: string;
  39127. shader: string;
  39128. };
  39129. }
  39130. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39131. /** @hidden */
  39132. export var logDepthFragment: {
  39133. name: string;
  39134. shader: string;
  39135. };
  39136. }
  39137. declare module "babylonjs/Shaders/default.fragment" {
  39138. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39139. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39140. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39141. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39142. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39143. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39144. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39145. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39146. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39147. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39148. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39149. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39150. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39151. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39152. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39153. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39154. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39155. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39156. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39157. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39158. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39159. /** @hidden */
  39160. export var defaultPixelShader: {
  39161. name: string;
  39162. shader: string;
  39163. };
  39164. }
  39165. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39166. /** @hidden */
  39167. export var defaultVertexDeclaration: {
  39168. name: string;
  39169. shader: string;
  39170. };
  39171. }
  39172. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39173. /** @hidden */
  39174. export var bumpVertexDeclaration: {
  39175. name: string;
  39176. shader: string;
  39177. };
  39178. }
  39179. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39180. /** @hidden */
  39181. export var bumpVertex: {
  39182. name: string;
  39183. shader: string;
  39184. };
  39185. }
  39186. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39187. /** @hidden */
  39188. export var fogVertex: {
  39189. name: string;
  39190. shader: string;
  39191. };
  39192. }
  39193. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39194. /** @hidden */
  39195. export var shadowsVertex: {
  39196. name: string;
  39197. shader: string;
  39198. };
  39199. }
  39200. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39201. /** @hidden */
  39202. export var pointCloudVertex: {
  39203. name: string;
  39204. shader: string;
  39205. };
  39206. }
  39207. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39208. /** @hidden */
  39209. export var logDepthVertex: {
  39210. name: string;
  39211. shader: string;
  39212. };
  39213. }
  39214. declare module "babylonjs/Shaders/default.vertex" {
  39215. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39216. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39218. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39219. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39220. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39221. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39222. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39223. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39224. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39225. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39226. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39227. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39228. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39229. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39230. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39231. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39232. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39233. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39234. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39235. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39236. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39237. /** @hidden */
  39238. export var defaultVertexShader: {
  39239. name: string;
  39240. shader: string;
  39241. };
  39242. }
  39243. declare module "babylonjs/Materials/standardMaterial" {
  39244. import { SmartArray } from "babylonjs/Misc/smartArray";
  39245. import { IAnimatable } from "babylonjs/Misc/tools";
  39246. import { Nullable } from "babylonjs/types";
  39247. import { Scene } from "babylonjs/scene";
  39248. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39249. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39251. import { Mesh } from "babylonjs/Meshes/mesh";
  39252. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39253. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39254. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39255. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39256. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39259. import "babylonjs/Shaders/default.fragment";
  39260. import "babylonjs/Shaders/default.vertex";
  39261. /** @hidden */
  39262. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39263. MAINUV1: boolean;
  39264. MAINUV2: boolean;
  39265. DIFFUSE: boolean;
  39266. DIFFUSEDIRECTUV: number;
  39267. AMBIENT: boolean;
  39268. AMBIENTDIRECTUV: number;
  39269. OPACITY: boolean;
  39270. OPACITYDIRECTUV: number;
  39271. OPACITYRGB: boolean;
  39272. REFLECTION: boolean;
  39273. EMISSIVE: boolean;
  39274. EMISSIVEDIRECTUV: number;
  39275. SPECULAR: boolean;
  39276. SPECULARDIRECTUV: number;
  39277. BUMP: boolean;
  39278. BUMPDIRECTUV: number;
  39279. PARALLAX: boolean;
  39280. PARALLAXOCCLUSION: boolean;
  39281. SPECULAROVERALPHA: boolean;
  39282. CLIPPLANE: boolean;
  39283. CLIPPLANE2: boolean;
  39284. CLIPPLANE3: boolean;
  39285. CLIPPLANE4: boolean;
  39286. ALPHATEST: boolean;
  39287. DEPTHPREPASS: boolean;
  39288. ALPHAFROMDIFFUSE: boolean;
  39289. POINTSIZE: boolean;
  39290. FOG: boolean;
  39291. SPECULARTERM: boolean;
  39292. DIFFUSEFRESNEL: boolean;
  39293. OPACITYFRESNEL: boolean;
  39294. REFLECTIONFRESNEL: boolean;
  39295. REFRACTIONFRESNEL: boolean;
  39296. EMISSIVEFRESNEL: boolean;
  39297. FRESNEL: boolean;
  39298. NORMAL: boolean;
  39299. UV1: boolean;
  39300. UV2: boolean;
  39301. VERTEXCOLOR: boolean;
  39302. VERTEXALPHA: boolean;
  39303. NUM_BONE_INFLUENCERS: number;
  39304. BonesPerMesh: number;
  39305. BONETEXTURE: boolean;
  39306. INSTANCES: boolean;
  39307. GLOSSINESS: boolean;
  39308. ROUGHNESS: boolean;
  39309. EMISSIVEASILLUMINATION: boolean;
  39310. LINKEMISSIVEWITHDIFFUSE: boolean;
  39311. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39312. LIGHTMAP: boolean;
  39313. LIGHTMAPDIRECTUV: number;
  39314. OBJECTSPACE_NORMALMAP: boolean;
  39315. USELIGHTMAPASSHADOWMAP: boolean;
  39316. REFLECTIONMAP_3D: boolean;
  39317. REFLECTIONMAP_SPHERICAL: boolean;
  39318. REFLECTIONMAP_PLANAR: boolean;
  39319. REFLECTIONMAP_CUBIC: boolean;
  39320. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39321. REFLECTIONMAP_PROJECTION: boolean;
  39322. REFLECTIONMAP_SKYBOX: boolean;
  39323. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39324. REFLECTIONMAP_EXPLICIT: boolean;
  39325. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39326. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39327. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39328. INVERTCUBICMAP: boolean;
  39329. LOGARITHMICDEPTH: boolean;
  39330. REFRACTION: boolean;
  39331. REFRACTIONMAP_3D: boolean;
  39332. REFLECTIONOVERALPHA: boolean;
  39333. TWOSIDEDLIGHTING: boolean;
  39334. SHADOWFLOAT: boolean;
  39335. MORPHTARGETS: boolean;
  39336. MORPHTARGETS_NORMAL: boolean;
  39337. MORPHTARGETS_TANGENT: boolean;
  39338. NUM_MORPH_INFLUENCERS: number;
  39339. NONUNIFORMSCALING: boolean;
  39340. PREMULTIPLYALPHA: boolean;
  39341. IMAGEPROCESSING: boolean;
  39342. VIGNETTE: boolean;
  39343. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39344. VIGNETTEBLENDMODEOPAQUE: boolean;
  39345. TONEMAPPING: boolean;
  39346. TONEMAPPING_ACES: boolean;
  39347. CONTRAST: boolean;
  39348. COLORCURVES: boolean;
  39349. COLORGRADING: boolean;
  39350. COLORGRADING3D: boolean;
  39351. SAMPLER3DGREENDEPTH: boolean;
  39352. SAMPLER3DBGRMAP: boolean;
  39353. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39354. /**
  39355. * If the reflection texture on this material is in linear color space
  39356. * @hidden
  39357. */
  39358. IS_REFLECTION_LINEAR: boolean;
  39359. /**
  39360. * If the refraction texture on this material is in linear color space
  39361. * @hidden
  39362. */
  39363. IS_REFRACTION_LINEAR: boolean;
  39364. EXPOSURE: boolean;
  39365. constructor();
  39366. setReflectionMode(modeToEnable: string): void;
  39367. }
  39368. /**
  39369. * This is the default material used in Babylon. It is the best trade off between quality
  39370. * and performances.
  39371. * @see http://doc.babylonjs.com/babylon101/materials
  39372. */
  39373. export class StandardMaterial extends PushMaterial {
  39374. private _diffuseTexture;
  39375. /**
  39376. * The basic texture of the material as viewed under a light.
  39377. */
  39378. diffuseTexture: Nullable<BaseTexture>;
  39379. private _ambientTexture;
  39380. /**
  39381. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39382. */
  39383. ambientTexture: Nullable<BaseTexture>;
  39384. private _opacityTexture;
  39385. /**
  39386. * Define the transparency of the material from a texture.
  39387. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39388. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39389. */
  39390. opacityTexture: Nullable<BaseTexture>;
  39391. private _reflectionTexture;
  39392. /**
  39393. * Define the texture used to display the reflection.
  39394. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39395. */
  39396. reflectionTexture: Nullable<BaseTexture>;
  39397. private _emissiveTexture;
  39398. /**
  39399. * Define texture of the material as if self lit.
  39400. * This will be mixed in the final result even in the absence of light.
  39401. */
  39402. emissiveTexture: Nullable<BaseTexture>;
  39403. private _specularTexture;
  39404. /**
  39405. * Define how the color and intensity of the highlight given by the light in the material.
  39406. */
  39407. specularTexture: Nullable<BaseTexture>;
  39408. private _bumpTexture;
  39409. /**
  39410. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39411. * 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.
  39412. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39413. */
  39414. bumpTexture: Nullable<BaseTexture>;
  39415. private _lightmapTexture;
  39416. /**
  39417. * Complex lighting can be computationally expensive to compute at runtime.
  39418. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39419. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39420. */
  39421. lightmapTexture: Nullable<BaseTexture>;
  39422. private _refractionTexture;
  39423. /**
  39424. * Define the texture used to display the refraction.
  39425. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39426. */
  39427. refractionTexture: Nullable<BaseTexture>;
  39428. /**
  39429. * The color of the material lit by the environmental background lighting.
  39430. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39431. */
  39432. ambientColor: Color3;
  39433. /**
  39434. * The basic color of the material as viewed under a light.
  39435. */
  39436. diffuseColor: Color3;
  39437. /**
  39438. * Define how the color and intensity of the highlight given by the light in the material.
  39439. */
  39440. specularColor: Color3;
  39441. /**
  39442. * Define the color of the material as if self lit.
  39443. * This will be mixed in the final result even in the absence of light.
  39444. */
  39445. emissiveColor: Color3;
  39446. /**
  39447. * Defines how sharp are the highlights in the material.
  39448. * The bigger the value the sharper giving a more glossy feeling to the result.
  39449. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39450. */
  39451. specularPower: number;
  39452. private _useAlphaFromDiffuseTexture;
  39453. /**
  39454. * Does the transparency come from the diffuse texture alpha channel.
  39455. */
  39456. useAlphaFromDiffuseTexture: boolean;
  39457. private _useEmissiveAsIllumination;
  39458. /**
  39459. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39460. */
  39461. useEmissiveAsIllumination: boolean;
  39462. private _linkEmissiveWithDiffuse;
  39463. /**
  39464. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39465. * the emissive level when the final color is close to one.
  39466. */
  39467. linkEmissiveWithDiffuse: boolean;
  39468. private _useSpecularOverAlpha;
  39469. /**
  39470. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39471. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39472. */
  39473. useSpecularOverAlpha: boolean;
  39474. private _useReflectionOverAlpha;
  39475. /**
  39476. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39477. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39478. */
  39479. useReflectionOverAlpha: boolean;
  39480. private _disableLighting;
  39481. /**
  39482. * Does lights from the scene impacts this material.
  39483. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39484. */
  39485. disableLighting: boolean;
  39486. private _useObjectSpaceNormalMap;
  39487. /**
  39488. * Allows using an object space normal map (instead of tangent space).
  39489. */
  39490. useObjectSpaceNormalMap: boolean;
  39491. private _useParallax;
  39492. /**
  39493. * Is parallax enabled or not.
  39494. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39495. */
  39496. useParallax: boolean;
  39497. private _useParallaxOcclusion;
  39498. /**
  39499. * Is parallax occlusion enabled or not.
  39500. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39501. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39502. */
  39503. useParallaxOcclusion: boolean;
  39504. /**
  39505. * 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.
  39506. */
  39507. parallaxScaleBias: number;
  39508. private _roughness;
  39509. /**
  39510. * Helps to define how blurry the reflections should appears in the material.
  39511. */
  39512. roughness: number;
  39513. /**
  39514. * In case of refraction, define the value of the indice of refraction.
  39515. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39516. */
  39517. indexOfRefraction: number;
  39518. /**
  39519. * Invert the refraction texture alongside the y axis.
  39520. * It can be useful with procedural textures or probe for instance.
  39521. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39522. */
  39523. invertRefractionY: boolean;
  39524. /**
  39525. * Defines the alpha limits in alpha test mode.
  39526. */
  39527. alphaCutOff: number;
  39528. private _useLightmapAsShadowmap;
  39529. /**
  39530. * In case of light mapping, define whether the map contains light or shadow informations.
  39531. */
  39532. useLightmapAsShadowmap: boolean;
  39533. private _diffuseFresnelParameters;
  39534. /**
  39535. * Define the diffuse fresnel parameters of the material.
  39536. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39537. */
  39538. diffuseFresnelParameters: FresnelParameters;
  39539. private _opacityFresnelParameters;
  39540. /**
  39541. * Define the opacity fresnel parameters of the material.
  39542. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39543. */
  39544. opacityFresnelParameters: FresnelParameters;
  39545. private _reflectionFresnelParameters;
  39546. /**
  39547. * Define the reflection fresnel parameters of the material.
  39548. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39549. */
  39550. reflectionFresnelParameters: FresnelParameters;
  39551. private _refractionFresnelParameters;
  39552. /**
  39553. * Define the refraction fresnel parameters of the material.
  39554. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39555. */
  39556. refractionFresnelParameters: FresnelParameters;
  39557. private _emissiveFresnelParameters;
  39558. /**
  39559. * Define the emissive fresnel parameters of the material.
  39560. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39561. */
  39562. emissiveFresnelParameters: FresnelParameters;
  39563. private _useReflectionFresnelFromSpecular;
  39564. /**
  39565. * If true automatically deducts the fresnels values from the material specularity.
  39566. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39567. */
  39568. useReflectionFresnelFromSpecular: boolean;
  39569. private _useGlossinessFromSpecularMapAlpha;
  39570. /**
  39571. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39572. */
  39573. useGlossinessFromSpecularMapAlpha: boolean;
  39574. private _maxSimultaneousLights;
  39575. /**
  39576. * Defines the maximum number of lights that can be used in the material
  39577. */
  39578. maxSimultaneousLights: number;
  39579. private _invertNormalMapX;
  39580. /**
  39581. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39582. */
  39583. invertNormalMapX: boolean;
  39584. private _invertNormalMapY;
  39585. /**
  39586. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39587. */
  39588. invertNormalMapY: boolean;
  39589. private _twoSidedLighting;
  39590. /**
  39591. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39592. */
  39593. twoSidedLighting: boolean;
  39594. /**
  39595. * Default configuration related to image processing available in the standard Material.
  39596. */
  39597. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39598. /**
  39599. * Gets the image processing configuration used either in this material.
  39600. */
  39601. /**
  39602. * Sets the Default image processing configuration used either in the this material.
  39603. *
  39604. * If sets to null, the scene one is in use.
  39605. */
  39606. imageProcessingConfiguration: ImageProcessingConfiguration;
  39607. /**
  39608. * Keep track of the image processing observer to allow dispose and replace.
  39609. */
  39610. private _imageProcessingObserver;
  39611. /**
  39612. * Attaches a new image processing configuration to the Standard Material.
  39613. * @param configuration
  39614. */
  39615. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39616. /**
  39617. * Gets wether the color curves effect is enabled.
  39618. */
  39619. /**
  39620. * Sets wether the color curves effect is enabled.
  39621. */
  39622. cameraColorCurvesEnabled: boolean;
  39623. /**
  39624. * Gets wether the color grading effect is enabled.
  39625. */
  39626. /**
  39627. * Gets wether the color grading effect is enabled.
  39628. */
  39629. cameraColorGradingEnabled: boolean;
  39630. /**
  39631. * Gets wether tonemapping is enabled or not.
  39632. */
  39633. /**
  39634. * Sets wether tonemapping is enabled or not
  39635. */
  39636. cameraToneMappingEnabled: boolean;
  39637. /**
  39638. * The camera exposure used on this material.
  39639. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39640. * This corresponds to a photographic exposure.
  39641. */
  39642. /**
  39643. * The camera exposure used on this material.
  39644. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39645. * This corresponds to a photographic exposure.
  39646. */
  39647. cameraExposure: number;
  39648. /**
  39649. * Gets The camera contrast used on this material.
  39650. */
  39651. /**
  39652. * Sets The camera contrast used on this material.
  39653. */
  39654. cameraContrast: number;
  39655. /**
  39656. * Gets the Color Grading 2D Lookup Texture.
  39657. */
  39658. /**
  39659. * Sets the Color Grading 2D Lookup Texture.
  39660. */
  39661. cameraColorGradingTexture: Nullable<BaseTexture>;
  39662. /**
  39663. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39664. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39665. * 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;
  39666. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39667. */
  39668. /**
  39669. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39670. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39671. * 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;
  39672. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39673. */
  39674. cameraColorCurves: Nullable<ColorCurves>;
  39675. /**
  39676. * Custom callback helping to override the default shader used in the material.
  39677. */
  39678. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39679. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39680. protected _worldViewProjectionMatrix: Matrix;
  39681. protected _globalAmbientColor: Color3;
  39682. protected _useLogarithmicDepth: boolean;
  39683. /**
  39684. * Instantiates a new standard material.
  39685. * This is the default material used in Babylon. It is the best trade off between quality
  39686. * and performances.
  39687. * @see http://doc.babylonjs.com/babylon101/materials
  39688. * @param name Define the name of the material in the scene
  39689. * @param scene Define the scene the material belong to
  39690. */
  39691. constructor(name: string, scene: Scene);
  39692. /**
  39693. * Gets a boolean indicating that current material needs to register RTT
  39694. */
  39695. readonly hasRenderTargetTextures: boolean;
  39696. /**
  39697. * Gets the current class name of the material e.g. "StandardMaterial"
  39698. * Mainly use in serialization.
  39699. * @returns the class name
  39700. */
  39701. getClassName(): string;
  39702. /**
  39703. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39704. * You can try switching to logarithmic depth.
  39705. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39706. */
  39707. useLogarithmicDepth: boolean;
  39708. /**
  39709. * Specifies if the material will require alpha blending
  39710. * @returns a boolean specifying if alpha blending is needed
  39711. */
  39712. needAlphaBlending(): boolean;
  39713. /**
  39714. * Specifies if this material should be rendered in alpha test mode
  39715. * @returns a boolean specifying if an alpha test is needed.
  39716. */
  39717. needAlphaTesting(): boolean;
  39718. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39719. /**
  39720. * Get the texture used for alpha test purpose.
  39721. * @returns the diffuse texture in case of the standard material.
  39722. */
  39723. getAlphaTestTexture(): Nullable<BaseTexture>;
  39724. /**
  39725. * Get if the submesh is ready to be used and all its information available.
  39726. * Child classes can use it to update shaders
  39727. * @param mesh defines the mesh to check
  39728. * @param subMesh defines which submesh to check
  39729. * @param useInstances specifies that instances should be used
  39730. * @returns a boolean indicating that the submesh is ready or not
  39731. */
  39732. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39733. /**
  39734. * Builds the material UBO layouts.
  39735. * Used internally during the effect preparation.
  39736. */
  39737. buildUniformLayout(): void;
  39738. /**
  39739. * Unbinds the material from the mesh
  39740. */
  39741. unbind(): void;
  39742. /**
  39743. * Binds the submesh to this material by preparing the effect and shader to draw
  39744. * @param world defines the world transformation matrix
  39745. * @param mesh defines the mesh containing the submesh
  39746. * @param subMesh defines the submesh to bind the material to
  39747. */
  39748. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39749. /**
  39750. * Get the list of animatables in the material.
  39751. * @returns the list of animatables object used in the material
  39752. */
  39753. getAnimatables(): IAnimatable[];
  39754. /**
  39755. * Gets the active textures from the material
  39756. * @returns an array of textures
  39757. */
  39758. getActiveTextures(): BaseTexture[];
  39759. /**
  39760. * Specifies if the material uses a texture
  39761. * @param texture defines the texture to check against the material
  39762. * @returns a boolean specifying if the material uses the texture
  39763. */
  39764. hasTexture(texture: BaseTexture): boolean;
  39765. /**
  39766. * Disposes the material
  39767. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39768. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39769. */
  39770. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39771. /**
  39772. * Makes a duplicate of the material, and gives it a new name
  39773. * @param name defines the new name for the duplicated material
  39774. * @returns the cloned material
  39775. */
  39776. clone(name: string): StandardMaterial;
  39777. /**
  39778. * Serializes this material in a JSON representation
  39779. * @returns the serialized material object
  39780. */
  39781. serialize(): any;
  39782. /**
  39783. * Creates a standard material from parsed material data
  39784. * @param source defines the JSON representation of the material
  39785. * @param scene defines the hosting scene
  39786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39787. * @returns a new standard material
  39788. */
  39789. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39790. /**
  39791. * Are diffuse textures enabled in the application.
  39792. */
  39793. static DiffuseTextureEnabled: boolean;
  39794. /**
  39795. * Are ambient textures enabled in the application.
  39796. */
  39797. static AmbientTextureEnabled: boolean;
  39798. /**
  39799. * Are opacity textures enabled in the application.
  39800. */
  39801. static OpacityTextureEnabled: boolean;
  39802. /**
  39803. * Are reflection textures enabled in the application.
  39804. */
  39805. static ReflectionTextureEnabled: boolean;
  39806. /**
  39807. * Are emissive textures enabled in the application.
  39808. */
  39809. static EmissiveTextureEnabled: boolean;
  39810. /**
  39811. * Are specular textures enabled in the application.
  39812. */
  39813. static SpecularTextureEnabled: boolean;
  39814. /**
  39815. * Are bump textures enabled in the application.
  39816. */
  39817. static BumpTextureEnabled: boolean;
  39818. /**
  39819. * Are lightmap textures enabled in the application.
  39820. */
  39821. static LightmapTextureEnabled: boolean;
  39822. /**
  39823. * Are refraction textures enabled in the application.
  39824. */
  39825. static RefractionTextureEnabled: boolean;
  39826. /**
  39827. * Are color grading textures enabled in the application.
  39828. */
  39829. static ColorGradingTextureEnabled: boolean;
  39830. /**
  39831. * Are fresnels enabled in the application.
  39832. */
  39833. static FresnelEnabled: boolean;
  39834. }
  39835. }
  39836. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39837. import { Scene } from "babylonjs/scene";
  39838. import { Texture } from "babylonjs/Materials/Textures/texture";
  39839. /**
  39840. * A class extending Texture allowing drawing on a texture
  39841. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39842. */
  39843. export class DynamicTexture extends Texture {
  39844. private _generateMipMaps;
  39845. private _canvas;
  39846. private _context;
  39847. private _engine;
  39848. /**
  39849. * Creates a DynamicTexture
  39850. * @param name defines the name of the texture
  39851. * @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
  39852. * @param scene defines the scene where you want the texture
  39853. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39854. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39855. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39856. */
  39857. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39858. /**
  39859. * Get the current class name of the texture useful for serialization or dynamic coding.
  39860. * @returns "DynamicTexture"
  39861. */
  39862. getClassName(): string;
  39863. /**
  39864. * Gets the current state of canRescale
  39865. */
  39866. readonly canRescale: boolean;
  39867. private _recreate;
  39868. /**
  39869. * Scales the texture
  39870. * @param ratio the scale factor to apply to both width and height
  39871. */
  39872. scale(ratio: number): void;
  39873. /**
  39874. * Resizes the texture
  39875. * @param width the new width
  39876. * @param height the new height
  39877. */
  39878. scaleTo(width: number, height: number): void;
  39879. /**
  39880. * Gets the context of the canvas used by the texture
  39881. * @returns the canvas context of the dynamic texture
  39882. */
  39883. getContext(): CanvasRenderingContext2D;
  39884. /**
  39885. * Clears the texture
  39886. */
  39887. clear(): void;
  39888. /**
  39889. * Updates the texture
  39890. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39891. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39892. */
  39893. update(invertY?: boolean, premulAlpha?: boolean): void;
  39894. /**
  39895. * Draws text onto the texture
  39896. * @param text defines the text to be drawn
  39897. * @param x defines the placement of the text from the left
  39898. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39899. * @param font defines the font to be used with font-style, font-size, font-name
  39900. * @param color defines the color used for the text
  39901. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39902. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39903. * @param update defines whether texture is immediately update (default is true)
  39904. */
  39905. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39906. /**
  39907. * Clones the texture
  39908. * @returns the clone of the texture.
  39909. */
  39910. clone(): DynamicTexture;
  39911. /**
  39912. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39913. * @returns a serialized dynamic texture object
  39914. */
  39915. serialize(): any;
  39916. /** @hidden */
  39917. _rebuild(): void;
  39918. }
  39919. }
  39920. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39921. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39922. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39923. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39924. /** @hidden */
  39925. export var imageProcessingPixelShader: {
  39926. name: string;
  39927. shader: string;
  39928. };
  39929. }
  39930. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39931. import { Nullable } from "babylonjs/types";
  39932. import { Color4 } from "babylonjs/Maths/math";
  39933. import { Camera } from "babylonjs/Cameras/camera";
  39934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39935. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39936. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39937. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39938. import { Engine } from "babylonjs/Engines/engine";
  39939. import "babylonjs/Shaders/imageProcessing.fragment";
  39940. import "babylonjs/Shaders/postprocess.vertex";
  39941. /**
  39942. * ImageProcessingPostProcess
  39943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39944. */
  39945. export class ImageProcessingPostProcess extends PostProcess {
  39946. /**
  39947. * Default configuration related to image processing available in the PBR Material.
  39948. */
  39949. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39950. /**
  39951. * Gets the image processing configuration used either in this material.
  39952. */
  39953. /**
  39954. * Sets the Default image processing configuration used either in the this material.
  39955. *
  39956. * If sets to null, the scene one is in use.
  39957. */
  39958. imageProcessingConfiguration: ImageProcessingConfiguration;
  39959. /**
  39960. * Keep track of the image processing observer to allow dispose and replace.
  39961. */
  39962. private _imageProcessingObserver;
  39963. /**
  39964. * Attaches a new image processing configuration to the PBR Material.
  39965. * @param configuration
  39966. */
  39967. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39968. /**
  39969. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39970. */
  39971. /**
  39972. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39973. */
  39974. colorCurves: Nullable<ColorCurves>;
  39975. /**
  39976. * Gets wether the color curves effect is enabled.
  39977. */
  39978. /**
  39979. * Sets wether the color curves effect is enabled.
  39980. */
  39981. colorCurvesEnabled: boolean;
  39982. /**
  39983. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39984. */
  39985. /**
  39986. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39987. */
  39988. colorGradingTexture: Nullable<BaseTexture>;
  39989. /**
  39990. * Gets wether the color grading effect is enabled.
  39991. */
  39992. /**
  39993. * Gets wether the color grading effect is enabled.
  39994. */
  39995. colorGradingEnabled: boolean;
  39996. /**
  39997. * Gets exposure used in the effect.
  39998. */
  39999. /**
  40000. * Sets exposure used in the effect.
  40001. */
  40002. exposure: number;
  40003. /**
  40004. * Gets wether tonemapping is enabled or not.
  40005. */
  40006. /**
  40007. * Sets wether tonemapping is enabled or not
  40008. */
  40009. toneMappingEnabled: boolean;
  40010. /**
  40011. * Gets the type of tone mapping effect.
  40012. */
  40013. /**
  40014. * Sets the type of tone mapping effect.
  40015. */
  40016. toneMappingType: number;
  40017. /**
  40018. * Gets contrast used in the effect.
  40019. */
  40020. /**
  40021. * Sets contrast used in the effect.
  40022. */
  40023. contrast: number;
  40024. /**
  40025. * Gets Vignette stretch size.
  40026. */
  40027. /**
  40028. * Sets Vignette stretch size.
  40029. */
  40030. vignetteStretch: number;
  40031. /**
  40032. * Gets Vignette centre X Offset.
  40033. */
  40034. /**
  40035. * Sets Vignette centre X Offset.
  40036. */
  40037. vignetteCentreX: number;
  40038. /**
  40039. * Gets Vignette centre Y Offset.
  40040. */
  40041. /**
  40042. * Sets Vignette centre Y Offset.
  40043. */
  40044. vignetteCentreY: number;
  40045. /**
  40046. * Gets Vignette weight or intensity of the vignette effect.
  40047. */
  40048. /**
  40049. * Sets Vignette weight or intensity of the vignette effect.
  40050. */
  40051. vignetteWeight: number;
  40052. /**
  40053. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40054. * if vignetteEnabled is set to true.
  40055. */
  40056. /**
  40057. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40058. * if vignetteEnabled is set to true.
  40059. */
  40060. vignetteColor: Color4;
  40061. /**
  40062. * Gets Camera field of view used by the Vignette effect.
  40063. */
  40064. /**
  40065. * Sets Camera field of view used by the Vignette effect.
  40066. */
  40067. vignetteCameraFov: number;
  40068. /**
  40069. * Gets the vignette blend mode allowing different kind of effect.
  40070. */
  40071. /**
  40072. * Sets the vignette blend mode allowing different kind of effect.
  40073. */
  40074. vignetteBlendMode: number;
  40075. /**
  40076. * Gets wether the vignette effect is enabled.
  40077. */
  40078. /**
  40079. * Sets wether the vignette effect is enabled.
  40080. */
  40081. vignetteEnabled: boolean;
  40082. private _fromLinearSpace;
  40083. /**
  40084. * Gets wether the input of the processing is in Gamma or Linear Space.
  40085. */
  40086. /**
  40087. * Sets wether the input of the processing is in Gamma or Linear Space.
  40088. */
  40089. fromLinearSpace: boolean;
  40090. /**
  40091. * Defines cache preventing GC.
  40092. */
  40093. private _defines;
  40094. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40095. /**
  40096. * "ImageProcessingPostProcess"
  40097. * @returns "ImageProcessingPostProcess"
  40098. */
  40099. getClassName(): string;
  40100. protected _updateParameters(): void;
  40101. dispose(camera?: Camera): void;
  40102. }
  40103. }
  40104. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40105. import { Scene } from "babylonjs/scene";
  40106. import { Color3 } from "babylonjs/Maths/math";
  40107. import { Mesh } from "babylonjs/Meshes/mesh";
  40108. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40109. /**
  40110. * Class containing static functions to help procedurally build meshes
  40111. */
  40112. export class GroundBuilder {
  40113. /**
  40114. * Creates a ground mesh
  40115. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40116. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40118. * @param name defines the name of the mesh
  40119. * @param options defines the options used to create the mesh
  40120. * @param scene defines the hosting scene
  40121. * @returns the ground mesh
  40122. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40123. */
  40124. static CreateGround(name: string, options: {
  40125. width?: number;
  40126. height?: number;
  40127. subdivisions?: number;
  40128. subdivisionsX?: number;
  40129. subdivisionsY?: number;
  40130. updatable?: boolean;
  40131. }, scene: any): Mesh;
  40132. /**
  40133. * Creates a tiled ground mesh
  40134. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40135. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40136. * * 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
  40137. * * 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
  40138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40139. * @param name defines the name of the mesh
  40140. * @param options defines the options used to create the mesh
  40141. * @param scene defines the hosting scene
  40142. * @returns the tiled ground mesh
  40143. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40144. */
  40145. static CreateTiledGround(name: string, options: {
  40146. xmin: number;
  40147. zmin: number;
  40148. xmax: number;
  40149. zmax: number;
  40150. subdivisions?: {
  40151. w: number;
  40152. h: number;
  40153. };
  40154. precision?: {
  40155. w: number;
  40156. h: number;
  40157. };
  40158. updatable?: boolean;
  40159. }, scene: Scene): Mesh;
  40160. /**
  40161. * Creates a ground mesh from a height map
  40162. * * The parameter `url` sets the URL of the height map image resource.
  40163. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40164. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40165. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40166. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40167. * * 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.
  40168. * * 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).
  40169. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40171. * @param name defines the name of the mesh
  40172. * @param url defines the url to the height map
  40173. * @param options defines the options used to create the mesh
  40174. * @param scene defines the hosting scene
  40175. * @returns the ground mesh
  40176. * @see https://doc.babylonjs.com/babylon101/height_map
  40177. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40178. */
  40179. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40180. width?: number;
  40181. height?: number;
  40182. subdivisions?: number;
  40183. minHeight?: number;
  40184. maxHeight?: number;
  40185. colorFilter?: Color3;
  40186. alphaFilter?: number;
  40187. updatable?: boolean;
  40188. onReady?: (mesh: GroundMesh) => void;
  40189. }, scene: Scene): GroundMesh;
  40190. }
  40191. }
  40192. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40193. import { Vector4 } from "babylonjs/Maths/math";
  40194. import { Mesh } from "babylonjs/Meshes/mesh";
  40195. /**
  40196. * Class containing static functions to help procedurally build meshes
  40197. */
  40198. export class TorusBuilder {
  40199. /**
  40200. * Creates a torus mesh
  40201. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40202. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40203. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40207. * @param name defines the name of the mesh
  40208. * @param options defines the options used to create the mesh
  40209. * @param scene defines the hosting scene
  40210. * @returns the torus mesh
  40211. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40212. */
  40213. static CreateTorus(name: string, options: {
  40214. diameter?: number;
  40215. thickness?: number;
  40216. tessellation?: number;
  40217. updatable?: boolean;
  40218. sideOrientation?: number;
  40219. frontUVs?: Vector4;
  40220. backUVs?: Vector4;
  40221. }, scene: any): Mesh;
  40222. }
  40223. }
  40224. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40225. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40226. import { Mesh } from "babylonjs/Meshes/mesh";
  40227. /**
  40228. * Class containing static functions to help procedurally build meshes
  40229. */
  40230. export class CylinderBuilder {
  40231. /**
  40232. * Creates a cylinder or a cone mesh
  40233. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40234. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40235. * * 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.
  40236. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40237. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40238. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40239. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40240. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40241. * * 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).
  40242. * * 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
  40243. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40244. * * 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
  40245. * * 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.
  40246. * * If `enclose` is false, a ring surface is one element.
  40247. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40248. * * 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
  40249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40252. * @param name defines the name of the mesh
  40253. * @param options defines the options used to create the mesh
  40254. * @param scene defines the hosting scene
  40255. * @returns the cylinder mesh
  40256. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40257. */
  40258. static CreateCylinder(name: string, options: {
  40259. height?: number;
  40260. diameterTop?: number;
  40261. diameterBottom?: number;
  40262. diameter?: number;
  40263. tessellation?: number;
  40264. subdivisions?: number;
  40265. arc?: number;
  40266. faceColors?: Color4[];
  40267. faceUV?: Vector4[];
  40268. updatable?: boolean;
  40269. hasRings?: boolean;
  40270. enclose?: boolean;
  40271. sideOrientation?: number;
  40272. frontUVs?: Vector4;
  40273. backUVs?: Vector4;
  40274. }, scene: any): Mesh;
  40275. }
  40276. }
  40277. declare module "babylonjs/Gamepads/gamepadManager" {
  40278. import { Observable } from "babylonjs/Misc/observable";
  40279. import { Nullable } from "babylonjs/types";
  40280. import { Scene } from "babylonjs/scene";
  40281. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40282. /**
  40283. * Manager for handling gamepads
  40284. */
  40285. export class GamepadManager {
  40286. private _scene?;
  40287. private _babylonGamepads;
  40288. private _oneGamepadConnected;
  40289. /** @hidden */
  40290. _isMonitoring: boolean;
  40291. private _gamepadEventSupported;
  40292. private _gamepadSupport;
  40293. /**
  40294. * observable to be triggered when the gamepad controller has been connected
  40295. */
  40296. onGamepadConnectedObservable: Observable<Gamepad>;
  40297. /**
  40298. * observable to be triggered when the gamepad controller has been disconnected
  40299. */
  40300. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40301. private _onGamepadConnectedEvent;
  40302. private _onGamepadDisconnectedEvent;
  40303. /**
  40304. * Initializes the gamepad manager
  40305. * @param _scene BabylonJS scene
  40306. */
  40307. constructor(_scene?: Scene | undefined);
  40308. /**
  40309. * The gamepads in the game pad manager
  40310. */
  40311. readonly gamepads: Gamepad[];
  40312. /**
  40313. * Get the gamepad controllers based on type
  40314. * @param type The type of gamepad controller
  40315. * @returns Nullable gamepad
  40316. */
  40317. getGamepadByType(type?: number): Nullable<Gamepad>;
  40318. /**
  40319. * Disposes the gamepad manager
  40320. */
  40321. dispose(): void;
  40322. private _addNewGamepad;
  40323. private _startMonitoringGamepads;
  40324. private _stopMonitoringGamepads;
  40325. /** @hidden */
  40326. _checkGamepadsStatus(): void;
  40327. private _updateGamepadObjects;
  40328. }
  40329. }
  40330. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40331. import { Nullable } from "babylonjs/types";
  40332. import { Scene } from "babylonjs/scene";
  40333. import { ISceneComponent } from "babylonjs/sceneComponent";
  40334. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40335. module "babylonjs/scene" {
  40336. interface Scene {
  40337. /** @hidden */
  40338. _gamepadManager: Nullable<GamepadManager>;
  40339. /**
  40340. * Gets the gamepad manager associated with the scene
  40341. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40342. */
  40343. gamepadManager: GamepadManager;
  40344. }
  40345. }
  40346. module "babylonjs/Cameras/freeCameraInputsManager" {
  40347. /**
  40348. * Interface representing a free camera inputs manager
  40349. */
  40350. interface FreeCameraInputsManager {
  40351. /**
  40352. * Adds gamepad input support to the FreeCameraInputsManager.
  40353. * @returns the FreeCameraInputsManager
  40354. */
  40355. addGamepad(): FreeCameraInputsManager;
  40356. }
  40357. }
  40358. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40359. /**
  40360. * Interface representing an arc rotate camera inputs manager
  40361. */
  40362. interface ArcRotateCameraInputsManager {
  40363. /**
  40364. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40365. * @returns the camera inputs manager
  40366. */
  40367. addGamepad(): ArcRotateCameraInputsManager;
  40368. }
  40369. }
  40370. /**
  40371. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40372. */
  40373. export class GamepadSystemSceneComponent implements ISceneComponent {
  40374. /**
  40375. * The component name helpfull to identify the component in the list of scene components.
  40376. */
  40377. readonly name: string;
  40378. /**
  40379. * The scene the component belongs to.
  40380. */
  40381. scene: Scene;
  40382. /**
  40383. * Creates a new instance of the component for the given scene
  40384. * @param scene Defines the scene to register the component in
  40385. */
  40386. constructor(scene: Scene);
  40387. /**
  40388. * Registers the component in a given scene
  40389. */
  40390. register(): void;
  40391. /**
  40392. * Rebuilds the elements related to this component in case of
  40393. * context lost for instance.
  40394. */
  40395. rebuild(): void;
  40396. /**
  40397. * Disposes the component and the associated ressources
  40398. */
  40399. dispose(): void;
  40400. private _beforeCameraUpdate;
  40401. }
  40402. }
  40403. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40404. import { Observable } from "babylonjs/Misc/observable";
  40405. import { Nullable } from "babylonjs/types";
  40406. import { Camera } from "babylonjs/Cameras/camera";
  40407. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40408. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40409. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40410. import { Scene } from "babylonjs/scene";
  40411. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40412. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40414. import { Mesh } from "babylonjs/Meshes/mesh";
  40415. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40416. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40417. import "babylonjs/Meshes/Builders/groundBuilder";
  40418. import "babylonjs/Meshes/Builders/torusBuilder";
  40419. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40420. import "babylonjs/Gamepads/gamepadSceneComponent";
  40421. import "babylonjs/Animations/animatable";
  40422. /**
  40423. * Options to modify the vr teleportation behavior.
  40424. */
  40425. export interface VRTeleportationOptions {
  40426. /**
  40427. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40428. */
  40429. floorMeshName?: string;
  40430. /**
  40431. * A list of meshes to be used as the teleportation floor. (default: empty)
  40432. */
  40433. floorMeshes?: Mesh[];
  40434. }
  40435. /**
  40436. * Options to modify the vr experience helper's behavior.
  40437. */
  40438. export interface VRExperienceHelperOptions extends WebVROptions {
  40439. /**
  40440. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40441. */
  40442. createDeviceOrientationCamera?: boolean;
  40443. /**
  40444. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40445. */
  40446. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40447. /**
  40448. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40449. */
  40450. laserToggle?: boolean;
  40451. /**
  40452. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40453. */
  40454. floorMeshes?: Mesh[];
  40455. /**
  40456. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40457. */
  40458. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40459. }
  40460. /**
  40461. * Event containing information after VR has been entered
  40462. */
  40463. export class OnAfterEnteringVRObservableEvent {
  40464. /**
  40465. * If entering vr was successful
  40466. */
  40467. success: boolean;
  40468. }
  40469. /**
  40470. * Helps to quickly add VR support to an existing scene.
  40471. * See http://doc.babylonjs.com/how_to/webvr_helper
  40472. */
  40473. export class VRExperienceHelper {
  40474. /** Options to modify the vr experience helper's behavior. */
  40475. webVROptions: VRExperienceHelperOptions;
  40476. private _scene;
  40477. private _position;
  40478. private _btnVR;
  40479. private _btnVRDisplayed;
  40480. private _webVRsupported;
  40481. private _webVRready;
  40482. private _webVRrequesting;
  40483. private _webVRpresenting;
  40484. private _hasEnteredVR;
  40485. private _fullscreenVRpresenting;
  40486. private _canvas;
  40487. private _webVRCamera;
  40488. private _vrDeviceOrientationCamera;
  40489. private _deviceOrientationCamera;
  40490. private _existingCamera;
  40491. private _onKeyDown;
  40492. private _onVrDisplayPresentChange;
  40493. private _onVRDisplayChanged;
  40494. private _onVRRequestPresentStart;
  40495. private _onVRRequestPresentComplete;
  40496. /**
  40497. * Observable raised right before entering VR.
  40498. */
  40499. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40500. /**
  40501. * Observable raised when entering VR has completed.
  40502. */
  40503. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40504. /**
  40505. * Observable raised when exiting VR.
  40506. */
  40507. onExitingVRObservable: Observable<VRExperienceHelper>;
  40508. /**
  40509. * Observable raised when controller mesh is loaded.
  40510. */
  40511. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40512. /** Return this.onEnteringVRObservable
  40513. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40514. */
  40515. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40516. /** Return this.onExitingVRObservable
  40517. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40518. */
  40519. readonly onExitingVR: Observable<VRExperienceHelper>;
  40520. /** Return this.onControllerMeshLoadedObservable
  40521. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40522. */
  40523. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40524. private _rayLength;
  40525. private _useCustomVRButton;
  40526. private _teleportationRequested;
  40527. private _teleportActive;
  40528. private _floorMeshName;
  40529. private _floorMeshesCollection;
  40530. private _rotationAllowed;
  40531. private _teleportBackwardsVector;
  40532. private _teleportationTarget;
  40533. private _isDefaultTeleportationTarget;
  40534. private _postProcessMove;
  40535. private _teleportationFillColor;
  40536. private _teleportationBorderColor;
  40537. private _rotationAngle;
  40538. private _haloCenter;
  40539. private _cameraGazer;
  40540. private _padSensibilityUp;
  40541. private _padSensibilityDown;
  40542. private _leftController;
  40543. private _rightController;
  40544. /**
  40545. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40546. */
  40547. onNewMeshSelected: Observable<AbstractMesh>;
  40548. /**
  40549. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40550. */
  40551. onNewMeshPicked: Observable<PickingInfo>;
  40552. private _circleEase;
  40553. /**
  40554. * Observable raised before camera teleportation
  40555. */
  40556. onBeforeCameraTeleport: Observable<Vector3>;
  40557. /**
  40558. * Observable raised after camera teleportation
  40559. */
  40560. onAfterCameraTeleport: Observable<Vector3>;
  40561. /**
  40562. * Observable raised when current selected mesh gets unselected
  40563. */
  40564. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40565. private _raySelectionPredicate;
  40566. /**
  40567. * To be optionaly changed by user to define custom ray selection
  40568. */
  40569. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40570. /**
  40571. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40572. */
  40573. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40574. /**
  40575. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40576. */
  40577. teleportationEnabled: boolean;
  40578. private _defaultHeight;
  40579. private _teleportationInitialized;
  40580. private _interactionsEnabled;
  40581. private _interactionsRequested;
  40582. private _displayGaze;
  40583. private _displayLaserPointer;
  40584. /**
  40585. * The mesh used to display where the user is going to teleport.
  40586. */
  40587. /**
  40588. * Sets the mesh to be used to display where the user is going to teleport.
  40589. */
  40590. teleportationTarget: Mesh;
  40591. /**
  40592. * 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
  40593. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40594. * See http://doc.babylonjs.com/resources/baking_transformations
  40595. */
  40596. gazeTrackerMesh: Mesh;
  40597. /**
  40598. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40599. */
  40600. updateGazeTrackerScale: boolean;
  40601. /**
  40602. * If the gaze trackers color should be updated when selecting meshes
  40603. */
  40604. updateGazeTrackerColor: boolean;
  40605. /**
  40606. * The gaze tracking mesh corresponding to the left controller
  40607. */
  40608. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40609. /**
  40610. * The gaze tracking mesh corresponding to the right controller
  40611. */
  40612. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40613. /**
  40614. * If the ray of the gaze should be displayed.
  40615. */
  40616. /**
  40617. * Sets if the ray of the gaze should be displayed.
  40618. */
  40619. displayGaze: boolean;
  40620. /**
  40621. * If the ray of the LaserPointer should be displayed.
  40622. */
  40623. /**
  40624. * Sets if the ray of the LaserPointer should be displayed.
  40625. */
  40626. displayLaserPointer: boolean;
  40627. /**
  40628. * The deviceOrientationCamera used as the camera when not in VR.
  40629. */
  40630. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40631. /**
  40632. * Based on the current WebVR support, returns the current VR camera used.
  40633. */
  40634. readonly currentVRCamera: Nullable<Camera>;
  40635. /**
  40636. * The webVRCamera which is used when in VR.
  40637. */
  40638. readonly webVRCamera: WebVRFreeCamera;
  40639. /**
  40640. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40641. */
  40642. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40643. private readonly _teleportationRequestInitiated;
  40644. /**
  40645. * Defines wether or not Pointer lock should be requested when switching to
  40646. * full screen.
  40647. */
  40648. requestPointerLockOnFullScreen: boolean;
  40649. /**
  40650. * Instantiates a VRExperienceHelper.
  40651. * Helps to quickly add VR support to an existing scene.
  40652. * @param scene The scene the VRExperienceHelper belongs to.
  40653. * @param webVROptions Options to modify the vr experience helper's behavior.
  40654. */
  40655. constructor(scene: Scene,
  40656. /** Options to modify the vr experience helper's behavior. */
  40657. webVROptions?: VRExperienceHelperOptions);
  40658. private _onDefaultMeshLoaded;
  40659. private _onResize;
  40660. private _onFullscreenChange;
  40661. /**
  40662. * Gets a value indicating if we are currently in VR mode.
  40663. */
  40664. readonly isInVRMode: boolean;
  40665. private onVrDisplayPresentChange;
  40666. private onVRDisplayChanged;
  40667. private moveButtonToBottomRight;
  40668. private displayVRButton;
  40669. private updateButtonVisibility;
  40670. private _cachedAngularSensibility;
  40671. /**
  40672. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40673. * Otherwise, will use the fullscreen API.
  40674. */
  40675. enterVR(): void;
  40676. /**
  40677. * Attempt to exit VR, or fullscreen.
  40678. */
  40679. exitVR(): void;
  40680. /**
  40681. * The position of the vr experience helper.
  40682. */
  40683. /**
  40684. * Sets the position of the vr experience helper.
  40685. */
  40686. position: Vector3;
  40687. /**
  40688. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40689. */
  40690. enableInteractions(): void;
  40691. private readonly _noControllerIsActive;
  40692. private beforeRender;
  40693. private _isTeleportationFloor;
  40694. /**
  40695. * Adds a floor mesh to be used for teleportation.
  40696. * @param floorMesh the mesh to be used for teleportation.
  40697. */
  40698. addFloorMesh(floorMesh: Mesh): void;
  40699. /**
  40700. * Removes a floor mesh from being used for teleportation.
  40701. * @param floorMesh the mesh to be removed.
  40702. */
  40703. removeFloorMesh(floorMesh: Mesh): void;
  40704. /**
  40705. * Enables interactions and teleportation using the VR controllers and gaze.
  40706. * @param vrTeleportationOptions options to modify teleportation behavior.
  40707. */
  40708. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40709. private _onNewGamepadConnected;
  40710. private _tryEnableInteractionOnController;
  40711. private _onNewGamepadDisconnected;
  40712. private _enableInteractionOnController;
  40713. private _checkTeleportWithRay;
  40714. private _checkRotate;
  40715. private _checkTeleportBackwards;
  40716. private _enableTeleportationOnController;
  40717. private _createTeleportationCircles;
  40718. private _displayTeleportationTarget;
  40719. private _hideTeleportationTarget;
  40720. private _rotateCamera;
  40721. private _moveTeleportationSelectorTo;
  40722. private _workingVector;
  40723. private _workingQuaternion;
  40724. private _workingMatrix;
  40725. /**
  40726. * Teleports the users feet to the desired location
  40727. * @param location The location where the user's feet should be placed
  40728. */
  40729. teleportCamera(location: Vector3): void;
  40730. private _convertNormalToDirectionOfRay;
  40731. private _castRayAndSelectObject;
  40732. private _notifySelectedMeshUnselected;
  40733. /**
  40734. * Sets the color of the laser ray from the vr controllers.
  40735. * @param color new color for the ray.
  40736. */
  40737. changeLaserColor(color: Color3): void;
  40738. /**
  40739. * Sets the color of the ray from the vr headsets gaze.
  40740. * @param color new color for the ray.
  40741. */
  40742. changeGazeColor(color: Color3): void;
  40743. /**
  40744. * Exits VR and disposes of the vr experience helper
  40745. */
  40746. dispose(): void;
  40747. /**
  40748. * Gets the name of the VRExperienceHelper class
  40749. * @returns "VRExperienceHelper"
  40750. */
  40751. getClassName(): string;
  40752. }
  40753. }
  40754. declare module "babylonjs/Cameras/VR/index" {
  40755. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40756. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40757. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40758. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40759. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40760. export * from "babylonjs/Cameras/VR/webVRCamera";
  40761. }
  40762. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40763. import { Observable } from "babylonjs/Misc/observable";
  40764. import { Nullable } from "babylonjs/types";
  40765. import { IDisposable, Scene } from "babylonjs/scene";
  40766. import { Vector3 } from "babylonjs/Maths/math";
  40767. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40768. import { Ray } from "babylonjs/Culling/ray";
  40769. /**
  40770. * Manages an XRSession
  40771. * @see https://doc.babylonjs.com/how_to/webxr
  40772. */
  40773. export class WebXRSessionManager implements IDisposable {
  40774. private scene;
  40775. /**
  40776. * Fires every time a new xrFrame arrives which can be used to update the camera
  40777. */
  40778. onXRFrameObservable: Observable<any>;
  40779. /**
  40780. * Fires when the xr session is ended either by the device or manually done
  40781. */
  40782. onXRSessionEnded: Observable<any>;
  40783. /** @hidden */
  40784. _xrSession: XRSession;
  40785. /** @hidden */
  40786. _frameOfReference: XRFrameOfReference;
  40787. /** @hidden */
  40788. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40789. /** @hidden */
  40790. _currentXRFrame: Nullable<XRFrame>;
  40791. private _xrNavigator;
  40792. private _xrDevice;
  40793. private _tmpMatrix;
  40794. /**
  40795. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40796. * @param scene The scene which the session should be created for
  40797. */
  40798. constructor(scene: Scene);
  40799. /**
  40800. * Initializes the manager
  40801. * After initialization enterXR can be called to start an XR session
  40802. * @returns Promise which resolves after it is initialized
  40803. */
  40804. initializeAsync(): Promise<void>;
  40805. /**
  40806. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40807. * @param sessionCreationOptions xr options to create the session with
  40808. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40809. * @returns Promise which resolves after it enters XR
  40810. */
  40811. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40812. /**
  40813. * Stops the xrSession and restores the renderloop
  40814. * @returns Promise which resolves after it exits XR
  40815. */
  40816. exitXRAsync(): Promise<void>;
  40817. /**
  40818. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40819. * @param ray ray to cast into the environment
  40820. * @returns Promise which resolves with a collision point in the environment if it exists
  40821. */
  40822. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40823. /**
  40824. * Checks if a session would be supported for the creation options specified
  40825. * @param options creation options to check if they are supported
  40826. * @returns true if supported
  40827. */
  40828. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40829. /**
  40830. * @hidden
  40831. * Converts the render layer of xrSession to a render target
  40832. * @param session session to create render target for
  40833. * @param scene scene the new render target should be created for
  40834. */
  40835. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40836. /**
  40837. * Disposes of the session manager
  40838. */
  40839. dispose(): void;
  40840. }
  40841. }
  40842. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40843. import { Scene } from "babylonjs/scene";
  40844. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40845. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40846. /**
  40847. * WebXR Camera which holds the views for the xrSession
  40848. * @see https://doc.babylonjs.com/how_to/webxr
  40849. */
  40850. export class WebXRCamera extends FreeCamera {
  40851. private static _TmpMatrix;
  40852. /**
  40853. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40854. * @param name the name of the camera
  40855. * @param scene the scene to add the camera to
  40856. */
  40857. constructor(name: string, scene: Scene);
  40858. private _updateNumberOfRigCameras;
  40859. /** @hidden */
  40860. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40861. /**
  40862. * Updates the cameras position from the current pose information of the XR session
  40863. * @param xrSessionManager the session containing pose information
  40864. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40865. */
  40866. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40867. }
  40868. }
  40869. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40870. import { Nullable } from "babylonjs/types";
  40871. import { Observable } from "babylonjs/Misc/observable";
  40872. import { IDisposable, Scene } from "babylonjs/scene";
  40873. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40874. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40875. import { Ray } from "babylonjs/Culling/ray";
  40876. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40877. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40878. /**
  40879. * States of the webXR experience
  40880. */
  40881. export enum WebXRState {
  40882. /**
  40883. * Transitioning to being in XR mode
  40884. */
  40885. ENTERING_XR = 0,
  40886. /**
  40887. * Transitioning to non XR mode
  40888. */
  40889. EXITING_XR = 1,
  40890. /**
  40891. * In XR mode and presenting
  40892. */
  40893. IN_XR = 2,
  40894. /**
  40895. * Not entered XR mode
  40896. */
  40897. NOT_IN_XR = 3
  40898. }
  40899. /**
  40900. * Helper class used to enable XR
  40901. * @see https://doc.babylonjs.com/how_to/webxr
  40902. */
  40903. export class WebXRExperienceHelper implements IDisposable {
  40904. private scene;
  40905. /**
  40906. * 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
  40907. */
  40908. container: AbstractMesh;
  40909. /**
  40910. * Camera used to render xr content
  40911. */
  40912. camera: WebXRCamera;
  40913. /**
  40914. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40915. */
  40916. state: WebXRState;
  40917. private _setState;
  40918. private static _TmpVector;
  40919. /**
  40920. * Fires when the state of the experience helper has changed
  40921. */
  40922. onStateChangedObservable: Observable<WebXRState>;
  40923. /** @hidden */
  40924. _sessionManager: WebXRSessionManager;
  40925. private _nonVRCamera;
  40926. private _originalSceneAutoClear;
  40927. private _supported;
  40928. /**
  40929. * Creates the experience helper
  40930. * @param scene the scene to attach the experience helper to
  40931. * @returns a promise for the experience helper
  40932. */
  40933. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40934. /**
  40935. * Creates a WebXRExperienceHelper
  40936. * @param scene The scene the helper should be created in
  40937. */
  40938. private constructor();
  40939. /**
  40940. * Exits XR mode and returns the scene to its original state
  40941. * @returns promise that resolves after xr mode has exited
  40942. */
  40943. exitXRAsync(): Promise<void>;
  40944. /**
  40945. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40946. * @param sessionCreationOptions options for the XR session
  40947. * @param frameOfReference frame of reference of the XR session
  40948. * @returns promise that resolves after xr mode has entered
  40949. */
  40950. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40951. /**
  40952. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40953. * @param ray ray to cast into the environment
  40954. * @returns Promise which resolves with a collision point in the environment if it exists
  40955. */
  40956. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40957. /**
  40958. * Updates the global position of the camera by moving the camera's container
  40959. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40960. * @param position The desired global position of the camera
  40961. */
  40962. setPositionOfCameraUsingContainer(position: Vector3): void;
  40963. /**
  40964. * Rotates the xr camera by rotating the camera's container around the camera's position
  40965. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40966. * @param rotation the desired quaternion rotation to apply to the camera
  40967. */
  40968. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40969. /**
  40970. * Checks if the creation options are supported by the xr session
  40971. * @param options creation options
  40972. * @returns true if supported
  40973. */
  40974. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40975. /**
  40976. * Disposes of the experience helper
  40977. */
  40978. dispose(): void;
  40979. }
  40980. }
  40981. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40982. import { Nullable } from "babylonjs/types";
  40983. import { Observable } from "babylonjs/Misc/observable";
  40984. import { IDisposable, Scene } from "babylonjs/scene";
  40985. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40986. /**
  40987. * Button which can be used to enter a different mode of XR
  40988. */
  40989. export class WebXREnterExitUIButton {
  40990. /** button element */
  40991. element: HTMLElement;
  40992. /** XR initialization options for the button */
  40993. initializationOptions: XRSessionCreationOptions;
  40994. /**
  40995. * Creates a WebXREnterExitUIButton
  40996. * @param element button element
  40997. * @param initializationOptions XR initialization options for the button
  40998. */
  40999. constructor(
  41000. /** button element */
  41001. element: HTMLElement,
  41002. /** XR initialization options for the button */
  41003. initializationOptions: XRSessionCreationOptions);
  41004. /**
  41005. * Overwritable function which can be used to update the button's visuals when the state changes
  41006. * @param activeButton the current active button in the UI
  41007. */
  41008. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41009. }
  41010. /**
  41011. * Options to create the webXR UI
  41012. */
  41013. export class WebXREnterExitUIOptions {
  41014. /**
  41015. * Context to enter xr with
  41016. */
  41017. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41018. /**
  41019. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41020. */
  41021. customButtons?: Array<WebXREnterExitUIButton>;
  41022. }
  41023. /**
  41024. * UI to allow the user to enter/exit XR mode
  41025. */
  41026. export class WebXREnterExitUI implements IDisposable {
  41027. private scene;
  41028. private _overlay;
  41029. private _buttons;
  41030. private _activeButton;
  41031. /**
  41032. * Fired every time the active button is changed.
  41033. *
  41034. * When xr is entered via a button that launches xr that button will be the callback parameter
  41035. *
  41036. * When exiting xr the callback parameter will be null)
  41037. */
  41038. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41039. /**
  41040. * Creates UI to allow the user to enter/exit XR mode
  41041. * @param scene the scene to add the ui to
  41042. * @param helper the xr experience helper to enter/exit xr with
  41043. * @param options options to configure the UI
  41044. * @returns the created ui
  41045. */
  41046. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41047. private constructor();
  41048. private _updateButtons;
  41049. /**
  41050. * Disposes of the object
  41051. */
  41052. dispose(): void;
  41053. }
  41054. }
  41055. declare module "babylonjs/Cameras/XR/webXRInput" {
  41056. import { IDisposable, Scene } from "babylonjs/scene";
  41057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41058. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41059. /**
  41060. * Represents an XR input
  41061. */
  41062. export class WebXRController {
  41063. /**
  41064. * 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
  41065. */
  41066. grip?: AbstractMesh;
  41067. /**
  41068. * Pointer which can be used to select objects or attach a visible laser to
  41069. */
  41070. pointer: AbstractMesh;
  41071. /**
  41072. * Creates the controller
  41073. * @see https://doc.babylonjs.com/how_to/webxr
  41074. * @param scene the scene which the controller should be associated to
  41075. */
  41076. constructor(scene: Scene);
  41077. /**
  41078. * Disposes of the object
  41079. */
  41080. dispose(): void;
  41081. }
  41082. /**
  41083. * XR input used to track XR inputs such as controllers/rays
  41084. */
  41085. export class WebXRInput implements IDisposable {
  41086. private helper;
  41087. /**
  41088. * XR controllers being tracked
  41089. */
  41090. controllers: Array<WebXRController>;
  41091. private _tmpMatrix;
  41092. private _frameObserver;
  41093. /**
  41094. * Initializes the WebXRInput
  41095. * @param helper experience helper which the input should be created for
  41096. */
  41097. constructor(helper: WebXRExperienceHelper);
  41098. /**
  41099. * Disposes of the object
  41100. */
  41101. dispose(): void;
  41102. }
  41103. }
  41104. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41105. import { Nullable } from "babylonjs/types";
  41106. import { IDisposable } from "babylonjs/scene";
  41107. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41108. /**
  41109. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41110. */
  41111. export class WebXRManagedOutputCanvas implements IDisposable {
  41112. private _canvas;
  41113. /**
  41114. * xrpresent context of the canvas which can be used to display/mirror xr content
  41115. */
  41116. canvasContext: Nullable<WebGLRenderingContext>;
  41117. /**
  41118. * Initializes the canvas to be added/removed upon entering/exiting xr
  41119. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41120. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41121. */
  41122. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41123. /**
  41124. * Disposes of the object
  41125. */
  41126. dispose(): void;
  41127. private _setManagedOutputCanvas;
  41128. private _addCanvas;
  41129. private _removeCanvas;
  41130. }
  41131. }
  41132. declare module "babylonjs/Cameras/XR/index" {
  41133. export * from "babylonjs/Cameras/XR/webXRCamera";
  41134. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41135. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41136. export * from "babylonjs/Cameras/XR/webXRInput";
  41137. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41138. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41139. }
  41140. declare module "babylonjs/Cameras/RigModes/index" {
  41141. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41142. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41143. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41144. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41145. }
  41146. declare module "babylonjs/Cameras/index" {
  41147. export * from "babylonjs/Cameras/Inputs/index";
  41148. export * from "babylonjs/Cameras/cameraInputsManager";
  41149. export * from "babylonjs/Cameras/camera";
  41150. export * from "babylonjs/Cameras/targetCamera";
  41151. export * from "babylonjs/Cameras/freeCamera";
  41152. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41153. export * from "babylonjs/Cameras/touchCamera";
  41154. export * from "babylonjs/Cameras/arcRotateCamera";
  41155. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41156. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41157. export * from "babylonjs/Cameras/flyCamera";
  41158. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41159. export * from "babylonjs/Cameras/followCamera";
  41160. export * from "babylonjs/Cameras/gamepadCamera";
  41161. export * from "babylonjs/Cameras/Stereoscopic/index";
  41162. export * from "babylonjs/Cameras/universalCamera";
  41163. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41164. export * from "babylonjs/Cameras/VR/index";
  41165. export * from "babylonjs/Cameras/XR/index";
  41166. export * from "babylonjs/Cameras/RigModes/index";
  41167. }
  41168. declare module "babylonjs/Collisions/index" {
  41169. export * from "babylonjs/Collisions/collider";
  41170. export * from "babylonjs/Collisions/collisionCoordinator";
  41171. export * from "babylonjs/Collisions/pickingInfo";
  41172. export * from "babylonjs/Collisions/intersectionInfo";
  41173. }
  41174. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41175. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41176. import { Vector3, Plane } from "babylonjs/Maths/math";
  41177. import { Ray } from "babylonjs/Culling/ray";
  41178. /**
  41179. * Contains an array of blocks representing the octree
  41180. */
  41181. export interface IOctreeContainer<T> {
  41182. /**
  41183. * Blocks within the octree
  41184. */
  41185. blocks: Array<OctreeBlock<T>>;
  41186. }
  41187. /**
  41188. * Class used to store a cell in an octree
  41189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41190. */
  41191. export class OctreeBlock<T> {
  41192. /**
  41193. * Gets the content of the current block
  41194. */
  41195. entries: T[];
  41196. /**
  41197. * Gets the list of block children
  41198. */
  41199. blocks: Array<OctreeBlock<T>>;
  41200. private _depth;
  41201. private _maxDepth;
  41202. private _capacity;
  41203. private _minPoint;
  41204. private _maxPoint;
  41205. private _boundingVectors;
  41206. private _creationFunc;
  41207. /**
  41208. * Creates a new block
  41209. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41210. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41211. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41212. * @param depth defines the current depth of this block in the octree
  41213. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41214. * @param creationFunc defines a callback to call when an element is added to the block
  41215. */
  41216. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41217. /**
  41218. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41219. */
  41220. readonly capacity: number;
  41221. /**
  41222. * Gets the minimum vector (in world space) of the block's bounding box
  41223. */
  41224. readonly minPoint: Vector3;
  41225. /**
  41226. * Gets the maximum vector (in world space) of the block's bounding box
  41227. */
  41228. readonly maxPoint: Vector3;
  41229. /**
  41230. * Add a new element to this block
  41231. * @param entry defines the element to add
  41232. */
  41233. addEntry(entry: T): void;
  41234. /**
  41235. * Remove an element from this block
  41236. * @param entry defines the element to remove
  41237. */
  41238. removeEntry(entry: T): void;
  41239. /**
  41240. * Add an array of elements to this block
  41241. * @param entries defines the array of elements to add
  41242. */
  41243. addEntries(entries: T[]): void;
  41244. /**
  41245. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41246. * @param frustumPlanes defines the frustum planes to test
  41247. * @param selection defines the array to store current content if selection is positive
  41248. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41249. */
  41250. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41251. /**
  41252. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41253. * @param sphereCenter defines the bounding sphere center
  41254. * @param sphereRadius defines the bounding sphere radius
  41255. * @param selection defines the array to store current content if selection is positive
  41256. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41257. */
  41258. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41259. /**
  41260. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41261. * @param ray defines the ray to test with
  41262. * @param selection defines the array to store current content if selection is positive
  41263. */
  41264. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41265. /**
  41266. * Subdivide the content into child blocks (this block will then be empty)
  41267. */
  41268. createInnerBlocks(): void;
  41269. /**
  41270. * @hidden
  41271. */
  41272. 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;
  41273. }
  41274. }
  41275. declare module "babylonjs/Culling/Octrees/octree" {
  41276. import { SmartArray } from "babylonjs/Misc/smartArray";
  41277. import { Vector3, Plane } from "babylonjs/Maths/math";
  41278. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41280. import { Ray } from "babylonjs/Culling/ray";
  41281. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41282. /**
  41283. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41284. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41285. */
  41286. export class Octree<T> {
  41287. /** 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.) */
  41288. maxDepth: number;
  41289. /**
  41290. * Blocks within the octree containing objects
  41291. */
  41292. blocks: Array<OctreeBlock<T>>;
  41293. /**
  41294. * Content stored in the octree
  41295. */
  41296. dynamicContent: T[];
  41297. private _maxBlockCapacity;
  41298. private _selectionContent;
  41299. private _creationFunc;
  41300. /**
  41301. * Creates a octree
  41302. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41303. * @param creationFunc function to be used to instatiate the octree
  41304. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41305. * @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.)
  41306. */
  41307. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41308. /** 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.) */
  41309. maxDepth?: number);
  41310. /**
  41311. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41312. * @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);
  41313. * @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);
  41314. * @param entries meshes to be added to the octree blocks
  41315. */
  41316. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41317. /**
  41318. * Adds a mesh to the octree
  41319. * @param entry Mesh to add to the octree
  41320. */
  41321. addMesh(entry: T): void;
  41322. /**
  41323. * Remove an element from the octree
  41324. * @param entry defines the element to remove
  41325. */
  41326. removeMesh(entry: T): void;
  41327. /**
  41328. * Selects an array of meshes within the frustum
  41329. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41330. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41331. * @returns array of meshes within the frustum
  41332. */
  41333. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41334. /**
  41335. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41336. * @param sphereCenter defines the bounding sphere center
  41337. * @param sphereRadius defines the bounding sphere radius
  41338. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41339. * @returns an array of objects that intersect the sphere
  41340. */
  41341. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41342. /**
  41343. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41344. * @param ray defines the ray to test with
  41345. * @returns array of intersected objects
  41346. */
  41347. intersectsRay(ray: Ray): SmartArray<T>;
  41348. /**
  41349. * Adds a mesh into the octree block if it intersects the block
  41350. */
  41351. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41352. /**
  41353. * Adds a submesh into the octree block if it intersects the block
  41354. */
  41355. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41356. }
  41357. }
  41358. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41359. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41360. import { Scene } from "babylonjs/scene";
  41361. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41363. import { Ray } from "babylonjs/Culling/ray";
  41364. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41365. import { Collider } from "babylonjs/Collisions/collider";
  41366. module "babylonjs/scene" {
  41367. interface Scene {
  41368. /**
  41369. * @hidden
  41370. * Backing Filed
  41371. */
  41372. _selectionOctree: Octree<AbstractMesh>;
  41373. /**
  41374. * Gets the octree used to boost mesh selection (picking)
  41375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41376. */
  41377. selectionOctree: Octree<AbstractMesh>;
  41378. /**
  41379. * Creates or updates the octree used to boost selection (picking)
  41380. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41381. * @param maxCapacity defines the maximum capacity per leaf
  41382. * @param maxDepth defines the maximum depth of the octree
  41383. * @returns an octree of AbstractMesh
  41384. */
  41385. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41386. }
  41387. }
  41388. module "babylonjs/Meshes/abstractMesh" {
  41389. interface AbstractMesh {
  41390. /**
  41391. * @hidden
  41392. * Backing Field
  41393. */
  41394. _submeshesOctree: Octree<SubMesh>;
  41395. /**
  41396. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41397. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41398. * @param maxCapacity defines the maximum size of each block (64 by default)
  41399. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41400. * @returns the new octree
  41401. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41403. */
  41404. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41405. }
  41406. }
  41407. /**
  41408. * Defines the octree scene component responsible to manage any octrees
  41409. * in a given scene.
  41410. */
  41411. export class OctreeSceneComponent {
  41412. /**
  41413. * The component name helpfull to identify the component in the list of scene components.
  41414. */
  41415. readonly name: string;
  41416. /**
  41417. * The scene the component belongs to.
  41418. */
  41419. scene: Scene;
  41420. /**
  41421. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41422. */
  41423. readonly checksIsEnabled: boolean;
  41424. /**
  41425. * Creates a new instance of the component for the given scene
  41426. * @param scene Defines the scene to register the component in
  41427. */
  41428. constructor(scene: Scene);
  41429. /**
  41430. * Registers the component in a given scene
  41431. */
  41432. register(): void;
  41433. /**
  41434. * Return the list of active meshes
  41435. * @returns the list of active meshes
  41436. */
  41437. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41438. /**
  41439. * Return the list of active sub meshes
  41440. * @param mesh The mesh to get the candidates sub meshes from
  41441. * @returns the list of active sub meshes
  41442. */
  41443. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41444. private _tempRay;
  41445. /**
  41446. * Return the list of sub meshes intersecting with a given local ray
  41447. * @param mesh defines the mesh to find the submesh for
  41448. * @param localRay defines the ray in local space
  41449. * @returns the list of intersecting sub meshes
  41450. */
  41451. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41452. /**
  41453. * Return the list of sub meshes colliding with a collider
  41454. * @param mesh defines the mesh to find the submesh for
  41455. * @param collider defines the collider to evaluate the collision against
  41456. * @returns the list of colliding sub meshes
  41457. */
  41458. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41459. /**
  41460. * Rebuilds the elements related to this component in case of
  41461. * context lost for instance.
  41462. */
  41463. rebuild(): void;
  41464. /**
  41465. * Disposes the component and the associated ressources.
  41466. */
  41467. dispose(): void;
  41468. }
  41469. }
  41470. declare module "babylonjs/Culling/Octrees/index" {
  41471. export * from "babylonjs/Culling/Octrees/octree";
  41472. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41473. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41474. }
  41475. declare module "babylonjs/Culling/index" {
  41476. export * from "babylonjs/Culling/boundingBox";
  41477. export * from "babylonjs/Culling/boundingInfo";
  41478. export * from "babylonjs/Culling/boundingSphere";
  41479. export * from "babylonjs/Culling/Octrees/index";
  41480. export * from "babylonjs/Culling/ray";
  41481. }
  41482. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41483. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41484. import { Nullable } from "babylonjs/types";
  41485. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41486. import { Scene } from "babylonjs/scene";
  41487. /**
  41488. * Class containing static functions to help procedurally build meshes
  41489. */
  41490. export class LinesBuilder {
  41491. /**
  41492. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41493. * * 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
  41494. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41495. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41496. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41497. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41498. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41499. * * 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
  41500. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41503. * @param name defines the name of the new line system
  41504. * @param options defines the options used to create the line system
  41505. * @param scene defines the hosting scene
  41506. * @returns a new line system mesh
  41507. */
  41508. static CreateLineSystem(name: string, options: {
  41509. lines: Vector3[][];
  41510. updatable?: boolean;
  41511. instance?: Nullable<LinesMesh>;
  41512. colors?: Nullable<Color4[][]>;
  41513. useVertexAlpha?: boolean;
  41514. }, scene: Nullable<Scene>): LinesMesh;
  41515. /**
  41516. * Creates a line mesh
  41517. * 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
  41518. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41519. * * The parameter `points` is an array successive Vector3
  41520. * * 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
  41521. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41522. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41523. * * When updating an instance, remember that only point positions can change, not the number of points
  41524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41525. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41526. * @param name defines the name of the new line system
  41527. * @param options defines the options used to create the line system
  41528. * @param scene defines the hosting scene
  41529. * @returns a new line mesh
  41530. */
  41531. static CreateLines(name: string, options: {
  41532. points: Vector3[];
  41533. updatable?: boolean;
  41534. instance?: Nullable<LinesMesh>;
  41535. colors?: Color4[];
  41536. useVertexAlpha?: boolean;
  41537. }, scene?: Nullable<Scene>): LinesMesh;
  41538. /**
  41539. * Creates a dashed line mesh
  41540. * * 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
  41541. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41542. * * The parameter `points` is an array successive Vector3
  41543. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41544. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41545. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41546. * * 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
  41547. * * When updating an instance, remember that only point positions can change, not the number of points
  41548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41549. * @param name defines the name of the mesh
  41550. * @param options defines the options used to create the mesh
  41551. * @param scene defines the hosting scene
  41552. * @returns the dashed line mesh
  41553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41554. */
  41555. static CreateDashedLines(name: string, options: {
  41556. points: Vector3[];
  41557. dashSize?: number;
  41558. gapSize?: number;
  41559. dashNb?: number;
  41560. updatable?: boolean;
  41561. instance?: LinesMesh;
  41562. }, scene?: Nullable<Scene>): LinesMesh;
  41563. }
  41564. }
  41565. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41566. import { IDisposable, Scene } from "babylonjs/scene";
  41567. import { Nullable } from "babylonjs/types";
  41568. import { Observable } from "babylonjs/Misc/observable";
  41569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41570. /**
  41571. * Renders a layer on top of an existing scene
  41572. */
  41573. export class UtilityLayerRenderer implements IDisposable {
  41574. /** the original scene that will be rendered on top of */
  41575. originalScene: Scene;
  41576. private _pointerCaptures;
  41577. private _lastPointerEvents;
  41578. private static _DefaultUtilityLayer;
  41579. private static _DefaultKeepDepthUtilityLayer;
  41580. /**
  41581. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41582. */
  41583. pickUtilitySceneFirst: boolean;
  41584. /**
  41585. * 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)
  41586. */
  41587. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41588. /**
  41589. * 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)
  41590. */
  41591. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41592. /**
  41593. * The scene that is rendered on top of the original scene
  41594. */
  41595. utilityLayerScene: Scene;
  41596. /**
  41597. * If the utility layer should automatically be rendered on top of existing scene
  41598. */
  41599. shouldRender: boolean;
  41600. /**
  41601. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41602. */
  41603. onlyCheckPointerDownEvents: boolean;
  41604. /**
  41605. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41606. */
  41607. processAllEvents: boolean;
  41608. /**
  41609. * Observable raised when the pointer move from the utility layer scene to the main scene
  41610. */
  41611. onPointerOutObservable: Observable<number>;
  41612. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41613. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41614. private _afterRenderObserver;
  41615. private _sceneDisposeObserver;
  41616. private _originalPointerObserver;
  41617. /**
  41618. * Instantiates a UtilityLayerRenderer
  41619. * @param originalScene the original scene that will be rendered on top of
  41620. * @param handleEvents boolean indicating if the utility layer should handle events
  41621. */
  41622. constructor(
  41623. /** the original scene that will be rendered on top of */
  41624. originalScene: Scene, handleEvents?: boolean);
  41625. private _notifyObservers;
  41626. /**
  41627. * Renders the utility layers scene on top of the original scene
  41628. */
  41629. render(): void;
  41630. /**
  41631. * Disposes of the renderer
  41632. */
  41633. dispose(): void;
  41634. private _updateCamera;
  41635. }
  41636. }
  41637. declare module "babylonjs/Gizmos/gizmo" {
  41638. import { Nullable } from "babylonjs/types";
  41639. import { IDisposable } from "babylonjs/scene";
  41640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41641. import { Mesh } from "babylonjs/Meshes/mesh";
  41642. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41643. /**
  41644. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41645. */
  41646. export class Gizmo implements IDisposable {
  41647. /** The utility layer the gizmo will be added to */
  41648. gizmoLayer: UtilityLayerRenderer;
  41649. /**
  41650. * The root mesh of the gizmo
  41651. */
  41652. _rootMesh: Mesh;
  41653. private _attachedMesh;
  41654. /**
  41655. * Ratio for the scale of the gizmo (Default: 1)
  41656. */
  41657. scaleRatio: number;
  41658. private _tmpMatrix;
  41659. /**
  41660. * If a custom mesh has been set (Default: false)
  41661. */
  41662. protected _customMeshSet: boolean;
  41663. /**
  41664. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41665. * * When set, interactions will be enabled
  41666. */
  41667. attachedMesh: Nullable<AbstractMesh>;
  41668. /**
  41669. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41670. * @param mesh The mesh to replace the default mesh of the gizmo
  41671. */
  41672. setCustomMesh(mesh: Mesh): void;
  41673. /**
  41674. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41675. */
  41676. updateGizmoRotationToMatchAttachedMesh: boolean;
  41677. /**
  41678. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41679. */
  41680. updateGizmoPositionToMatchAttachedMesh: boolean;
  41681. /**
  41682. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41683. */
  41684. protected _updateScale: boolean;
  41685. protected _interactionsEnabled: boolean;
  41686. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41687. private _beforeRenderObserver;
  41688. /**
  41689. * Creates a gizmo
  41690. * @param gizmoLayer The utility layer the gizmo will be added to
  41691. */
  41692. constructor(
  41693. /** The utility layer the gizmo will be added to */
  41694. gizmoLayer?: UtilityLayerRenderer);
  41695. private _tempVector;
  41696. /**
  41697. * @hidden
  41698. * Updates the gizmo to match the attached mesh's position/rotation
  41699. */
  41700. protected _update(): void;
  41701. /**
  41702. * Disposes of the gizmo
  41703. */
  41704. dispose(): void;
  41705. }
  41706. }
  41707. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41708. import { Observable } from "babylonjs/Misc/observable";
  41709. import { Nullable } from "babylonjs/types";
  41710. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41711. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41713. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41714. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41715. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41716. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41717. import { Scene } from "babylonjs/scene";
  41718. /**
  41719. * Single axis drag gizmo
  41720. */
  41721. export class AxisDragGizmo extends Gizmo {
  41722. /**
  41723. * Drag behavior responsible for the gizmos dragging interactions
  41724. */
  41725. dragBehavior: PointerDragBehavior;
  41726. private _pointerObserver;
  41727. /**
  41728. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41729. */
  41730. snapDistance: number;
  41731. /**
  41732. * Event that fires each time the gizmo snaps to a new location.
  41733. * * snapDistance is the the change in distance
  41734. */
  41735. onSnapObservable: Observable<{
  41736. snapDistance: number;
  41737. }>;
  41738. /** @hidden */
  41739. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41740. /** @hidden */
  41741. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41742. /**
  41743. * Creates an AxisDragGizmo
  41744. * @param gizmoLayer The utility layer the gizmo will be added to
  41745. * @param dragAxis The axis which the gizmo will be able to drag on
  41746. * @param color The color of the gizmo
  41747. */
  41748. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41749. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41750. /**
  41751. * Disposes of the gizmo
  41752. */
  41753. dispose(): void;
  41754. }
  41755. }
  41756. declare module "babylonjs/Debug/axesViewer" {
  41757. import { Vector3 } from "babylonjs/Maths/math";
  41758. import { Nullable } from "babylonjs/types";
  41759. import { Scene } from "babylonjs/scene";
  41760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41761. /**
  41762. * The Axes viewer will show 3 axes in a specific point in space
  41763. */
  41764. export class AxesViewer {
  41765. private _xAxis;
  41766. private _yAxis;
  41767. private _zAxis;
  41768. private _scaleLinesFactor;
  41769. private _instanced;
  41770. /**
  41771. * Gets the hosting scene
  41772. */
  41773. scene: Scene;
  41774. /**
  41775. * Gets or sets a number used to scale line length
  41776. */
  41777. scaleLines: number;
  41778. /** Gets the node hierarchy used to render x-axis */
  41779. readonly xAxis: TransformNode;
  41780. /** Gets the node hierarchy used to render y-axis */
  41781. readonly yAxis: TransformNode;
  41782. /** Gets the node hierarchy used to render z-axis */
  41783. readonly zAxis: TransformNode;
  41784. /**
  41785. * Creates a new AxesViewer
  41786. * @param scene defines the hosting scene
  41787. * @param scaleLines defines a number used to scale line length (1 by default)
  41788. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41789. * @param xAxis defines the node hierarchy used to render the x-axis
  41790. * @param yAxis defines the node hierarchy used to render the y-axis
  41791. * @param zAxis defines the node hierarchy used to render the z-axis
  41792. */
  41793. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41794. /**
  41795. * Force the viewer to update
  41796. * @param position defines the position of the viewer
  41797. * @param xaxis defines the x axis of the viewer
  41798. * @param yaxis defines the y axis of the viewer
  41799. * @param zaxis defines the z axis of the viewer
  41800. */
  41801. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41802. /**
  41803. * Creates an instance of this axes viewer.
  41804. * @returns a new axes viewer with instanced meshes
  41805. */
  41806. createInstance(): AxesViewer;
  41807. /** Releases resources */
  41808. dispose(): void;
  41809. private static _SetRenderingGroupId;
  41810. }
  41811. }
  41812. declare module "babylonjs/Debug/boneAxesViewer" {
  41813. import { Nullable } from "babylonjs/types";
  41814. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41815. import { Vector3 } from "babylonjs/Maths/math";
  41816. import { Mesh } from "babylonjs/Meshes/mesh";
  41817. import { Bone } from "babylonjs/Bones/bone";
  41818. import { Scene } from "babylonjs/scene";
  41819. /**
  41820. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41821. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41822. */
  41823. export class BoneAxesViewer extends AxesViewer {
  41824. /**
  41825. * Gets or sets the target mesh where to display the axes viewer
  41826. */
  41827. mesh: Nullable<Mesh>;
  41828. /**
  41829. * Gets or sets the target bone where to display the axes viewer
  41830. */
  41831. bone: Nullable<Bone>;
  41832. /** Gets current position */
  41833. pos: Vector3;
  41834. /** Gets direction of X axis */
  41835. xaxis: Vector3;
  41836. /** Gets direction of Y axis */
  41837. yaxis: Vector3;
  41838. /** Gets direction of Z axis */
  41839. zaxis: Vector3;
  41840. /**
  41841. * Creates a new BoneAxesViewer
  41842. * @param scene defines the hosting scene
  41843. * @param bone defines the target bone
  41844. * @param mesh defines the target mesh
  41845. * @param scaleLines defines a scaling factor for line length (1 by default)
  41846. */
  41847. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41848. /**
  41849. * Force the viewer to update
  41850. */
  41851. update(): void;
  41852. /** Releases resources */
  41853. dispose(): void;
  41854. }
  41855. }
  41856. declare module "babylonjs/Debug/debugLayer" {
  41857. import { Observable } from "babylonjs/Misc/observable";
  41858. import { Scene } from "babylonjs/scene";
  41859. /**
  41860. * Interface used to define scene explorer extensibility option
  41861. */
  41862. export interface IExplorerExtensibilityOption {
  41863. /**
  41864. * Define the option label
  41865. */
  41866. label: string;
  41867. /**
  41868. * Defines the action to execute on click
  41869. */
  41870. action: (entity: any) => void;
  41871. }
  41872. /**
  41873. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41874. */
  41875. export interface IExplorerExtensibilityGroup {
  41876. /**
  41877. * Defines a predicate to test if a given type mut be extended
  41878. */
  41879. predicate: (entity: any) => boolean;
  41880. /**
  41881. * Gets the list of options added to a type
  41882. */
  41883. entries: IExplorerExtensibilityOption[];
  41884. }
  41885. /**
  41886. * Interface used to define the options to use to create the Inspector
  41887. */
  41888. export interface IInspectorOptions {
  41889. /**
  41890. * Display in overlay mode (default: false)
  41891. */
  41892. overlay?: boolean;
  41893. /**
  41894. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41895. */
  41896. globalRoot?: HTMLElement;
  41897. /**
  41898. * Display the Scene explorer
  41899. */
  41900. showExplorer?: boolean;
  41901. /**
  41902. * Display the property inspector
  41903. */
  41904. showInspector?: boolean;
  41905. /**
  41906. * Display in embed mode (both panes on the right)
  41907. */
  41908. embedMode?: boolean;
  41909. /**
  41910. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41911. */
  41912. handleResize?: boolean;
  41913. /**
  41914. * Allow the panes to popup (default: true)
  41915. */
  41916. enablePopup?: boolean;
  41917. /**
  41918. * Allow the panes to be closed by users (default: true)
  41919. */
  41920. enableClose?: boolean;
  41921. /**
  41922. * Optional list of extensibility entries
  41923. */
  41924. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41925. /**
  41926. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41927. */
  41928. inspectorURL?: string;
  41929. }
  41930. module "babylonjs/scene" {
  41931. interface Scene {
  41932. /**
  41933. * @hidden
  41934. * Backing field
  41935. */
  41936. _debugLayer: DebugLayer;
  41937. /**
  41938. * Gets the debug layer (aka Inspector) associated with the scene
  41939. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41940. */
  41941. debugLayer: DebugLayer;
  41942. }
  41943. }
  41944. /**
  41945. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41946. * what is happening in your scene
  41947. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41948. */
  41949. export class DebugLayer {
  41950. /**
  41951. * Define the url to get the inspector script from.
  41952. * By default it uses the babylonjs CDN.
  41953. * @ignoreNaming
  41954. */
  41955. static InspectorURL: string;
  41956. private _scene;
  41957. private BJSINSPECTOR;
  41958. /**
  41959. * Observable triggered when a property is changed through the inspector.
  41960. */
  41961. onPropertyChangedObservable: Observable<{
  41962. object: any;
  41963. property: string;
  41964. value: any;
  41965. initialValue: any;
  41966. }>;
  41967. /**
  41968. * Instantiates a new debug layer.
  41969. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41970. * what is happening in your scene
  41971. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41972. * @param scene Defines the scene to inspect
  41973. */
  41974. constructor(scene: Scene);
  41975. /** Creates the inspector window. */
  41976. private _createInspector;
  41977. /**
  41978. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41979. * @param entity defines the entity to select
  41980. * @param lineContainerTitle defines the specific block to highlight
  41981. */
  41982. select(entity: any, lineContainerTitle?: string): void;
  41983. /** Get the inspector from bundle or global */
  41984. private _getGlobalInspector;
  41985. /**
  41986. * Get if the inspector is visible or not.
  41987. * @returns true if visible otherwise, false
  41988. */
  41989. isVisible(): boolean;
  41990. /**
  41991. * Hide the inspector and close its window.
  41992. */
  41993. hide(): void;
  41994. /**
  41995. * Launch the debugLayer.
  41996. * @param config Define the configuration of the inspector
  41997. * @return a promise fulfilled when the debug layer is visible
  41998. */
  41999. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42000. }
  42001. }
  42002. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42003. import { Nullable } from "babylonjs/types";
  42004. import { Scene } from "babylonjs/scene";
  42005. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42006. import { Mesh } from "babylonjs/Meshes/mesh";
  42007. /**
  42008. * Class containing static functions to help procedurally build meshes
  42009. */
  42010. export class BoxBuilder {
  42011. /**
  42012. * Creates a box mesh
  42013. * * The parameter `size` sets the size (float) of each box side (default 1)
  42014. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42015. * * 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)
  42016. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42018. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42020. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42021. * @param name defines the name of the mesh
  42022. * @param options defines the options used to create the mesh
  42023. * @param scene defines the hosting scene
  42024. * @returns the box mesh
  42025. */
  42026. static CreateBox(name: string, options: {
  42027. size?: number;
  42028. width?: number;
  42029. height?: number;
  42030. depth?: number;
  42031. faceUV?: Vector4[];
  42032. faceColors?: Color4[];
  42033. sideOrientation?: number;
  42034. frontUVs?: Vector4;
  42035. backUVs?: Vector4;
  42036. updatable?: boolean;
  42037. }, scene?: Nullable<Scene>): Mesh;
  42038. }
  42039. }
  42040. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42041. import { Vector4 } from "babylonjs/Maths/math";
  42042. import { Mesh } from "babylonjs/Meshes/mesh";
  42043. /**
  42044. * Class containing static functions to help procedurally build meshes
  42045. */
  42046. export class SphereBuilder {
  42047. /**
  42048. * Creates a sphere mesh
  42049. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42050. * * 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`)
  42051. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42052. * * 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
  42053. * * 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)
  42054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42057. * @param name defines the name of the mesh
  42058. * @param options defines the options used to create the mesh
  42059. * @param scene defines the hosting scene
  42060. * @returns the sphere mesh
  42061. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42062. */
  42063. static CreateSphere(name: string, options: {
  42064. segments?: number;
  42065. diameter?: number;
  42066. diameterX?: number;
  42067. diameterY?: number;
  42068. diameterZ?: number;
  42069. arc?: number;
  42070. slice?: number;
  42071. sideOrientation?: number;
  42072. frontUVs?: Vector4;
  42073. backUVs?: Vector4;
  42074. updatable?: boolean;
  42075. }, scene: any): Mesh;
  42076. }
  42077. }
  42078. declare module "babylonjs/Debug/physicsViewer" {
  42079. import { Nullable } from "babylonjs/types";
  42080. import { Scene } from "babylonjs/scene";
  42081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42082. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42083. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42084. /**
  42085. * Used to show the physics impostor around the specific mesh
  42086. */
  42087. export class PhysicsViewer {
  42088. /** @hidden */
  42089. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42090. /** @hidden */
  42091. protected _meshes: Array<Nullable<AbstractMesh>>;
  42092. /** @hidden */
  42093. protected _scene: Nullable<Scene>;
  42094. /** @hidden */
  42095. protected _numMeshes: number;
  42096. /** @hidden */
  42097. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42098. private _renderFunction;
  42099. private _utilityLayer;
  42100. private _debugBoxMesh;
  42101. private _debugSphereMesh;
  42102. private _debugMaterial;
  42103. /**
  42104. * Creates a new PhysicsViewer
  42105. * @param scene defines the hosting scene
  42106. */
  42107. constructor(scene: Scene);
  42108. /** @hidden */
  42109. protected _updateDebugMeshes(): void;
  42110. /**
  42111. * Renders a specified physic impostor
  42112. * @param impostor defines the impostor to render
  42113. * @returns the new debug mesh used to render the impostor
  42114. */
  42115. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42116. /**
  42117. * Hides a specified physic impostor
  42118. * @param impostor defines the impostor to hide
  42119. */
  42120. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42121. private _getDebugMaterial;
  42122. private _getDebugBoxMesh;
  42123. private _getDebugSphereMesh;
  42124. private _getDebugMesh;
  42125. /** Releases all resources */
  42126. dispose(): void;
  42127. }
  42128. }
  42129. declare module "babylonjs/Debug/rayHelper" {
  42130. import { Nullable } from "babylonjs/types";
  42131. import { Ray } from "babylonjs/Culling/ray";
  42132. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42133. import { Scene } from "babylonjs/scene";
  42134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42135. import "babylonjs/Meshes/Builders/linesBuilder";
  42136. /**
  42137. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42138. * in order to better appreciate the issue one might have.
  42139. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42140. */
  42141. export class RayHelper {
  42142. /**
  42143. * Defines the ray we are currently tryin to visualize.
  42144. */
  42145. ray: Nullable<Ray>;
  42146. private _renderPoints;
  42147. private _renderLine;
  42148. private _renderFunction;
  42149. private _scene;
  42150. private _updateToMeshFunction;
  42151. private _attachedToMesh;
  42152. private _meshSpaceDirection;
  42153. private _meshSpaceOrigin;
  42154. /**
  42155. * Helper function to create a colored helper in a scene in one line.
  42156. * @param ray Defines the ray we are currently tryin to visualize
  42157. * @param scene Defines the scene the ray is used in
  42158. * @param color Defines the color we want to see the ray in
  42159. * @returns The newly created ray helper.
  42160. */
  42161. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42162. /**
  42163. * Instantiate a new ray helper.
  42164. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42165. * in order to better appreciate the issue one might have.
  42166. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42167. * @param ray Defines the ray we are currently tryin to visualize
  42168. */
  42169. constructor(ray: Ray);
  42170. /**
  42171. * Shows the ray we are willing to debug.
  42172. * @param scene Defines the scene the ray needs to be rendered in
  42173. * @param color Defines the color the ray needs to be rendered in
  42174. */
  42175. show(scene: Scene, color?: Color3): void;
  42176. /**
  42177. * Hides the ray we are debugging.
  42178. */
  42179. hide(): void;
  42180. private _render;
  42181. /**
  42182. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42183. * @param mesh Defines the mesh we want the helper attached to
  42184. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42185. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42186. * @param length Defines the length of the ray
  42187. */
  42188. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42189. /**
  42190. * Detach the ray helper from the mesh it has previously been attached to.
  42191. */
  42192. detachFromMesh(): void;
  42193. private _updateToMesh;
  42194. /**
  42195. * Dispose the helper and release its associated resources.
  42196. */
  42197. dispose(): void;
  42198. }
  42199. }
  42200. declare module "babylonjs/Debug/skeletonViewer" {
  42201. import { Color3 } from "babylonjs/Maths/math";
  42202. import { Scene } from "babylonjs/scene";
  42203. import { Nullable } from "babylonjs/types";
  42204. import { Skeleton } from "babylonjs/Bones/skeleton";
  42205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42206. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42207. /**
  42208. * Class used to render a debug view of a given skeleton
  42209. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42210. */
  42211. export class SkeletonViewer {
  42212. /** defines the skeleton to render */
  42213. skeleton: Skeleton;
  42214. /** defines the mesh attached to the skeleton */
  42215. mesh: AbstractMesh;
  42216. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42217. autoUpdateBonesMatrices: boolean;
  42218. /** defines the rendering group id to use with the viewer */
  42219. renderingGroupId: number;
  42220. /** Gets or sets the color used to render the skeleton */
  42221. color: Color3;
  42222. private _scene;
  42223. private _debugLines;
  42224. private _debugMesh;
  42225. private _isEnabled;
  42226. private _renderFunction;
  42227. private _utilityLayer;
  42228. /**
  42229. * Returns the mesh used to render the bones
  42230. */
  42231. readonly debugMesh: Nullable<LinesMesh>;
  42232. /**
  42233. * Creates a new SkeletonViewer
  42234. * @param skeleton defines the skeleton to render
  42235. * @param mesh defines the mesh attached to the skeleton
  42236. * @param scene defines the hosting scene
  42237. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42238. * @param renderingGroupId defines the rendering group id to use with the viewer
  42239. */
  42240. constructor(
  42241. /** defines the skeleton to render */
  42242. skeleton: Skeleton,
  42243. /** defines the mesh attached to the skeleton */
  42244. mesh: AbstractMesh, scene: Scene,
  42245. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42246. autoUpdateBonesMatrices?: boolean,
  42247. /** defines the rendering group id to use with the viewer */
  42248. renderingGroupId?: number);
  42249. /** Gets or sets a boolean indicating if the viewer is enabled */
  42250. isEnabled: boolean;
  42251. private _getBonePosition;
  42252. private _getLinesForBonesWithLength;
  42253. private _getLinesForBonesNoLength;
  42254. /** Update the viewer to sync with current skeleton state */
  42255. update(): void;
  42256. /** Release associated resources */
  42257. dispose(): void;
  42258. }
  42259. }
  42260. declare module "babylonjs/Debug/index" {
  42261. export * from "babylonjs/Debug/axesViewer";
  42262. export * from "babylonjs/Debug/boneAxesViewer";
  42263. export * from "babylonjs/Debug/debugLayer";
  42264. export * from "babylonjs/Debug/physicsViewer";
  42265. export * from "babylonjs/Debug/rayHelper";
  42266. export * from "babylonjs/Debug/skeletonViewer";
  42267. }
  42268. declare module "babylonjs/Engines/nullEngine" {
  42269. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42270. import { Scene } from "babylonjs/scene";
  42271. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42272. import { Engine } from "babylonjs/Engines/engine";
  42273. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42274. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42275. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42276. import { Effect } from "babylonjs/Materials/effect";
  42277. /**
  42278. * Options to create the null engine
  42279. */
  42280. export class NullEngineOptions {
  42281. /**
  42282. * Render width (Default: 512)
  42283. */
  42284. renderWidth: number;
  42285. /**
  42286. * Render height (Default: 256)
  42287. */
  42288. renderHeight: number;
  42289. /**
  42290. * Texture size (Default: 512)
  42291. */
  42292. textureSize: number;
  42293. /**
  42294. * If delta time between frames should be constant
  42295. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42296. */
  42297. deterministicLockstep: boolean;
  42298. /**
  42299. * Maximum about of steps between frames (Default: 4)
  42300. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42301. */
  42302. lockstepMaxSteps: number;
  42303. }
  42304. /**
  42305. * The null engine class provides support for headless version of babylon.js.
  42306. * This can be used in server side scenario or for testing purposes
  42307. */
  42308. export class NullEngine extends Engine {
  42309. private _options;
  42310. /**
  42311. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42312. */
  42313. isDeterministicLockStep(): boolean;
  42314. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42315. getLockstepMaxSteps(): number;
  42316. /**
  42317. * Sets hardware scaling, used to save performance if needed
  42318. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42319. */
  42320. getHardwareScalingLevel(): number;
  42321. constructor(options?: NullEngineOptions);
  42322. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42323. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42324. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42325. getRenderWidth(useScreen?: boolean): number;
  42326. getRenderHeight(useScreen?: boolean): number;
  42327. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42328. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42329. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42330. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42331. bindSamplers(effect: Effect): void;
  42332. enableEffect(effect: Effect): void;
  42333. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42334. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42335. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42336. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42337. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42338. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42339. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42340. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42341. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42342. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42343. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42344. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42345. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42346. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42347. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42348. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42349. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42350. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42351. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42352. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42353. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42354. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42355. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42356. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42357. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42358. bindBuffers(vertexBuffers: {
  42359. [key: string]: VertexBuffer;
  42360. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42361. wipeCaches(bruteForce?: boolean): void;
  42362. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42363. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42364. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42365. /** @hidden */
  42366. _createTexture(): WebGLTexture;
  42367. /** @hidden */
  42368. _releaseTexture(texture: InternalTexture): void;
  42369. 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;
  42370. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42371. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42372. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42373. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42374. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42375. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42376. areAllEffectsReady(): boolean;
  42377. /**
  42378. * @hidden
  42379. * Get the current error code of the webGL context
  42380. * @returns the error code
  42381. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42382. */
  42383. getError(): number;
  42384. /** @hidden */
  42385. _getUnpackAlignement(): number;
  42386. /** @hidden */
  42387. _unpackFlipY(value: boolean): void;
  42388. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42389. /**
  42390. * Updates a dynamic vertex buffer.
  42391. * @param vertexBuffer the vertex buffer to update
  42392. * @param data the data used to update the vertex buffer
  42393. * @param byteOffset the byte offset of the data (optional)
  42394. * @param byteLength the byte length of the data (optional)
  42395. */
  42396. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42397. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42398. /** @hidden */
  42399. _bindTexture(channel: number, texture: InternalTexture): void;
  42400. /** @hidden */
  42401. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42402. releaseEffects(): void;
  42403. displayLoadingUI(): void;
  42404. hideLoadingUI(): void;
  42405. /** @hidden */
  42406. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42407. /** @hidden */
  42408. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42409. /** @hidden */
  42410. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42411. /** @hidden */
  42412. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42413. }
  42414. }
  42415. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42416. import { Nullable, int } from "babylonjs/types";
  42417. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42418. /** @hidden */
  42419. export class _OcclusionDataStorage {
  42420. /** @hidden */
  42421. occlusionInternalRetryCounter: number;
  42422. /** @hidden */
  42423. isOcclusionQueryInProgress: boolean;
  42424. /** @hidden */
  42425. isOccluded: boolean;
  42426. /** @hidden */
  42427. occlusionRetryCount: number;
  42428. /** @hidden */
  42429. occlusionType: number;
  42430. /** @hidden */
  42431. occlusionQueryAlgorithmType: number;
  42432. }
  42433. module "babylonjs/Engines/engine" {
  42434. interface Engine {
  42435. /**
  42436. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42437. * @return the new query
  42438. */
  42439. createQuery(): WebGLQuery;
  42440. /**
  42441. * Delete and release a webGL query
  42442. * @param query defines the query to delete
  42443. * @return the current engine
  42444. */
  42445. deleteQuery(query: WebGLQuery): Engine;
  42446. /**
  42447. * Check if a given query has resolved and got its value
  42448. * @param query defines the query to check
  42449. * @returns true if the query got its value
  42450. */
  42451. isQueryResultAvailable(query: WebGLQuery): boolean;
  42452. /**
  42453. * Gets the value of a given query
  42454. * @param query defines the query to check
  42455. * @returns the value of the query
  42456. */
  42457. getQueryResult(query: WebGLQuery): number;
  42458. /**
  42459. * Initiates an occlusion query
  42460. * @param algorithmType defines the algorithm to use
  42461. * @param query defines the query to use
  42462. * @returns the current engine
  42463. * @see http://doc.babylonjs.com/features/occlusionquery
  42464. */
  42465. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42466. /**
  42467. * Ends an occlusion query
  42468. * @see http://doc.babylonjs.com/features/occlusionquery
  42469. * @param algorithmType defines the algorithm to use
  42470. * @returns the current engine
  42471. */
  42472. endOcclusionQuery(algorithmType: number): Engine;
  42473. /**
  42474. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42475. * Please note that only one query can be issued at a time
  42476. * @returns a time token used to track the time span
  42477. */
  42478. startTimeQuery(): Nullable<_TimeToken>;
  42479. /**
  42480. * Ends a time query
  42481. * @param token defines the token used to measure the time span
  42482. * @returns the time spent (in ns)
  42483. */
  42484. endTimeQuery(token: _TimeToken): int;
  42485. /** @hidden */
  42486. _currentNonTimestampToken: Nullable<_TimeToken>;
  42487. /** @hidden */
  42488. _createTimeQuery(): WebGLQuery;
  42489. /** @hidden */
  42490. _deleteTimeQuery(query: WebGLQuery): void;
  42491. /** @hidden */
  42492. _getGlAlgorithmType(algorithmType: number): number;
  42493. /** @hidden */
  42494. _getTimeQueryResult(query: WebGLQuery): any;
  42495. /** @hidden */
  42496. _getTimeQueryAvailability(query: WebGLQuery): any;
  42497. }
  42498. }
  42499. module "babylonjs/Meshes/abstractMesh" {
  42500. interface AbstractMesh {
  42501. /**
  42502. * Backing filed
  42503. * @hidden
  42504. */
  42505. __occlusionDataStorage: _OcclusionDataStorage;
  42506. /**
  42507. * Access property
  42508. * @hidden
  42509. */
  42510. _occlusionDataStorage: _OcclusionDataStorage;
  42511. /**
  42512. * 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.
  42513. * The default value is -1 which means don't break the query and wait till the result
  42514. * @see http://doc.babylonjs.com/features/occlusionquery
  42515. */
  42516. occlusionRetryCount: number;
  42517. /**
  42518. * 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:
  42519. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42520. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42521. * * 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.
  42522. * @see http://doc.babylonjs.com/features/occlusionquery
  42523. */
  42524. occlusionType: number;
  42525. /**
  42526. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42527. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42528. * * 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.
  42529. * @see http://doc.babylonjs.com/features/occlusionquery
  42530. */
  42531. occlusionQueryAlgorithmType: number;
  42532. /**
  42533. * 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
  42534. * @see http://doc.babylonjs.com/features/occlusionquery
  42535. */
  42536. isOccluded: boolean;
  42537. /**
  42538. * Flag to check the progress status of the query
  42539. * @see http://doc.babylonjs.com/features/occlusionquery
  42540. */
  42541. isOcclusionQueryInProgress: boolean;
  42542. }
  42543. }
  42544. }
  42545. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42546. import { Nullable } from "babylonjs/types";
  42547. /** @hidden */
  42548. export var _forceTransformFeedbackToBundle: boolean;
  42549. module "babylonjs/Engines/engine" {
  42550. interface Engine {
  42551. /**
  42552. * Creates a webGL transform feedback object
  42553. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42554. * @returns the webGL transform feedback object
  42555. */
  42556. createTransformFeedback(): WebGLTransformFeedback;
  42557. /**
  42558. * Delete a webGL transform feedback object
  42559. * @param value defines the webGL transform feedback object to delete
  42560. */
  42561. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42562. /**
  42563. * Bind a webGL transform feedback object to the webgl context
  42564. * @param value defines the webGL transform feedback object to bind
  42565. */
  42566. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42567. /**
  42568. * Begins a transform feedback operation
  42569. * @param usePoints defines if points or triangles must be used
  42570. */
  42571. beginTransformFeedback(usePoints: boolean): void;
  42572. /**
  42573. * Ends a transform feedback operation
  42574. */
  42575. endTransformFeedback(): void;
  42576. /**
  42577. * Specify the varyings to use with transform feedback
  42578. * @param program defines the associated webGL program
  42579. * @param value defines the list of strings representing the varying names
  42580. */
  42581. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42582. /**
  42583. * Bind a webGL buffer for a transform feedback operation
  42584. * @param value defines the webGL buffer to bind
  42585. */
  42586. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42587. }
  42588. }
  42589. }
  42590. declare module "babylonjs/Engines/Extensions/index" {
  42591. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42592. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42593. }
  42594. declare module "babylonjs/Engines/index" {
  42595. export * from "babylonjs/Engines/constants";
  42596. export * from "babylonjs/Engines/engine";
  42597. export * from "babylonjs/Engines/engineStore";
  42598. export * from "babylonjs/Engines/nullEngine";
  42599. export * from "babylonjs/Engines/Extensions/index";
  42600. }
  42601. declare module "babylonjs/Events/clipboardEvents" {
  42602. /**
  42603. * Gather the list of clipboard event types as constants.
  42604. */
  42605. export class ClipboardEventTypes {
  42606. /**
  42607. * The clipboard event is fired when a copy command is active (pressed).
  42608. */
  42609. static readonly COPY: number;
  42610. /**
  42611. * The clipboard event is fired when a cut command is active (pressed).
  42612. */
  42613. static readonly CUT: number;
  42614. /**
  42615. * The clipboard event is fired when a paste command is active (pressed).
  42616. */
  42617. static readonly PASTE: number;
  42618. }
  42619. /**
  42620. * This class is used to store clipboard related info for the onClipboardObservable event.
  42621. */
  42622. export class ClipboardInfo {
  42623. /**
  42624. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42625. */
  42626. type: number;
  42627. /**
  42628. * Defines the related dom event
  42629. */
  42630. event: ClipboardEvent;
  42631. /**
  42632. *Creates an instance of ClipboardInfo.
  42633. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42634. * @param event Defines the related dom event
  42635. */
  42636. constructor(
  42637. /**
  42638. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42639. */
  42640. type: number,
  42641. /**
  42642. * Defines the related dom event
  42643. */
  42644. event: ClipboardEvent);
  42645. /**
  42646. * Get the clipboard event's type from the keycode.
  42647. * @param keyCode Defines the keyCode for the current keyboard event.
  42648. * @return {number}
  42649. */
  42650. static GetTypeFromCharacter(keyCode: number): number;
  42651. }
  42652. }
  42653. declare module "babylonjs/Events/index" {
  42654. export * from "babylonjs/Events/keyboardEvents";
  42655. export * from "babylonjs/Events/pointerEvents";
  42656. export * from "babylonjs/Events/clipboardEvents";
  42657. }
  42658. declare module "babylonjs/Loading/sceneLoader" {
  42659. import { Observable } from "babylonjs/Misc/observable";
  42660. import { Nullable } from "babylonjs/types";
  42661. import { Scene } from "babylonjs/scene";
  42662. import { Engine } from "babylonjs/Engines/engine";
  42663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42664. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42665. import { AssetContainer } from "babylonjs/assetContainer";
  42666. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42667. import { Skeleton } from "babylonjs/Bones/skeleton";
  42668. /**
  42669. * Class used to represent data loading progression
  42670. */
  42671. export class SceneLoaderProgressEvent {
  42672. /** defines if data length to load can be evaluated */
  42673. readonly lengthComputable: boolean;
  42674. /** defines the loaded data length */
  42675. readonly loaded: number;
  42676. /** defines the data length to load */
  42677. readonly total: number;
  42678. /**
  42679. * Create a new progress event
  42680. * @param lengthComputable defines if data length to load can be evaluated
  42681. * @param loaded defines the loaded data length
  42682. * @param total defines the data length to load
  42683. */
  42684. constructor(
  42685. /** defines if data length to load can be evaluated */
  42686. lengthComputable: boolean,
  42687. /** defines the loaded data length */
  42688. loaded: number,
  42689. /** defines the data length to load */
  42690. total: number);
  42691. /**
  42692. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42693. * @param event defines the source event
  42694. * @returns a new SceneLoaderProgressEvent
  42695. */
  42696. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42697. }
  42698. /**
  42699. * Interface used by SceneLoader plugins to define supported file extensions
  42700. */
  42701. export interface ISceneLoaderPluginExtensions {
  42702. /**
  42703. * Defines the list of supported extensions
  42704. */
  42705. [extension: string]: {
  42706. isBinary: boolean;
  42707. };
  42708. }
  42709. /**
  42710. * Interface used by SceneLoader plugin factory
  42711. */
  42712. export interface ISceneLoaderPluginFactory {
  42713. /**
  42714. * Defines the name of the factory
  42715. */
  42716. name: string;
  42717. /**
  42718. * Function called to create a new plugin
  42719. * @return the new plugin
  42720. */
  42721. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42722. /**
  42723. * Boolean indicating if the plugin can direct load specific data
  42724. */
  42725. canDirectLoad?: (data: string) => boolean;
  42726. }
  42727. /**
  42728. * Interface used to define a SceneLoader plugin
  42729. */
  42730. export interface ISceneLoaderPlugin {
  42731. /**
  42732. * The friendly name of this plugin.
  42733. */
  42734. name: string;
  42735. /**
  42736. * The file extensions supported by this plugin.
  42737. */
  42738. extensions: string | ISceneLoaderPluginExtensions;
  42739. /**
  42740. * Import meshes into a scene.
  42741. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42742. * @param scene The scene to import into
  42743. * @param data The data to import
  42744. * @param rootUrl The root url for scene and resources
  42745. * @param meshes The meshes array to import into
  42746. * @param particleSystems The particle systems array to import into
  42747. * @param skeletons The skeletons array to import into
  42748. * @param onError The callback when import fails
  42749. * @returns True if successful or false otherwise
  42750. */
  42751. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42752. /**
  42753. * Load into a scene.
  42754. * @param scene The scene to load into
  42755. * @param data The data to import
  42756. * @param rootUrl The root url for scene and resources
  42757. * @param onError The callback when import fails
  42758. * @returns true if successful or false otherwise
  42759. */
  42760. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42761. /**
  42762. * The callback that returns true if the data can be directly loaded.
  42763. */
  42764. canDirectLoad?: (data: string) => boolean;
  42765. /**
  42766. * The callback that allows custom handling of the root url based on the response url.
  42767. */
  42768. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42769. /**
  42770. * Load into an asset container.
  42771. * @param scene The scene to load into
  42772. * @param data The data to import
  42773. * @param rootUrl The root url for scene and resources
  42774. * @param onError The callback when import fails
  42775. * @returns The loaded asset container
  42776. */
  42777. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42778. }
  42779. /**
  42780. * Interface used to define an async SceneLoader plugin
  42781. */
  42782. export interface ISceneLoaderPluginAsync {
  42783. /**
  42784. * The friendly name of this plugin.
  42785. */
  42786. name: string;
  42787. /**
  42788. * The file extensions supported by this plugin.
  42789. */
  42790. extensions: string | ISceneLoaderPluginExtensions;
  42791. /**
  42792. * Import meshes into a scene.
  42793. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42794. * @param scene The scene to import into
  42795. * @param data The data to import
  42796. * @param rootUrl The root url for scene and resources
  42797. * @param onProgress The callback when the load progresses
  42798. * @param fileName Defines the name of the file to load
  42799. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42800. */
  42801. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42802. meshes: AbstractMesh[];
  42803. particleSystems: IParticleSystem[];
  42804. skeletons: Skeleton[];
  42805. animationGroups: AnimationGroup[];
  42806. }>;
  42807. /**
  42808. * Load into a scene.
  42809. * @param scene The scene to load into
  42810. * @param data The data to import
  42811. * @param rootUrl The root url for scene and resources
  42812. * @param onProgress The callback when the load progresses
  42813. * @param fileName Defines the name of the file to load
  42814. * @returns Nothing
  42815. */
  42816. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42817. /**
  42818. * The callback that returns true if the data can be directly loaded.
  42819. */
  42820. canDirectLoad?: (data: string) => boolean;
  42821. /**
  42822. * The callback that allows custom handling of the root url based on the response url.
  42823. */
  42824. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42825. /**
  42826. * Load into an asset container.
  42827. * @param scene The scene to load into
  42828. * @param data The data to import
  42829. * @param rootUrl The root url for scene and resources
  42830. * @param onProgress The callback when the load progresses
  42831. * @param fileName Defines the name of the file to load
  42832. * @returns The loaded asset container
  42833. */
  42834. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42835. }
  42836. /**
  42837. * Class used to load scene from various file formats using registered plugins
  42838. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42839. */
  42840. export class SceneLoader {
  42841. /**
  42842. * No logging while loading
  42843. */
  42844. static readonly NO_LOGGING: number;
  42845. /**
  42846. * Minimal logging while loading
  42847. */
  42848. static readonly MINIMAL_LOGGING: number;
  42849. /**
  42850. * Summary logging while loading
  42851. */
  42852. static readonly SUMMARY_LOGGING: number;
  42853. /**
  42854. * Detailled logging while loading
  42855. */
  42856. static readonly DETAILED_LOGGING: number;
  42857. /**
  42858. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42859. */
  42860. static ForceFullSceneLoadingForIncremental: boolean;
  42861. /**
  42862. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42863. */
  42864. static ShowLoadingScreen: boolean;
  42865. /**
  42866. * Defines the current logging level (while loading the scene)
  42867. * @ignorenaming
  42868. */
  42869. static loggingLevel: number;
  42870. /**
  42871. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42872. */
  42873. static CleanBoneMatrixWeights: boolean;
  42874. /**
  42875. * Event raised when a plugin is used to load a scene
  42876. */
  42877. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42878. private static _registeredPlugins;
  42879. private static _getDefaultPlugin;
  42880. private static _getPluginForExtension;
  42881. private static _getPluginForDirectLoad;
  42882. private static _getPluginForFilename;
  42883. private static _getDirectLoad;
  42884. private static _loadData;
  42885. private static _getFileInfo;
  42886. /**
  42887. * Gets a plugin that can load the given extension
  42888. * @param extension defines the extension to load
  42889. * @returns a plugin or null if none works
  42890. */
  42891. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42892. /**
  42893. * Gets a boolean indicating that the given extension can be loaded
  42894. * @param extension defines the extension to load
  42895. * @returns true if the extension is supported
  42896. */
  42897. static IsPluginForExtensionAvailable(extension: string): boolean;
  42898. /**
  42899. * Adds a new plugin to the list of registered plugins
  42900. * @param plugin defines the plugin to add
  42901. */
  42902. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42903. /**
  42904. * Import meshes into a scene
  42905. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42906. * @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)
  42907. * @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)
  42908. * @param scene the instance of BABYLON.Scene to append to
  42909. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42910. * @param onProgress a callback with a progress event for each file being loaded
  42911. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42912. * @param pluginExtension the extension used to determine the plugin
  42913. * @returns The loaded plugin
  42914. */
  42915. 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>;
  42916. /**
  42917. * Import meshes into a scene
  42918. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42919. * @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)
  42920. * @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)
  42921. * @param scene the instance of BABYLON.Scene to append to
  42922. * @param onProgress a callback with a progress event for each file being loaded
  42923. * @param pluginExtension the extension used to determine the plugin
  42924. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42925. */
  42926. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42927. meshes: AbstractMesh[];
  42928. particleSystems: IParticleSystem[];
  42929. skeletons: Skeleton[];
  42930. animationGroups: AnimationGroup[];
  42931. }>;
  42932. /**
  42933. * Load a scene
  42934. * @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)
  42935. * @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)
  42936. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42937. * @param onSuccess a callback with the scene when import succeeds
  42938. * @param onProgress a callback with a progress event for each file being loaded
  42939. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42940. * @param pluginExtension the extension used to determine the plugin
  42941. * @returns The loaded plugin
  42942. */
  42943. 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>;
  42944. /**
  42945. * Load a scene
  42946. * @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)
  42947. * @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)
  42948. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42949. * @param onProgress a callback with a progress event for each file being loaded
  42950. * @param pluginExtension the extension used to determine the plugin
  42951. * @returns The loaded scene
  42952. */
  42953. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42954. /**
  42955. * Append a scene
  42956. * @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)
  42957. * @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)
  42958. * @param scene is the instance of BABYLON.Scene to append to
  42959. * @param onSuccess a callback with the scene when import succeeds
  42960. * @param onProgress a callback with a progress event for each file being loaded
  42961. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42962. * @param pluginExtension the extension used to determine the plugin
  42963. * @returns The loaded plugin
  42964. */
  42965. 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>;
  42966. /**
  42967. * Append a scene
  42968. * @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)
  42969. * @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)
  42970. * @param scene is the instance of BABYLON.Scene to append to
  42971. * @param onProgress a callback with a progress event for each file being loaded
  42972. * @param pluginExtension the extension used to determine the plugin
  42973. * @returns The given scene
  42974. */
  42975. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42976. /**
  42977. * Load a scene into an asset container
  42978. * @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)
  42979. * @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)
  42980. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42981. * @param onSuccess a callback with the scene when import succeeds
  42982. * @param onProgress a callback with a progress event for each file being loaded
  42983. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42984. * @param pluginExtension the extension used to determine the plugin
  42985. * @returns The loaded plugin
  42986. */
  42987. 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>;
  42988. /**
  42989. * Load a scene into an asset container
  42990. * @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)
  42991. * @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)
  42992. * @param scene is the instance of Scene to append to
  42993. * @param onProgress a callback with a progress event for each file being loaded
  42994. * @param pluginExtension the extension used to determine the plugin
  42995. * @returns The loaded asset container
  42996. */
  42997. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42998. }
  42999. }
  43000. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43001. import { Scene } from "babylonjs/scene";
  43002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43003. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43004. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43005. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43006. /**
  43007. * Google Daydream controller
  43008. */
  43009. export class DaydreamController extends WebVRController {
  43010. /**
  43011. * Base Url for the controller model.
  43012. */
  43013. static MODEL_BASE_URL: string;
  43014. /**
  43015. * File name for the controller model.
  43016. */
  43017. static MODEL_FILENAME: string;
  43018. /**
  43019. * Gamepad Id prefix used to identify Daydream Controller.
  43020. */
  43021. static readonly GAMEPAD_ID_PREFIX: string;
  43022. /**
  43023. * Creates a new DaydreamController from a gamepad
  43024. * @param vrGamepad the gamepad that the controller should be created from
  43025. */
  43026. constructor(vrGamepad: any);
  43027. /**
  43028. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43029. * @param scene scene in which to add meshes
  43030. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43031. */
  43032. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43033. /**
  43034. * Called once for each button that changed state since the last frame
  43035. * @param buttonIdx Which button index changed
  43036. * @param state New state of the button
  43037. * @param changes Which properties on the state changed since last frame
  43038. */
  43039. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43040. }
  43041. }
  43042. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43043. import { Scene } from "babylonjs/scene";
  43044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43045. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43046. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43047. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43048. /**
  43049. * Gear VR Controller
  43050. */
  43051. export class GearVRController extends WebVRController {
  43052. /**
  43053. * Base Url for the controller model.
  43054. */
  43055. static MODEL_BASE_URL: string;
  43056. /**
  43057. * File name for the controller model.
  43058. */
  43059. static MODEL_FILENAME: string;
  43060. /**
  43061. * Gamepad Id prefix used to identify this controller.
  43062. */
  43063. static readonly GAMEPAD_ID_PREFIX: string;
  43064. private readonly _buttonIndexToObservableNameMap;
  43065. /**
  43066. * Creates a new GearVRController from a gamepad
  43067. * @param vrGamepad the gamepad that the controller should be created from
  43068. */
  43069. constructor(vrGamepad: any);
  43070. /**
  43071. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43072. * @param scene scene in which to add meshes
  43073. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43074. */
  43075. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43076. /**
  43077. * Called once for each button that changed state since the last frame
  43078. * @param buttonIdx Which button index changed
  43079. * @param state New state of the button
  43080. * @param changes Which properties on the state changed since last frame
  43081. */
  43082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43083. }
  43084. }
  43085. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43086. import { Scene } from "babylonjs/scene";
  43087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43088. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43089. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43090. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43091. /**
  43092. * Generic Controller
  43093. */
  43094. export class GenericController extends WebVRController {
  43095. /**
  43096. * Base Url for the controller model.
  43097. */
  43098. static readonly MODEL_BASE_URL: string;
  43099. /**
  43100. * File name for the controller model.
  43101. */
  43102. static readonly MODEL_FILENAME: string;
  43103. /**
  43104. * Creates a new GenericController from a gamepad
  43105. * @param vrGamepad the gamepad that the controller should be created from
  43106. */
  43107. constructor(vrGamepad: any);
  43108. /**
  43109. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43110. * @param scene scene in which to add meshes
  43111. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43112. */
  43113. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43114. /**
  43115. * Called once for each button that changed state since the last frame
  43116. * @param buttonIdx Which button index changed
  43117. * @param state New state of the button
  43118. * @param changes Which properties on the state changed since last frame
  43119. */
  43120. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43121. }
  43122. }
  43123. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43124. import { Observable } from "babylonjs/Misc/observable";
  43125. import { Scene } from "babylonjs/scene";
  43126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43127. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43128. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43129. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43130. /**
  43131. * Oculus Touch Controller
  43132. */
  43133. export class OculusTouchController extends WebVRController {
  43134. /**
  43135. * Base Url for the controller model.
  43136. */
  43137. static MODEL_BASE_URL: string;
  43138. /**
  43139. * File name for the left controller model.
  43140. */
  43141. static MODEL_LEFT_FILENAME: string;
  43142. /**
  43143. * File name for the right controller model.
  43144. */
  43145. static MODEL_RIGHT_FILENAME: string;
  43146. /**
  43147. * Fired when the secondary trigger on this controller is modified
  43148. */
  43149. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43150. /**
  43151. * Fired when the thumb rest on this controller is modified
  43152. */
  43153. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43154. /**
  43155. * Creates a new OculusTouchController from a gamepad
  43156. * @param vrGamepad the gamepad that the controller should be created from
  43157. */
  43158. constructor(vrGamepad: any);
  43159. /**
  43160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43161. * @param scene scene in which to add meshes
  43162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43163. */
  43164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43165. /**
  43166. * Fired when the A button on this controller is modified
  43167. */
  43168. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43169. /**
  43170. * Fired when the B button on this controller is modified
  43171. */
  43172. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43173. /**
  43174. * Fired when the X button on this controller is modified
  43175. */
  43176. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43177. /**
  43178. * Fired when the Y button on this controller is modified
  43179. */
  43180. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43181. /**
  43182. * Called once for each button that changed state since the last frame
  43183. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43184. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43185. * 2) secondary trigger (same)
  43186. * 3) A (right) X (left), touch, pressed = value
  43187. * 4) B / Y
  43188. * 5) thumb rest
  43189. * @param buttonIdx Which button index changed
  43190. * @param state New state of the button
  43191. * @param changes Which properties on the state changed since last frame
  43192. */
  43193. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43194. }
  43195. }
  43196. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43197. import { Scene } from "babylonjs/scene";
  43198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43199. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43200. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43201. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43202. import { Observable } from "babylonjs/Misc/observable";
  43203. /**
  43204. * Vive Controller
  43205. */
  43206. export class ViveController extends WebVRController {
  43207. /**
  43208. * Base Url for the controller model.
  43209. */
  43210. static MODEL_BASE_URL: string;
  43211. /**
  43212. * File name for the controller model.
  43213. */
  43214. static MODEL_FILENAME: string;
  43215. /**
  43216. * Creates a new ViveController from a gamepad
  43217. * @param vrGamepad the gamepad that the controller should be created from
  43218. */
  43219. constructor(vrGamepad: any);
  43220. /**
  43221. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43222. * @param scene scene in which to add meshes
  43223. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43224. */
  43225. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43226. /**
  43227. * Fired when the left button on this controller is modified
  43228. */
  43229. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43230. /**
  43231. * Fired when the right button on this controller is modified
  43232. */
  43233. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43234. /**
  43235. * Fired when the menu button on this controller is modified
  43236. */
  43237. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43238. /**
  43239. * Called once for each button that changed state since the last frame
  43240. * Vive mapping:
  43241. * 0: touchpad
  43242. * 1: trigger
  43243. * 2: left AND right buttons
  43244. * 3: menu button
  43245. * @param buttonIdx Which button index changed
  43246. * @param state New state of the button
  43247. * @param changes Which properties on the state changed since last frame
  43248. */
  43249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43250. }
  43251. }
  43252. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43253. import { Observable } from "babylonjs/Misc/observable";
  43254. import { Scene } from "babylonjs/scene";
  43255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43256. import { Ray } from "babylonjs/Culling/ray";
  43257. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43258. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43259. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43260. /**
  43261. * Defines the WindowsMotionController object that the state of the windows motion controller
  43262. */
  43263. export class WindowsMotionController extends WebVRController {
  43264. /**
  43265. * The base url used to load the left and right controller models
  43266. */
  43267. static MODEL_BASE_URL: string;
  43268. /**
  43269. * The name of the left controller model file
  43270. */
  43271. static MODEL_LEFT_FILENAME: string;
  43272. /**
  43273. * The name of the right controller model file
  43274. */
  43275. static MODEL_RIGHT_FILENAME: string;
  43276. /**
  43277. * The controller name prefix for this controller type
  43278. */
  43279. static readonly GAMEPAD_ID_PREFIX: string;
  43280. /**
  43281. * The controller id pattern for this controller type
  43282. */
  43283. private static readonly GAMEPAD_ID_PATTERN;
  43284. private _loadedMeshInfo;
  43285. private readonly _mapping;
  43286. /**
  43287. * Fired when the trackpad on this controller is clicked
  43288. */
  43289. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43290. /**
  43291. * Fired when the trackpad on this controller is modified
  43292. */
  43293. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43294. /**
  43295. * The current x and y values of this controller's trackpad
  43296. */
  43297. trackpad: StickValues;
  43298. /**
  43299. * Creates a new WindowsMotionController from a gamepad
  43300. * @param vrGamepad the gamepad that the controller should be created from
  43301. */
  43302. constructor(vrGamepad: any);
  43303. /**
  43304. * Fired when the trigger on this controller is modified
  43305. */
  43306. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43307. /**
  43308. * Fired when the menu button on this controller is modified
  43309. */
  43310. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43311. /**
  43312. * Fired when the grip button on this controller is modified
  43313. */
  43314. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43315. /**
  43316. * Fired when the thumbstick button on this controller is modified
  43317. */
  43318. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43319. /**
  43320. * Fired when the touchpad button on this controller is modified
  43321. */
  43322. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43323. /**
  43324. * Fired when the touchpad values on this controller are modified
  43325. */
  43326. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43327. private _updateTrackpad;
  43328. /**
  43329. * Called once per frame by the engine.
  43330. */
  43331. update(): void;
  43332. /**
  43333. * Called once for each button that changed state since the last frame
  43334. * @param buttonIdx Which button index changed
  43335. * @param state New state of the button
  43336. * @param changes Which properties on the state changed since last frame
  43337. */
  43338. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43339. /**
  43340. * Moves the buttons on the controller mesh based on their current state
  43341. * @param buttonName the name of the button to move
  43342. * @param buttonValue the value of the button which determines the buttons new position
  43343. */
  43344. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43345. /**
  43346. * Moves the axis on the controller mesh based on its current state
  43347. * @param axis the index of the axis
  43348. * @param axisValue the value of the axis which determines the meshes new position
  43349. * @hidden
  43350. */
  43351. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43352. /**
  43353. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43354. * @param scene scene in which to add meshes
  43355. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43356. */
  43357. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43358. /**
  43359. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43360. * can be transformed by button presses and axes values, based on this._mapping.
  43361. *
  43362. * @param scene scene in which the meshes exist
  43363. * @param meshes list of meshes that make up the controller model to process
  43364. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43365. */
  43366. private processModel;
  43367. private createMeshInfo;
  43368. /**
  43369. * Gets the ray of the controller in the direction the controller is pointing
  43370. * @param length the length the resulting ray should be
  43371. * @returns a ray in the direction the controller is pointing
  43372. */
  43373. getForwardRay(length?: number): Ray;
  43374. /**
  43375. * Disposes of the controller
  43376. */
  43377. dispose(): void;
  43378. }
  43379. }
  43380. declare module "babylonjs/Gamepads/Controllers/index" {
  43381. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43382. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43383. export * from "babylonjs/Gamepads/Controllers/genericController";
  43384. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43385. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43386. export * from "babylonjs/Gamepads/Controllers/viveController";
  43387. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43388. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43389. }
  43390. declare module "babylonjs/Gamepads/index" {
  43391. export * from "babylonjs/Gamepads/Controllers/index";
  43392. export * from "babylonjs/Gamepads/gamepad";
  43393. export * from "babylonjs/Gamepads/gamepadManager";
  43394. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43395. export * from "babylonjs/Gamepads/xboxGamepad";
  43396. }
  43397. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43398. import { Observable } from "babylonjs/Misc/observable";
  43399. import { Nullable } from "babylonjs/types";
  43400. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43402. import { Mesh } from "babylonjs/Meshes/mesh";
  43403. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43404. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43405. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43406. /**
  43407. * Single axis scale gizmo
  43408. */
  43409. export class AxisScaleGizmo extends Gizmo {
  43410. private _coloredMaterial;
  43411. /**
  43412. * Drag behavior responsible for the gizmos dragging interactions
  43413. */
  43414. dragBehavior: PointerDragBehavior;
  43415. private _pointerObserver;
  43416. /**
  43417. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43418. */
  43419. snapDistance: number;
  43420. /**
  43421. * Event that fires each time the gizmo snaps to a new location.
  43422. * * snapDistance is the the change in distance
  43423. */
  43424. onSnapObservable: Observable<{
  43425. snapDistance: number;
  43426. }>;
  43427. /**
  43428. * If the scaling operation should be done on all axis (default: false)
  43429. */
  43430. uniformScaling: boolean;
  43431. /**
  43432. * Creates an AxisScaleGizmo
  43433. * @param gizmoLayer The utility layer the gizmo will be added to
  43434. * @param dragAxis The axis which the gizmo will be able to scale on
  43435. * @param color The color of the gizmo
  43436. */
  43437. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43438. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43439. /**
  43440. * Disposes of the gizmo
  43441. */
  43442. dispose(): void;
  43443. /**
  43444. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43445. * @param mesh The mesh to replace the default mesh of the gizmo
  43446. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43447. */
  43448. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43449. }
  43450. }
  43451. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43452. import { Observable } from "babylonjs/Misc/observable";
  43453. import { Nullable } from "babylonjs/types";
  43454. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43456. import { Mesh } from "babylonjs/Meshes/mesh";
  43457. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43458. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43459. import "babylonjs/Meshes/Builders/boxBuilder";
  43460. /**
  43461. * Bounding box gizmo
  43462. */
  43463. export class BoundingBoxGizmo extends Gizmo {
  43464. private _lineBoundingBox;
  43465. private _rotateSpheresParent;
  43466. private _scaleBoxesParent;
  43467. private _boundingDimensions;
  43468. private _renderObserver;
  43469. private _pointerObserver;
  43470. private _scaleDragSpeed;
  43471. private _tmpQuaternion;
  43472. private _tmpVector;
  43473. private _tmpRotationMatrix;
  43474. /**
  43475. * 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)
  43476. */
  43477. ignoreChildren: boolean;
  43478. /**
  43479. * 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)
  43480. */
  43481. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43482. /**
  43483. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43484. */
  43485. rotationSphereSize: number;
  43486. /**
  43487. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43488. */
  43489. scaleBoxSize: number;
  43490. /**
  43491. * 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)
  43492. */
  43493. fixedDragMeshScreenSize: boolean;
  43494. /**
  43495. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43496. */
  43497. fixedDragMeshScreenSizeDistanceFactor: number;
  43498. /**
  43499. * Fired when a rotation sphere or scale box is dragged
  43500. */
  43501. onDragStartObservable: Observable<{}>;
  43502. /**
  43503. * Fired when a scale box is dragged
  43504. */
  43505. onScaleBoxDragObservable: Observable<{}>;
  43506. /**
  43507. * Fired when a scale box drag is ended
  43508. */
  43509. onScaleBoxDragEndObservable: Observable<{}>;
  43510. /**
  43511. * Fired when a rotation sphere is dragged
  43512. */
  43513. onRotationSphereDragObservable: Observable<{}>;
  43514. /**
  43515. * Fired when a rotation sphere drag is ended
  43516. */
  43517. onRotationSphereDragEndObservable: Observable<{}>;
  43518. /**
  43519. * 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)
  43520. */
  43521. scalePivot: Nullable<Vector3>;
  43522. private _anchorMesh;
  43523. private _existingMeshScale;
  43524. private _dragMesh;
  43525. private pointerDragBehavior;
  43526. private coloredMaterial;
  43527. private hoverColoredMaterial;
  43528. /**
  43529. * Sets the color of the bounding box gizmo
  43530. * @param color the color to set
  43531. */
  43532. setColor(color: Color3): void;
  43533. /**
  43534. * Creates an BoundingBoxGizmo
  43535. * @param gizmoLayer The utility layer the gizmo will be added to
  43536. * @param color The color of the gizmo
  43537. */
  43538. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43539. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43540. private _selectNode;
  43541. /**
  43542. * Updates the bounding box information for the Gizmo
  43543. */
  43544. updateBoundingBox(): void;
  43545. private _updateRotationSpheres;
  43546. private _updateScaleBoxes;
  43547. /**
  43548. * Enables rotation on the specified axis and disables rotation on the others
  43549. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43550. */
  43551. setEnabledRotationAxis(axis: string): void;
  43552. /**
  43553. * Enables/disables scaling
  43554. * @param enable if scaling should be enabled
  43555. */
  43556. setEnabledScaling(enable: boolean): void;
  43557. private _updateDummy;
  43558. /**
  43559. * Enables a pointer drag behavior on the bounding box of the gizmo
  43560. */
  43561. enableDragBehavior(): void;
  43562. /**
  43563. * Disposes of the gizmo
  43564. */
  43565. dispose(): void;
  43566. /**
  43567. * 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)
  43568. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43569. * @returns the bounding box mesh with the passed in mesh as a child
  43570. */
  43571. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43572. /**
  43573. * CustomMeshes are not supported by this gizmo
  43574. * @param mesh The mesh to replace the default mesh of the gizmo
  43575. */
  43576. setCustomMesh(mesh: Mesh): void;
  43577. }
  43578. }
  43579. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43580. import { Observable } from "babylonjs/Misc/observable";
  43581. import { Nullable } from "babylonjs/types";
  43582. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43584. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43585. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43586. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43587. import "babylonjs/Meshes/Builders/linesBuilder";
  43588. /**
  43589. * Single plane rotation gizmo
  43590. */
  43591. export class PlaneRotationGizmo extends Gizmo {
  43592. /**
  43593. * Drag behavior responsible for the gizmos dragging interactions
  43594. */
  43595. dragBehavior: PointerDragBehavior;
  43596. private _pointerObserver;
  43597. /**
  43598. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43599. */
  43600. snapDistance: number;
  43601. /**
  43602. * Event that fires each time the gizmo snaps to a new location.
  43603. * * snapDistance is the the change in distance
  43604. */
  43605. onSnapObservable: Observable<{
  43606. snapDistance: number;
  43607. }>;
  43608. /**
  43609. * Creates a PlaneRotationGizmo
  43610. * @param gizmoLayer The utility layer the gizmo will be added to
  43611. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43612. * @param color The color of the gizmo
  43613. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43614. */
  43615. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43616. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43617. /**
  43618. * Disposes of the gizmo
  43619. */
  43620. dispose(): void;
  43621. }
  43622. }
  43623. declare module "babylonjs/Gizmos/rotationGizmo" {
  43624. import { Observable } from "babylonjs/Misc/observable";
  43625. import { Nullable } from "babylonjs/types";
  43626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43627. import { Mesh } from "babylonjs/Meshes/mesh";
  43628. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43629. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43630. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43631. /**
  43632. * Gizmo that enables rotating a mesh along 3 axis
  43633. */
  43634. export class RotationGizmo extends Gizmo {
  43635. /**
  43636. * Internal gizmo used for interactions on the x axis
  43637. */
  43638. xGizmo: PlaneRotationGizmo;
  43639. /**
  43640. * Internal gizmo used for interactions on the y axis
  43641. */
  43642. yGizmo: PlaneRotationGizmo;
  43643. /**
  43644. * Internal gizmo used for interactions on the z axis
  43645. */
  43646. zGizmo: PlaneRotationGizmo;
  43647. /** Fires an event when any of it's sub gizmos are dragged */
  43648. onDragStartObservable: Observable<{}>;
  43649. /** Fires an event when any of it's sub gizmos are released from dragging */
  43650. onDragEndObservable: Observable<{}>;
  43651. attachedMesh: Nullable<AbstractMesh>;
  43652. /**
  43653. * Creates a RotationGizmo
  43654. * @param gizmoLayer The utility layer the gizmo will be added to
  43655. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43656. */
  43657. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43658. updateGizmoRotationToMatchAttachedMesh: boolean;
  43659. /**
  43660. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43661. */
  43662. snapDistance: number;
  43663. /**
  43664. * Ratio for the scale of the gizmo (Default: 1)
  43665. */
  43666. scaleRatio: number;
  43667. /**
  43668. * Disposes of the gizmo
  43669. */
  43670. dispose(): void;
  43671. /**
  43672. * CustomMeshes are not supported by this gizmo
  43673. * @param mesh The mesh to replace the default mesh of the gizmo
  43674. */
  43675. setCustomMesh(mesh: Mesh): void;
  43676. }
  43677. }
  43678. declare module "babylonjs/Gizmos/positionGizmo" {
  43679. import { Observable } from "babylonjs/Misc/observable";
  43680. import { Nullable } from "babylonjs/types";
  43681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43682. import { Mesh } from "babylonjs/Meshes/mesh";
  43683. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43684. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43685. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43686. /**
  43687. * Gizmo that enables dragging a mesh along 3 axis
  43688. */
  43689. export class PositionGizmo extends Gizmo {
  43690. /**
  43691. * Internal gizmo used for interactions on the x axis
  43692. */
  43693. xGizmo: AxisDragGizmo;
  43694. /**
  43695. * Internal gizmo used for interactions on the y axis
  43696. */
  43697. yGizmo: AxisDragGizmo;
  43698. /**
  43699. * Internal gizmo used for interactions on the z axis
  43700. */
  43701. zGizmo: AxisDragGizmo;
  43702. /** Fires an event when any of it's sub gizmos are dragged */
  43703. onDragStartObservable: Observable<{}>;
  43704. /** Fires an event when any of it's sub gizmos are released from dragging */
  43705. onDragEndObservable: Observable<{}>;
  43706. attachedMesh: Nullable<AbstractMesh>;
  43707. /**
  43708. * Creates a PositionGizmo
  43709. * @param gizmoLayer The utility layer the gizmo will be added to
  43710. */
  43711. constructor(gizmoLayer?: UtilityLayerRenderer);
  43712. updateGizmoRotationToMatchAttachedMesh: boolean;
  43713. /**
  43714. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43715. */
  43716. snapDistance: number;
  43717. /**
  43718. * Ratio for the scale of the gizmo (Default: 1)
  43719. */
  43720. scaleRatio: number;
  43721. /**
  43722. * Disposes of the gizmo
  43723. */
  43724. dispose(): void;
  43725. /**
  43726. * CustomMeshes are not supported by this gizmo
  43727. * @param mesh The mesh to replace the default mesh of the gizmo
  43728. */
  43729. setCustomMesh(mesh: Mesh): void;
  43730. }
  43731. }
  43732. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43733. import { Scene } from "babylonjs/scene";
  43734. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43735. import { Mesh } from "babylonjs/Meshes/mesh";
  43736. /**
  43737. * Class containing static functions to help procedurally build meshes
  43738. */
  43739. export class PolyhedronBuilder {
  43740. /**
  43741. * Creates a polyhedron mesh
  43742. * * 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
  43743. * * The parameter `size` (positive float, default 1) sets the polygon size
  43744. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43745. * * 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`
  43746. * * 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
  43747. * * 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)`)
  43748. * * 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
  43749. * * 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
  43750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43753. * @param name defines the name of the mesh
  43754. * @param options defines the options used to create the mesh
  43755. * @param scene defines the hosting scene
  43756. * @returns the polyhedron mesh
  43757. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43758. */
  43759. static CreatePolyhedron(name: string, options: {
  43760. type?: number;
  43761. size?: number;
  43762. sizeX?: number;
  43763. sizeY?: number;
  43764. sizeZ?: number;
  43765. custom?: any;
  43766. faceUV?: Vector4[];
  43767. faceColors?: Color4[];
  43768. flat?: boolean;
  43769. updatable?: boolean;
  43770. sideOrientation?: number;
  43771. frontUVs?: Vector4;
  43772. backUVs?: Vector4;
  43773. }, scene: Scene): Mesh;
  43774. }
  43775. }
  43776. declare module "babylonjs/Gizmos/scaleGizmo" {
  43777. import { Observable } from "babylonjs/Misc/observable";
  43778. import { Nullable } from "babylonjs/types";
  43779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43780. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43781. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43782. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43783. /**
  43784. * Gizmo that enables scaling a mesh along 3 axis
  43785. */
  43786. export class ScaleGizmo extends Gizmo {
  43787. /**
  43788. * Internal gizmo used for interactions on the x axis
  43789. */
  43790. xGizmo: AxisScaleGizmo;
  43791. /**
  43792. * Internal gizmo used for interactions on the y axis
  43793. */
  43794. yGizmo: AxisScaleGizmo;
  43795. /**
  43796. * Internal gizmo used for interactions on the z axis
  43797. */
  43798. zGizmo: AxisScaleGizmo;
  43799. /**
  43800. * Internal gizmo used to scale all axis equally
  43801. */
  43802. uniformScaleGizmo: AxisScaleGizmo;
  43803. /** Fires an event when any of it's sub gizmos are dragged */
  43804. onDragStartObservable: Observable<{}>;
  43805. /** Fires an event when any of it's sub gizmos are released from dragging */
  43806. onDragEndObservable: Observable<{}>;
  43807. attachedMesh: Nullable<AbstractMesh>;
  43808. /**
  43809. * Creates a ScaleGizmo
  43810. * @param gizmoLayer The utility layer the gizmo will be added to
  43811. */
  43812. constructor(gizmoLayer?: UtilityLayerRenderer);
  43813. updateGizmoRotationToMatchAttachedMesh: boolean;
  43814. /**
  43815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43816. */
  43817. snapDistance: number;
  43818. /**
  43819. * Ratio for the scale of the gizmo (Default: 1)
  43820. */
  43821. scaleRatio: number;
  43822. /**
  43823. * Disposes of the gizmo
  43824. */
  43825. dispose(): void;
  43826. }
  43827. }
  43828. declare module "babylonjs/Gizmos/gizmoManager" {
  43829. import { Observable } from "babylonjs/Misc/observable";
  43830. import { Nullable } from "babylonjs/types";
  43831. import { Scene, IDisposable } from "babylonjs/scene";
  43832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43833. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43834. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43835. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43836. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43837. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43838. /**
  43839. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43840. */
  43841. export class GizmoManager implements IDisposable {
  43842. private scene;
  43843. /**
  43844. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43845. */
  43846. gizmos: {
  43847. positionGizmo: Nullable<PositionGizmo>;
  43848. rotationGizmo: Nullable<RotationGizmo>;
  43849. scaleGizmo: Nullable<ScaleGizmo>;
  43850. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43851. };
  43852. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43853. clearGizmoOnEmptyPointerEvent: boolean;
  43854. /** Fires an event when the manager is attached to a mesh */
  43855. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43856. private _gizmosEnabled;
  43857. private _pointerObserver;
  43858. private _attachedMesh;
  43859. private _boundingBoxColor;
  43860. private _defaultUtilityLayer;
  43861. private _defaultKeepDepthUtilityLayer;
  43862. /**
  43863. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43864. */
  43865. boundingBoxDragBehavior: SixDofDragBehavior;
  43866. /**
  43867. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43868. */
  43869. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43870. /**
  43871. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43872. */
  43873. usePointerToAttachGizmos: boolean;
  43874. /**
  43875. * Instatiates a gizmo manager
  43876. * @param scene the scene to overlay the gizmos on top of
  43877. */
  43878. constructor(scene: Scene);
  43879. /**
  43880. * Attaches a set of gizmos to the specified mesh
  43881. * @param mesh The mesh the gizmo's should be attached to
  43882. */
  43883. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43884. /**
  43885. * If the position gizmo is enabled
  43886. */
  43887. positionGizmoEnabled: boolean;
  43888. /**
  43889. * If the rotation gizmo is enabled
  43890. */
  43891. rotationGizmoEnabled: boolean;
  43892. /**
  43893. * If the scale gizmo is enabled
  43894. */
  43895. scaleGizmoEnabled: boolean;
  43896. /**
  43897. * If the boundingBox gizmo is enabled
  43898. */
  43899. boundingBoxGizmoEnabled: boolean;
  43900. /**
  43901. * Disposes of the gizmo manager
  43902. */
  43903. dispose(): void;
  43904. }
  43905. }
  43906. declare module "babylonjs/Gizmos/lightGizmo" {
  43907. import { Nullable } from "babylonjs/types";
  43908. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43909. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43910. import { Light } from "babylonjs/Lights/light";
  43911. /**
  43912. * Gizmo that enables viewing a light
  43913. */
  43914. export class LightGizmo extends Gizmo {
  43915. private _box;
  43916. /**
  43917. * Creates a LightGizmo
  43918. * @param gizmoLayer The utility layer the gizmo will be added to
  43919. */
  43920. constructor(gizmoLayer?: UtilityLayerRenderer);
  43921. private _light;
  43922. /**
  43923. * The light that the gizmo is attached to
  43924. */
  43925. light: Nullable<Light>;
  43926. /**
  43927. * @hidden
  43928. * Updates the gizmo to match the attached mesh's position/rotation
  43929. */
  43930. protected _update(): void;
  43931. }
  43932. }
  43933. declare module "babylonjs/Gizmos/index" {
  43934. export * from "babylonjs/Gizmos/axisDragGizmo";
  43935. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43936. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43937. export * from "babylonjs/Gizmos/gizmo";
  43938. export * from "babylonjs/Gizmos/gizmoManager";
  43939. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43940. export * from "babylonjs/Gizmos/positionGizmo";
  43941. export * from "babylonjs/Gizmos/rotationGizmo";
  43942. export * from "babylonjs/Gizmos/scaleGizmo";
  43943. export * from "babylonjs/Gizmos/lightGizmo";
  43944. }
  43945. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43946. /** @hidden */
  43947. export var backgroundFragmentDeclaration: {
  43948. name: string;
  43949. shader: string;
  43950. };
  43951. }
  43952. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43953. /** @hidden */
  43954. export var backgroundUboDeclaration: {
  43955. name: string;
  43956. shader: string;
  43957. };
  43958. }
  43959. declare module "babylonjs/Shaders/background.fragment" {
  43960. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43961. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43962. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43963. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43964. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43965. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43966. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43967. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43968. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43969. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43970. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43971. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43972. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43973. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43974. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43975. /** @hidden */
  43976. export var backgroundPixelShader: {
  43977. name: string;
  43978. shader: string;
  43979. };
  43980. }
  43981. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43982. /** @hidden */
  43983. export var backgroundVertexDeclaration: {
  43984. name: string;
  43985. shader: string;
  43986. };
  43987. }
  43988. declare module "babylonjs/Shaders/background.vertex" {
  43989. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43990. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43991. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43992. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43993. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43994. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43995. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43996. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43997. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43998. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43999. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44000. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44001. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44002. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44003. /** @hidden */
  44004. export var backgroundVertexShader: {
  44005. name: string;
  44006. shader: string;
  44007. };
  44008. }
  44009. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44010. import { Nullable, int, float } from "babylonjs/types";
  44011. import { Scene } from "babylonjs/scene";
  44012. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44013. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44015. import { Mesh } from "babylonjs/Meshes/mesh";
  44016. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44017. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44018. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44020. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44021. import "babylonjs/Shaders/background.fragment";
  44022. import "babylonjs/Shaders/background.vertex";
  44023. /**
  44024. * Background material used to create an efficient environement around your scene.
  44025. */
  44026. export class BackgroundMaterial extends PushMaterial {
  44027. /**
  44028. * Standard reflectance value at parallel view angle.
  44029. */
  44030. static StandardReflectance0: number;
  44031. /**
  44032. * Standard reflectance value at grazing angle.
  44033. */
  44034. static StandardReflectance90: number;
  44035. protected _primaryColor: Color3;
  44036. /**
  44037. * Key light Color (multiply against the environement texture)
  44038. */
  44039. primaryColor: Color3;
  44040. protected __perceptualColor: Nullable<Color3>;
  44041. /**
  44042. * Experimental Internal Use Only.
  44043. *
  44044. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44045. * This acts as a helper to set the primary color to a more "human friendly" value.
  44046. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44047. * output color as close as possible from the chosen value.
  44048. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44049. * part of lighting setup.)
  44050. */
  44051. _perceptualColor: Nullable<Color3>;
  44052. protected _primaryColorShadowLevel: float;
  44053. /**
  44054. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44055. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44056. */
  44057. primaryColorShadowLevel: float;
  44058. protected _primaryColorHighlightLevel: float;
  44059. /**
  44060. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44061. * The primary color is used at the level chosen to define what the white area would look.
  44062. */
  44063. primaryColorHighlightLevel: float;
  44064. protected _reflectionTexture: Nullable<BaseTexture>;
  44065. /**
  44066. * Reflection Texture used in the material.
  44067. * Should be author in a specific way for the best result (refer to the documentation).
  44068. */
  44069. reflectionTexture: Nullable<BaseTexture>;
  44070. protected _reflectionBlur: float;
  44071. /**
  44072. * Reflection Texture level of blur.
  44073. *
  44074. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44075. * texture twice.
  44076. */
  44077. reflectionBlur: float;
  44078. protected _diffuseTexture: Nullable<BaseTexture>;
  44079. /**
  44080. * Diffuse Texture used in the material.
  44081. * Should be author in a specific way for the best result (refer to the documentation).
  44082. */
  44083. diffuseTexture: Nullable<BaseTexture>;
  44084. protected _shadowLights: Nullable<IShadowLight[]>;
  44085. /**
  44086. * Specify the list of lights casting shadow on the material.
  44087. * All scene shadow lights will be included if null.
  44088. */
  44089. shadowLights: Nullable<IShadowLight[]>;
  44090. protected _shadowLevel: float;
  44091. /**
  44092. * Helps adjusting the shadow to a softer level if required.
  44093. * 0 means black shadows and 1 means no shadows.
  44094. */
  44095. shadowLevel: float;
  44096. protected _sceneCenter: Vector3;
  44097. /**
  44098. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44099. * It is usually zero but might be interesting to modify according to your setup.
  44100. */
  44101. sceneCenter: Vector3;
  44102. protected _opacityFresnel: boolean;
  44103. /**
  44104. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44105. * This helps ensuring a nice transition when the camera goes under the ground.
  44106. */
  44107. opacityFresnel: boolean;
  44108. protected _reflectionFresnel: boolean;
  44109. /**
  44110. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44111. * This helps adding a mirror texture on the ground.
  44112. */
  44113. reflectionFresnel: boolean;
  44114. protected _reflectionFalloffDistance: number;
  44115. /**
  44116. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44117. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44118. */
  44119. reflectionFalloffDistance: number;
  44120. protected _reflectionAmount: number;
  44121. /**
  44122. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44123. */
  44124. reflectionAmount: number;
  44125. protected _reflectionReflectance0: number;
  44126. /**
  44127. * This specifies the weight of the reflection at grazing angle.
  44128. */
  44129. reflectionReflectance0: number;
  44130. protected _reflectionReflectance90: number;
  44131. /**
  44132. * This specifies the weight of the reflection at a perpendicular point of view.
  44133. */
  44134. reflectionReflectance90: number;
  44135. /**
  44136. * Sets the reflection reflectance fresnel values according to the default standard
  44137. * empirically know to work well :-)
  44138. */
  44139. reflectionStandardFresnelWeight: number;
  44140. protected _useRGBColor: boolean;
  44141. /**
  44142. * Helps to directly use the maps channels instead of their level.
  44143. */
  44144. useRGBColor: boolean;
  44145. protected _enableNoise: boolean;
  44146. /**
  44147. * This helps reducing the banding effect that could occur on the background.
  44148. */
  44149. enableNoise: boolean;
  44150. /**
  44151. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44152. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44153. * Recommended to be keep at 1.0 except for special cases.
  44154. */
  44155. fovMultiplier: number;
  44156. private _fovMultiplier;
  44157. /**
  44158. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44159. */
  44160. useEquirectangularFOV: boolean;
  44161. private _maxSimultaneousLights;
  44162. /**
  44163. * Number of Simultaneous lights allowed on the material.
  44164. */
  44165. maxSimultaneousLights: int;
  44166. /**
  44167. * Default configuration related to image processing available in the Background Material.
  44168. */
  44169. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44170. /**
  44171. * Keep track of the image processing observer to allow dispose and replace.
  44172. */
  44173. private _imageProcessingObserver;
  44174. /**
  44175. * Attaches a new image processing configuration to the PBR Material.
  44176. * @param configuration (if null the scene configuration will be use)
  44177. */
  44178. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44179. /**
  44180. * Gets the image processing configuration used either in this material.
  44181. */
  44182. /**
  44183. * Sets the Default image processing configuration used either in the this material.
  44184. *
  44185. * If sets to null, the scene one is in use.
  44186. */
  44187. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44188. /**
  44189. * Gets wether the color curves effect is enabled.
  44190. */
  44191. /**
  44192. * Sets wether the color curves effect is enabled.
  44193. */
  44194. cameraColorCurvesEnabled: boolean;
  44195. /**
  44196. * Gets wether the color grading effect is enabled.
  44197. */
  44198. /**
  44199. * Gets wether the color grading effect is enabled.
  44200. */
  44201. cameraColorGradingEnabled: boolean;
  44202. /**
  44203. * Gets wether tonemapping is enabled or not.
  44204. */
  44205. /**
  44206. * Sets wether tonemapping is enabled or not
  44207. */
  44208. cameraToneMappingEnabled: boolean;
  44209. /**
  44210. * The camera exposure used on this material.
  44211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44212. * This corresponds to a photographic exposure.
  44213. */
  44214. /**
  44215. * The camera exposure used on this material.
  44216. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44217. * This corresponds to a photographic exposure.
  44218. */
  44219. cameraExposure: float;
  44220. /**
  44221. * Gets The camera contrast used on this material.
  44222. */
  44223. /**
  44224. * Sets The camera contrast used on this material.
  44225. */
  44226. cameraContrast: float;
  44227. /**
  44228. * Gets the Color Grading 2D Lookup Texture.
  44229. */
  44230. /**
  44231. * Sets the Color Grading 2D Lookup Texture.
  44232. */
  44233. cameraColorGradingTexture: Nullable<BaseTexture>;
  44234. /**
  44235. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44236. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44237. * 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;
  44238. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44239. */
  44240. /**
  44241. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44242. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44243. * 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;
  44244. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44245. */
  44246. cameraColorCurves: Nullable<ColorCurves>;
  44247. /**
  44248. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44249. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44250. */
  44251. switchToBGR: boolean;
  44252. private _renderTargets;
  44253. private _reflectionControls;
  44254. private _white;
  44255. private _primaryShadowColor;
  44256. private _primaryHighlightColor;
  44257. /**
  44258. * Instantiates a Background Material in the given scene
  44259. * @param name The friendly name of the material
  44260. * @param scene The scene to add the material to
  44261. */
  44262. constructor(name: string, scene: Scene);
  44263. /**
  44264. * Gets a boolean indicating that current material needs to register RTT
  44265. */
  44266. readonly hasRenderTargetTextures: boolean;
  44267. /**
  44268. * The entire material has been created in order to prevent overdraw.
  44269. * @returns false
  44270. */
  44271. needAlphaTesting(): boolean;
  44272. /**
  44273. * The entire material has been created in order to prevent overdraw.
  44274. * @returns true if blending is enable
  44275. */
  44276. needAlphaBlending(): boolean;
  44277. /**
  44278. * Checks wether the material is ready to be rendered for a given mesh.
  44279. * @param mesh The mesh to render
  44280. * @param subMesh The submesh to check against
  44281. * @param useInstances Specify wether or not the material is used with instances
  44282. * @returns true if all the dependencies are ready (Textures, Effects...)
  44283. */
  44284. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44285. /**
  44286. * Compute the primary color according to the chosen perceptual color.
  44287. */
  44288. private _computePrimaryColorFromPerceptualColor;
  44289. /**
  44290. * Compute the highlights and shadow colors according to their chosen levels.
  44291. */
  44292. private _computePrimaryColors;
  44293. /**
  44294. * Build the uniform buffer used in the material.
  44295. */
  44296. buildUniformLayout(): void;
  44297. /**
  44298. * Unbind the material.
  44299. */
  44300. unbind(): void;
  44301. /**
  44302. * Bind only the world matrix to the material.
  44303. * @param world The world matrix to bind.
  44304. */
  44305. bindOnlyWorldMatrix(world: Matrix): void;
  44306. /**
  44307. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44308. * @param world The world matrix to bind.
  44309. * @param subMesh The submesh to bind for.
  44310. */
  44311. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44312. /**
  44313. * Dispose the material.
  44314. * @param forceDisposeEffect Force disposal of the associated effect.
  44315. * @param forceDisposeTextures Force disposal of the associated textures.
  44316. */
  44317. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44318. /**
  44319. * Clones the material.
  44320. * @param name The cloned name.
  44321. * @returns The cloned material.
  44322. */
  44323. clone(name: string): BackgroundMaterial;
  44324. /**
  44325. * Serializes the current material to its JSON representation.
  44326. * @returns The JSON representation.
  44327. */
  44328. serialize(): any;
  44329. /**
  44330. * Gets the class name of the material
  44331. * @returns "BackgroundMaterial"
  44332. */
  44333. getClassName(): string;
  44334. /**
  44335. * Parse a JSON input to create back a background material.
  44336. * @param source The JSON data to parse
  44337. * @param scene The scene to create the parsed material in
  44338. * @param rootUrl The root url of the assets the material depends upon
  44339. * @returns the instantiated BackgroundMaterial.
  44340. */
  44341. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44342. }
  44343. }
  44344. declare module "babylonjs/Helpers/environmentHelper" {
  44345. import { Observable } from "babylonjs/Misc/observable";
  44346. import { Nullable } from "babylonjs/types";
  44347. import { Scene } from "babylonjs/scene";
  44348. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44350. import { Mesh } from "babylonjs/Meshes/mesh";
  44351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44352. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44353. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44354. import "babylonjs/Meshes/Builders/planeBuilder";
  44355. import "babylonjs/Meshes/Builders/boxBuilder";
  44356. /**
  44357. * Represents the different options available during the creation of
  44358. * a Environment helper.
  44359. *
  44360. * This can control the default ground, skybox and image processing setup of your scene.
  44361. */
  44362. export interface IEnvironmentHelperOptions {
  44363. /**
  44364. * Specifies wether or not to create a ground.
  44365. * True by default.
  44366. */
  44367. createGround: boolean;
  44368. /**
  44369. * Specifies the ground size.
  44370. * 15 by default.
  44371. */
  44372. groundSize: number;
  44373. /**
  44374. * The texture used on the ground for the main color.
  44375. * Comes from the BabylonJS CDN by default.
  44376. *
  44377. * Remarks: Can be either a texture or a url.
  44378. */
  44379. groundTexture: string | BaseTexture;
  44380. /**
  44381. * The color mixed in the ground texture by default.
  44382. * BabylonJS clearColor by default.
  44383. */
  44384. groundColor: Color3;
  44385. /**
  44386. * Specifies the ground opacity.
  44387. * 1 by default.
  44388. */
  44389. groundOpacity: number;
  44390. /**
  44391. * Enables the ground to receive shadows.
  44392. * True by default.
  44393. */
  44394. enableGroundShadow: boolean;
  44395. /**
  44396. * Helps preventing the shadow to be fully black on the ground.
  44397. * 0.5 by default.
  44398. */
  44399. groundShadowLevel: number;
  44400. /**
  44401. * Creates a mirror texture attach to the ground.
  44402. * false by default.
  44403. */
  44404. enableGroundMirror: boolean;
  44405. /**
  44406. * Specifies the ground mirror size ratio.
  44407. * 0.3 by default as the default kernel is 64.
  44408. */
  44409. groundMirrorSizeRatio: number;
  44410. /**
  44411. * Specifies the ground mirror blur kernel size.
  44412. * 64 by default.
  44413. */
  44414. groundMirrorBlurKernel: number;
  44415. /**
  44416. * Specifies the ground mirror visibility amount.
  44417. * 1 by default
  44418. */
  44419. groundMirrorAmount: number;
  44420. /**
  44421. * Specifies the ground mirror reflectance weight.
  44422. * This uses the standard weight of the background material to setup the fresnel effect
  44423. * of the mirror.
  44424. * 1 by default.
  44425. */
  44426. groundMirrorFresnelWeight: number;
  44427. /**
  44428. * Specifies the ground mirror Falloff distance.
  44429. * This can helps reducing the size of the reflection.
  44430. * 0 by Default.
  44431. */
  44432. groundMirrorFallOffDistance: number;
  44433. /**
  44434. * Specifies the ground mirror texture type.
  44435. * Unsigned Int by Default.
  44436. */
  44437. groundMirrorTextureType: number;
  44438. /**
  44439. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44440. * the shown objects.
  44441. */
  44442. groundYBias: number;
  44443. /**
  44444. * Specifies wether or not to create a skybox.
  44445. * True by default.
  44446. */
  44447. createSkybox: boolean;
  44448. /**
  44449. * Specifies the skybox size.
  44450. * 20 by default.
  44451. */
  44452. skyboxSize: number;
  44453. /**
  44454. * The texture used on the skybox for the main color.
  44455. * Comes from the BabylonJS CDN by default.
  44456. *
  44457. * Remarks: Can be either a texture or a url.
  44458. */
  44459. skyboxTexture: string | BaseTexture;
  44460. /**
  44461. * The color mixed in the skybox texture by default.
  44462. * BabylonJS clearColor by default.
  44463. */
  44464. skyboxColor: Color3;
  44465. /**
  44466. * The background rotation around the Y axis of the scene.
  44467. * This helps aligning the key lights of your scene with the background.
  44468. * 0 by default.
  44469. */
  44470. backgroundYRotation: number;
  44471. /**
  44472. * Compute automatically the size of the elements to best fit with the scene.
  44473. */
  44474. sizeAuto: boolean;
  44475. /**
  44476. * Default position of the rootMesh if autoSize is not true.
  44477. */
  44478. rootPosition: Vector3;
  44479. /**
  44480. * Sets up the image processing in the scene.
  44481. * true by default.
  44482. */
  44483. setupImageProcessing: boolean;
  44484. /**
  44485. * The texture used as your environment texture in the scene.
  44486. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44487. *
  44488. * Remarks: Can be either a texture or a url.
  44489. */
  44490. environmentTexture: string | BaseTexture;
  44491. /**
  44492. * The value of the exposure to apply to the scene.
  44493. * 0.6 by default if setupImageProcessing is true.
  44494. */
  44495. cameraExposure: number;
  44496. /**
  44497. * The value of the contrast to apply to the scene.
  44498. * 1.6 by default if setupImageProcessing is true.
  44499. */
  44500. cameraContrast: number;
  44501. /**
  44502. * Specifies wether or not tonemapping should be enabled in the scene.
  44503. * true by default if setupImageProcessing is true.
  44504. */
  44505. toneMappingEnabled: boolean;
  44506. }
  44507. /**
  44508. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44509. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44510. * It also helps with the default setup of your imageProcessing configuration.
  44511. */
  44512. export class EnvironmentHelper {
  44513. /**
  44514. * Default ground texture URL.
  44515. */
  44516. private static _groundTextureCDNUrl;
  44517. /**
  44518. * Default skybox texture URL.
  44519. */
  44520. private static _skyboxTextureCDNUrl;
  44521. /**
  44522. * Default environment texture URL.
  44523. */
  44524. private static _environmentTextureCDNUrl;
  44525. /**
  44526. * Creates the default options for the helper.
  44527. */
  44528. private static _getDefaultOptions;
  44529. private _rootMesh;
  44530. /**
  44531. * Gets the root mesh created by the helper.
  44532. */
  44533. readonly rootMesh: Mesh;
  44534. private _skybox;
  44535. /**
  44536. * Gets the skybox created by the helper.
  44537. */
  44538. readonly skybox: Nullable<Mesh>;
  44539. private _skyboxTexture;
  44540. /**
  44541. * Gets the skybox texture created by the helper.
  44542. */
  44543. readonly skyboxTexture: Nullable<BaseTexture>;
  44544. private _skyboxMaterial;
  44545. /**
  44546. * Gets the skybox material created by the helper.
  44547. */
  44548. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44549. private _ground;
  44550. /**
  44551. * Gets the ground mesh created by the helper.
  44552. */
  44553. readonly ground: Nullable<Mesh>;
  44554. private _groundTexture;
  44555. /**
  44556. * Gets the ground texture created by the helper.
  44557. */
  44558. readonly groundTexture: Nullable<BaseTexture>;
  44559. private _groundMirror;
  44560. /**
  44561. * Gets the ground mirror created by the helper.
  44562. */
  44563. readonly groundMirror: Nullable<MirrorTexture>;
  44564. /**
  44565. * Gets the ground mirror render list to helps pushing the meshes
  44566. * you wish in the ground reflection.
  44567. */
  44568. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44569. private _groundMaterial;
  44570. /**
  44571. * Gets the ground material created by the helper.
  44572. */
  44573. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44574. /**
  44575. * Stores the creation options.
  44576. */
  44577. private readonly _scene;
  44578. private _options;
  44579. /**
  44580. * This observable will be notified with any error during the creation of the environment,
  44581. * mainly texture creation errors.
  44582. */
  44583. onErrorObservable: Observable<{
  44584. message?: string;
  44585. exception?: any;
  44586. }>;
  44587. /**
  44588. * constructor
  44589. * @param options Defines the options we want to customize the helper
  44590. * @param scene The scene to add the material to
  44591. */
  44592. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44593. /**
  44594. * Updates the background according to the new options
  44595. * @param options
  44596. */
  44597. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44598. /**
  44599. * Sets the primary color of all the available elements.
  44600. * @param color the main color to affect to the ground and the background
  44601. */
  44602. setMainColor(color: Color3): void;
  44603. /**
  44604. * Setup the image processing according to the specified options.
  44605. */
  44606. private _setupImageProcessing;
  44607. /**
  44608. * Setup the environment texture according to the specified options.
  44609. */
  44610. private _setupEnvironmentTexture;
  44611. /**
  44612. * Setup the background according to the specified options.
  44613. */
  44614. private _setupBackground;
  44615. /**
  44616. * Get the scene sizes according to the setup.
  44617. */
  44618. private _getSceneSize;
  44619. /**
  44620. * Setup the ground according to the specified options.
  44621. */
  44622. private _setupGround;
  44623. /**
  44624. * Setup the ground material according to the specified options.
  44625. */
  44626. private _setupGroundMaterial;
  44627. /**
  44628. * Setup the ground diffuse texture according to the specified options.
  44629. */
  44630. private _setupGroundDiffuseTexture;
  44631. /**
  44632. * Setup the ground mirror texture according to the specified options.
  44633. */
  44634. private _setupGroundMirrorTexture;
  44635. /**
  44636. * Setup the ground to receive the mirror texture.
  44637. */
  44638. private _setupMirrorInGroundMaterial;
  44639. /**
  44640. * Setup the skybox according to the specified options.
  44641. */
  44642. private _setupSkybox;
  44643. /**
  44644. * Setup the skybox material according to the specified options.
  44645. */
  44646. private _setupSkyboxMaterial;
  44647. /**
  44648. * Setup the skybox reflection texture according to the specified options.
  44649. */
  44650. private _setupSkyboxReflectionTexture;
  44651. private _errorHandler;
  44652. /**
  44653. * Dispose all the elements created by the Helper.
  44654. */
  44655. dispose(): void;
  44656. }
  44657. }
  44658. declare module "babylonjs/Helpers/photoDome" {
  44659. import { Observable } from "babylonjs/Misc/observable";
  44660. import { Nullable } from "babylonjs/types";
  44661. import { Scene } from "babylonjs/scene";
  44662. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44663. import { Mesh } from "babylonjs/Meshes/mesh";
  44664. import { Texture } from "babylonjs/Materials/Textures/texture";
  44665. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44666. import "babylonjs/Meshes/Builders/sphereBuilder";
  44667. /**
  44668. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44669. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44670. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44671. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44672. */
  44673. export class PhotoDome extends TransformNode {
  44674. private _useDirectMapping;
  44675. /**
  44676. * The texture being displayed on the sphere
  44677. */
  44678. protected _photoTexture: Texture;
  44679. /**
  44680. * Gets or sets the texture being displayed on the sphere
  44681. */
  44682. photoTexture: Texture;
  44683. /**
  44684. * Observable raised when an error occured while loading the 360 image
  44685. */
  44686. onLoadErrorObservable: Observable<string>;
  44687. /**
  44688. * The skybox material
  44689. */
  44690. protected _material: BackgroundMaterial;
  44691. /**
  44692. * The surface used for the skybox
  44693. */
  44694. protected _mesh: Mesh;
  44695. /**
  44696. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44697. * Also see the options.resolution property.
  44698. */
  44699. fovMultiplier: number;
  44700. /**
  44701. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44702. * @param name Element's name, child elements will append suffixes for their own names.
  44703. * @param urlsOfPhoto defines the url of the photo to display
  44704. * @param options defines an object containing optional or exposed sub element properties
  44705. * @param onError defines a callback called when an error occured while loading the texture
  44706. */
  44707. constructor(name: string, urlOfPhoto: string, options: {
  44708. resolution?: number;
  44709. size?: number;
  44710. useDirectMapping?: boolean;
  44711. faceForward?: boolean;
  44712. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44713. /**
  44714. * Releases resources associated with this node.
  44715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44717. */
  44718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44719. }
  44720. }
  44721. declare module "babylonjs/Misc/textureTools" {
  44722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44723. import { Texture } from "babylonjs/Materials/Textures/texture";
  44724. import { Scene } from "babylonjs/scene";
  44725. /**
  44726. * Class used to host texture specific utilities
  44727. */
  44728. export class TextureTools {
  44729. /**
  44730. * Uses the GPU to create a copy texture rescaled at a given size
  44731. * @param texture Texture to copy from
  44732. * @param width defines the desired width
  44733. * @param height defines the desired height
  44734. * @param useBilinearMode defines if bilinear mode has to be used
  44735. * @return the generated texture
  44736. */
  44737. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44738. /**
  44739. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44740. * @param scene defines the hosting scene
  44741. * @returns the environment BRDF texture
  44742. */
  44743. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44744. private static _environmentBRDFBase64Texture;
  44745. }
  44746. }
  44747. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44748. import { Nullable } from "babylonjs/types";
  44749. import { IAnimatable } from "babylonjs/Misc/tools";
  44750. import { Color3 } from "babylonjs/Maths/math";
  44751. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44752. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44753. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44754. import { Engine } from "babylonjs/Engines/engine";
  44755. import { Scene } from "babylonjs/scene";
  44756. /**
  44757. * @hidden
  44758. */
  44759. export interface IMaterialClearCoatDefines {
  44760. CLEARCOAT: boolean;
  44761. CLEARCOAT_DEFAULTIOR: boolean;
  44762. CLEARCOAT_TEXTURE: boolean;
  44763. CLEARCOAT_TEXTUREDIRECTUV: number;
  44764. CLEARCOAT_BUMP: boolean;
  44765. CLEARCOAT_BUMPDIRECTUV: number;
  44766. CLEARCOAT_TINT: boolean;
  44767. CLEARCOAT_TINT_TEXTURE: boolean;
  44768. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44769. /** @hidden */
  44770. _areTexturesDirty: boolean;
  44771. }
  44772. /**
  44773. * Define the code related to the clear coat parameters of the pbr material.
  44774. */
  44775. export class PBRClearCoatConfiguration {
  44776. /**
  44777. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44778. * The default fits with a polyurethane material.
  44779. */
  44780. private static readonly _DefaultIndiceOfRefraction;
  44781. private _isEnabled;
  44782. /**
  44783. * Defines if the clear coat is enabled in the material.
  44784. */
  44785. isEnabled: boolean;
  44786. /**
  44787. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44788. */
  44789. intensity: number;
  44790. /**
  44791. * Defines the clear coat layer roughness.
  44792. */
  44793. roughness: number;
  44794. private _indiceOfRefraction;
  44795. /**
  44796. * Defines the indice of refraction of the clear coat.
  44797. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44798. * The default fits with a polyurethane material.
  44799. * Changing the default value is more performance intensive.
  44800. */
  44801. indiceOfRefraction: number;
  44802. private _texture;
  44803. /**
  44804. * Stores the clear coat values in a texture.
  44805. */
  44806. texture: Nullable<BaseTexture>;
  44807. private _bumpTexture;
  44808. /**
  44809. * Define the clear coat specific bump texture.
  44810. */
  44811. bumpTexture: Nullable<BaseTexture>;
  44812. private _isTintEnabled;
  44813. /**
  44814. * Defines if the clear coat tint is enabled in the material.
  44815. */
  44816. isTintEnabled: boolean;
  44817. /**
  44818. * Defines if the clear coat tint is enabled in the material.
  44819. * This is only use if tint is enabled
  44820. */
  44821. tintColor: Color3;
  44822. /**
  44823. * Defines if the distance at which the tint color should be found in the
  44824. * clear coat media.
  44825. * This is only use if tint is enabled
  44826. */
  44827. tintColorAtDistance: number;
  44828. /**
  44829. * Defines the clear coat layer thickness.
  44830. * This is only use if tint is enabled
  44831. */
  44832. tintThickness: number;
  44833. private _tintTexture;
  44834. /**
  44835. * Stores the clear tint values in a texture.
  44836. * rgb is tint
  44837. * a is a thickness factor
  44838. */
  44839. tintTexture: Nullable<BaseTexture>;
  44840. /** @hidden */
  44841. private _internalMarkAllSubMeshesAsTexturesDirty;
  44842. /** @hidden */
  44843. _markAllSubMeshesAsTexturesDirty(): void;
  44844. /**
  44845. * Instantiate a new istance of clear coat configuration.
  44846. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44847. */
  44848. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44849. /**
  44850. * Specifies that the submesh is ready to be used.
  44851. * @param defines the list of "defines" to update.
  44852. * @param scene defines the scene the material belongs to.
  44853. * @param engine defines the engine the material belongs to.
  44854. * @param disableBumpMap defines wether the material disables bump or not.
  44855. * @returns - boolean indicating that the submesh is ready or not.
  44856. */
  44857. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44858. /**
  44859. * Checks to see if a texture is used in the material.
  44860. * @param defines the list of "defines" to update.
  44861. * @param scene defines the scene to the material belongs to.
  44862. */
  44863. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44864. /**
  44865. * Binds the material data.
  44866. * @param uniformBuffer defines the Uniform buffer to fill in.
  44867. * @param scene defines the scene the material belongs to.
  44868. * @param engine defines the engine the material belongs to.
  44869. * @param disableBumpMap defines wether the material disables bump or not.
  44870. * @param isFrozen defines wether the material is frozen or not.
  44871. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44872. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44873. */
  44874. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44875. /**
  44876. * Checks to see if a texture is used in the material.
  44877. * @param texture - Base texture to use.
  44878. * @returns - Boolean specifying if a texture is used in the material.
  44879. */
  44880. hasTexture(texture: BaseTexture): boolean;
  44881. /**
  44882. * Returns an array of the actively used textures.
  44883. * @param activeTextures Array of BaseTextures
  44884. */
  44885. getActiveTextures(activeTextures: BaseTexture[]): void;
  44886. /**
  44887. * Returns the animatable textures.
  44888. * @param animatables Array of animatable textures.
  44889. */
  44890. getAnimatables(animatables: IAnimatable[]): void;
  44891. /**
  44892. * Disposes the resources of the material.
  44893. * @param forceDisposeTextures - Forces the disposal of all textures.
  44894. */
  44895. dispose(forceDisposeTextures?: boolean): void;
  44896. /**
  44897. * Get the current class name of the texture useful for serialization or dynamic coding.
  44898. * @returns "PBRClearCoatConfiguration"
  44899. */
  44900. getClassName(): string;
  44901. /**
  44902. * Add fallbacks to the effect fallbacks list.
  44903. * @param defines defines the Base texture to use.
  44904. * @param fallbacks defines the current fallback list.
  44905. * @param currentRank defines the current fallback rank.
  44906. * @returns the new fallback rank.
  44907. */
  44908. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44909. /**
  44910. * Add the required uniforms to the current list.
  44911. * @param uniforms defines the current uniform list.
  44912. */
  44913. static AddUniforms(uniforms: string[]): void;
  44914. /**
  44915. * Add the required samplers to the current list.
  44916. * @param samplers defines the current sampler list.
  44917. */
  44918. static AddSamplers(samplers: string[]): void;
  44919. /**
  44920. * Add the required uniforms to the current buffer.
  44921. * @param uniformBuffer defines the current uniform buffer.
  44922. */
  44923. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44924. /**
  44925. * Makes a duplicate of the current configuration into another one.
  44926. * @param clearCoatConfiguration define the config where to copy the info
  44927. */
  44928. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44929. /**
  44930. * Serializes this clear coat configuration.
  44931. * @returns - An object with the serialized config.
  44932. */
  44933. serialize(): any;
  44934. /**
  44935. * Parses a Clear Coat Configuration from a serialized object.
  44936. * @param source - Serialized object.
  44937. */
  44938. parse(source: any): void;
  44939. }
  44940. }
  44941. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44942. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44943. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44945. import { Vector2 } from "babylonjs/Maths/math";
  44946. import { Scene } from "babylonjs/scene";
  44947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44948. import { IAnimatable } from "babylonjs/Misc/tools";
  44949. import { Nullable } from "babylonjs/types";
  44950. /**
  44951. * @hidden
  44952. */
  44953. export interface IMaterialAnisotropicDefines {
  44954. ANISOTROPIC: boolean;
  44955. ANISOTROPIC_TEXTURE: boolean;
  44956. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44957. MAINUV1: boolean;
  44958. _areTexturesDirty: boolean;
  44959. _needUVs: boolean;
  44960. }
  44961. /**
  44962. * Define the code related to the anisotropic parameters of the pbr material.
  44963. */
  44964. export class PBRAnisotropicConfiguration {
  44965. private _isEnabled;
  44966. /**
  44967. * Defines if the anisotropy is enabled in the material.
  44968. */
  44969. isEnabled: boolean;
  44970. /**
  44971. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44972. */
  44973. intensity: number;
  44974. /**
  44975. * Defines if the effect is along the tangents, bitangents or in between.
  44976. * By default, the effect is "strectching" the highlights along the tangents.
  44977. */
  44978. direction: Vector2;
  44979. private _texture;
  44980. /**
  44981. * Stores the anisotropy values in a texture.
  44982. * rg is direction (like normal from -1 to 1)
  44983. * b is a intensity
  44984. */
  44985. texture: Nullable<BaseTexture>;
  44986. /** @hidden */
  44987. private _internalMarkAllSubMeshesAsTexturesDirty;
  44988. /** @hidden */
  44989. _markAllSubMeshesAsTexturesDirty(): void;
  44990. /**
  44991. * Instantiate a new istance of anisotropy configuration.
  44992. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44993. */
  44994. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44995. /**
  44996. * Specifies that the submesh is ready to be used.
  44997. * @param defines the list of "defines" to update.
  44998. * @param scene defines the scene the material belongs to.
  44999. * @returns - boolean indicating that the submesh is ready or not.
  45000. */
  45001. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45002. /**
  45003. * Checks to see if a texture is used in the material.
  45004. * @param defines the list of "defines" to update.
  45005. * @param mesh the mesh we are preparing the defines for.
  45006. * @param scene defines the scene the material belongs to.
  45007. */
  45008. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45009. /**
  45010. * Binds the material data.
  45011. * @param uniformBuffer defines the Uniform buffer to fill in.
  45012. * @param scene defines the scene the material belongs to.
  45013. * @param isFrozen defines wether the material is frozen or not.
  45014. */
  45015. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45016. /**
  45017. * Checks to see if a texture is used in the material.
  45018. * @param texture - Base texture to use.
  45019. * @returns - Boolean specifying if a texture is used in the material.
  45020. */
  45021. hasTexture(texture: BaseTexture): boolean;
  45022. /**
  45023. * Returns an array of the actively used textures.
  45024. * @param activeTextures Array of BaseTextures
  45025. */
  45026. getActiveTextures(activeTextures: BaseTexture[]): void;
  45027. /**
  45028. * Returns the animatable textures.
  45029. * @param animatables Array of animatable textures.
  45030. */
  45031. getAnimatables(animatables: IAnimatable[]): void;
  45032. /**
  45033. * Disposes the resources of the material.
  45034. * @param forceDisposeTextures - Forces the disposal of all textures.
  45035. */
  45036. dispose(forceDisposeTextures?: boolean): void;
  45037. /**
  45038. * Get the current class name of the texture useful for serialization or dynamic coding.
  45039. * @returns "PBRAnisotropicConfiguration"
  45040. */
  45041. getClassName(): string;
  45042. /**
  45043. * Add fallbacks to the effect fallbacks list.
  45044. * @param defines defines the Base texture to use.
  45045. * @param fallbacks defines the current fallback list.
  45046. * @param currentRank defines the current fallback rank.
  45047. * @returns the new fallback rank.
  45048. */
  45049. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45050. /**
  45051. * Add the required uniforms to the current list.
  45052. * @param uniforms defines the current uniform list.
  45053. */
  45054. static AddUniforms(uniforms: string[]): void;
  45055. /**
  45056. * Add the required uniforms to the current buffer.
  45057. * @param uniformBuffer defines the current uniform buffer.
  45058. */
  45059. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45060. /**
  45061. * Add the required samplers to the current list.
  45062. * @param samplers defines the current sampler list.
  45063. */
  45064. static AddSamplers(samplers: string[]): void;
  45065. /**
  45066. * Makes a duplicate of the current configuration into another one.
  45067. * @param anisotropicConfiguration define the config where to copy the info
  45068. */
  45069. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45070. /**
  45071. * Serializes this anisotropy configuration.
  45072. * @returns - An object with the serialized config.
  45073. */
  45074. serialize(): any;
  45075. /**
  45076. * Parses a anisotropy Configuration from a serialized object.
  45077. * @param source - Serialized object.
  45078. */
  45079. parse(source: any): void;
  45080. }
  45081. }
  45082. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45083. /**
  45084. * @hidden
  45085. */
  45086. export interface IMaterialBRDFDefines {
  45087. BRDF_V_HEIGHT_CORRELATED: boolean;
  45088. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45089. /** @hidden */
  45090. _areMiscDirty: boolean;
  45091. }
  45092. /**
  45093. * Define the code related to the BRDF parameters of the pbr material.
  45094. */
  45095. export class PBRBRDFConfiguration {
  45096. private _useEnergyConservation;
  45097. /**
  45098. * Defines if the material uses energy conservation.
  45099. */
  45100. useEnergyConservation: boolean;
  45101. private _useSmithVisibilityHeightCorrelated;
  45102. /**
  45103. * LEGACY Mode set to false
  45104. * Defines if the material uses height smith correlated visibility term.
  45105. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45106. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45107. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45108. * Not relying on height correlated will also disable energy conservation.
  45109. */
  45110. useSmithVisibilityHeightCorrelated: boolean;
  45111. /** @hidden */
  45112. private _internalMarkAllSubMeshesAsMiscDirty;
  45113. /** @hidden */
  45114. _markAllSubMeshesAsMiscDirty(): void;
  45115. /**
  45116. * Instantiate a new istance of clear coat configuration.
  45117. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45118. */
  45119. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45120. /**
  45121. * Checks to see if a texture is used in the material.
  45122. * @param defines the list of "defines" to update.
  45123. */
  45124. prepareDefines(defines: IMaterialBRDFDefines): void;
  45125. /**
  45126. * Get the current class name of the texture useful for serialization or dynamic coding.
  45127. * @returns "PBRClearCoatConfiguration"
  45128. */
  45129. getClassName(): string;
  45130. /**
  45131. * Makes a duplicate of the current configuration into another one.
  45132. * @param brdfConfiguration define the config where to copy the info
  45133. */
  45134. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45135. /**
  45136. * Serializes this BRDF configuration.
  45137. * @returns - An object with the serialized config.
  45138. */
  45139. serialize(): any;
  45140. /**
  45141. * Parses a BRDF Configuration from a serialized object.
  45142. * @param source - Serialized object.
  45143. */
  45144. parse(source: any): void;
  45145. }
  45146. }
  45147. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45148. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45149. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45150. import { Color3 } from "babylonjs/Maths/math";
  45151. import { Scene } from "babylonjs/scene";
  45152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45153. import { IAnimatable } from "babylonjs/Misc/tools";
  45154. import { Nullable } from "babylonjs/types";
  45155. /**
  45156. * @hidden
  45157. */
  45158. export interface IMaterialSheenDefines {
  45159. SHEEN: boolean;
  45160. SHEEN_TEXTURE: boolean;
  45161. SHEEN_TEXTUREDIRECTUV: number;
  45162. SHEEN_LINKWITHALBEDO: boolean;
  45163. /** @hidden */
  45164. _areTexturesDirty: boolean;
  45165. }
  45166. /**
  45167. * Define the code related to the Sheen parameters of the pbr material.
  45168. */
  45169. export class PBRSheenConfiguration {
  45170. private _isEnabled;
  45171. /**
  45172. * Defines if the material uses sheen.
  45173. */
  45174. isEnabled: boolean;
  45175. private _linkSheenWithAlbedo;
  45176. /**
  45177. * Defines if the sheen is linked to the sheen color.
  45178. */
  45179. linkSheenWithAlbedo: boolean;
  45180. /**
  45181. * Defines the sheen intensity.
  45182. */
  45183. intensity: number;
  45184. /**
  45185. * Defines the sheen color.
  45186. */
  45187. color: Color3;
  45188. private _texture;
  45189. /**
  45190. * Stores the sheen tint values in a texture.
  45191. * rgb is tint
  45192. * a is a intensity
  45193. */
  45194. texture: Nullable<BaseTexture>;
  45195. /** @hidden */
  45196. private _internalMarkAllSubMeshesAsTexturesDirty;
  45197. /** @hidden */
  45198. _markAllSubMeshesAsTexturesDirty(): void;
  45199. /**
  45200. * Instantiate a new istance of clear coat configuration.
  45201. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45202. */
  45203. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45204. /**
  45205. * Specifies that the submesh is ready to be used.
  45206. * @param defines the list of "defines" to update.
  45207. * @param scene defines the scene the material belongs to.
  45208. * @returns - boolean indicating that the submesh is ready or not.
  45209. */
  45210. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45211. /**
  45212. * Checks to see if a texture is used in the material.
  45213. * @param defines the list of "defines" to update.
  45214. * @param scene defines the scene the material belongs to.
  45215. */
  45216. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45217. /**
  45218. * Binds the material data.
  45219. * @param uniformBuffer defines the Uniform buffer to fill in.
  45220. * @param scene defines the scene the material belongs to.
  45221. * @param isFrozen defines wether the material is frozen or not.
  45222. */
  45223. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45224. /**
  45225. * Checks to see if a texture is used in the material.
  45226. * @param texture - Base texture to use.
  45227. * @returns - Boolean specifying if a texture is used in the material.
  45228. */
  45229. hasTexture(texture: BaseTexture): boolean;
  45230. /**
  45231. * Returns an array of the actively used textures.
  45232. * @param activeTextures Array of BaseTextures
  45233. */
  45234. getActiveTextures(activeTextures: BaseTexture[]): void;
  45235. /**
  45236. * Returns the animatable textures.
  45237. * @param animatables Array of animatable textures.
  45238. */
  45239. getAnimatables(animatables: IAnimatable[]): void;
  45240. /**
  45241. * Disposes the resources of the material.
  45242. * @param forceDisposeTextures - Forces the disposal of all textures.
  45243. */
  45244. dispose(forceDisposeTextures?: boolean): void;
  45245. /**
  45246. * Get the current class name of the texture useful for serialization or dynamic coding.
  45247. * @returns "PBRSheenConfiguration"
  45248. */
  45249. getClassName(): string;
  45250. /**
  45251. * Add fallbacks to the effect fallbacks list.
  45252. * @param defines defines the Base texture to use.
  45253. * @param fallbacks defines the current fallback list.
  45254. * @param currentRank defines the current fallback rank.
  45255. * @returns the new fallback rank.
  45256. */
  45257. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45258. /**
  45259. * Add the required uniforms to the current list.
  45260. * @param uniforms defines the current uniform list.
  45261. */
  45262. static AddUniforms(uniforms: string[]): void;
  45263. /**
  45264. * Add the required uniforms to the current buffer.
  45265. * @param uniformBuffer defines the current uniform buffer.
  45266. */
  45267. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45268. /**
  45269. * Add the required samplers to the current list.
  45270. * @param samplers defines the current sampler list.
  45271. */
  45272. static AddSamplers(samplers: string[]): void;
  45273. /**
  45274. * Makes a duplicate of the current configuration into another one.
  45275. * @param sheenConfiguration define the config where to copy the info
  45276. */
  45277. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45278. /**
  45279. * Serializes this BRDF configuration.
  45280. * @returns - An object with the serialized config.
  45281. */
  45282. serialize(): any;
  45283. /**
  45284. * Parses a Sheen Configuration from a serialized object.
  45285. * @param source - Serialized object.
  45286. */
  45287. parse(source: any): void;
  45288. }
  45289. }
  45290. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45291. /** @hidden */
  45292. export var pbrFragmentDeclaration: {
  45293. name: string;
  45294. shader: string;
  45295. };
  45296. }
  45297. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45298. /** @hidden */
  45299. export var pbrUboDeclaration: {
  45300. name: string;
  45301. shader: string;
  45302. };
  45303. }
  45304. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45305. /** @hidden */
  45306. export var pbrFragmentExtraDeclaration: {
  45307. name: string;
  45308. shader: string;
  45309. };
  45310. }
  45311. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45312. /** @hidden */
  45313. export var pbrFragmentSamplersDeclaration: {
  45314. name: string;
  45315. shader: string;
  45316. };
  45317. }
  45318. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45319. /** @hidden */
  45320. export var pbrHelperFunctions: {
  45321. name: string;
  45322. shader: string;
  45323. };
  45324. }
  45325. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45326. /** @hidden */
  45327. export var harmonicsFunctions: {
  45328. name: string;
  45329. shader: string;
  45330. };
  45331. }
  45332. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45333. /** @hidden */
  45334. export var pbrDirectLightingSetupFunctions: {
  45335. name: string;
  45336. shader: string;
  45337. };
  45338. }
  45339. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45340. /** @hidden */
  45341. export var pbrDirectLightingFalloffFunctions: {
  45342. name: string;
  45343. shader: string;
  45344. };
  45345. }
  45346. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45347. /** @hidden */
  45348. export var pbrBRDFFunctions: {
  45349. name: string;
  45350. shader: string;
  45351. };
  45352. }
  45353. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45354. /** @hidden */
  45355. export var pbrDirectLightingFunctions: {
  45356. name: string;
  45357. shader: string;
  45358. };
  45359. }
  45360. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45361. /** @hidden */
  45362. export var pbrIBLFunctions: {
  45363. name: string;
  45364. shader: string;
  45365. };
  45366. }
  45367. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45368. /** @hidden */
  45369. export var pbrDebug: {
  45370. name: string;
  45371. shader: string;
  45372. };
  45373. }
  45374. declare module "babylonjs/Shaders/pbr.fragment" {
  45375. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45376. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45377. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45378. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45379. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45380. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45381. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45382. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45383. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45384. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45385. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45386. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45387. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45388. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45389. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45390. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45391. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45392. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45393. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45394. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45395. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45396. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45397. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45398. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45399. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45400. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45401. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45402. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45403. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45404. /** @hidden */
  45405. export var pbrPixelShader: {
  45406. name: string;
  45407. shader: string;
  45408. };
  45409. }
  45410. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45411. /** @hidden */
  45412. export var pbrVertexDeclaration: {
  45413. name: string;
  45414. shader: string;
  45415. };
  45416. }
  45417. declare module "babylonjs/Shaders/pbr.vertex" {
  45418. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45419. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45420. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45421. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45422. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45423. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45424. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45425. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45426. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45427. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45428. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45429. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45430. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45431. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45433. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45434. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45435. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45436. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45437. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45438. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45439. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45440. /** @hidden */
  45441. export var pbrVertexShader: {
  45442. name: string;
  45443. shader: string;
  45444. };
  45445. }
  45446. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45447. import { IAnimatable } from "babylonjs/Misc/tools";
  45448. import { Nullable } from "babylonjs/types";
  45449. import { Scene } from "babylonjs/scene";
  45450. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45451. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45453. import { Mesh } from "babylonjs/Meshes/mesh";
  45454. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45455. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45456. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45457. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45458. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45459. import { Material } from "babylonjs/Materials/material";
  45460. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45462. import "babylonjs/Shaders/pbr.fragment";
  45463. import "babylonjs/Shaders/pbr.vertex";
  45464. /**
  45465. * The Physically based material base class of BJS.
  45466. *
  45467. * This offers the main features of a standard PBR material.
  45468. * For more information, please refer to the documentation :
  45469. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45470. */
  45471. export abstract class PBRBaseMaterial extends PushMaterial {
  45472. /**
  45473. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45474. */
  45475. static readonly PBRMATERIAL_OPAQUE: number;
  45476. /**
  45477. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45478. */
  45479. static readonly PBRMATERIAL_ALPHATEST: number;
  45480. /**
  45481. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45482. */
  45483. static readonly PBRMATERIAL_ALPHABLEND: number;
  45484. /**
  45485. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45486. * They are also discarded below the alpha cutoff threshold to improve performances.
  45487. */
  45488. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45489. /**
  45490. * Defines the default value of how much AO map is occluding the analytical lights
  45491. * (point spot...).
  45492. */
  45493. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45494. /**
  45495. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45496. */
  45497. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45498. /**
  45499. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45500. * to enhance interoperability with other engines.
  45501. */
  45502. static readonly LIGHTFALLOFF_GLTF: number;
  45503. /**
  45504. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45505. * to enhance interoperability with other materials.
  45506. */
  45507. static readonly LIGHTFALLOFF_STANDARD: number;
  45508. /**
  45509. * Intensity of the direct lights e.g. the four lights available in your scene.
  45510. * This impacts both the direct diffuse and specular highlights.
  45511. */
  45512. protected _directIntensity: number;
  45513. /**
  45514. * Intensity of the emissive part of the material.
  45515. * This helps controlling the emissive effect without modifying the emissive color.
  45516. */
  45517. protected _emissiveIntensity: number;
  45518. /**
  45519. * Intensity of the environment e.g. how much the environment will light the object
  45520. * either through harmonics for rough material or through the refelction for shiny ones.
  45521. */
  45522. protected _environmentIntensity: number;
  45523. /**
  45524. * This is a special control allowing the reduction of the specular highlights coming from the
  45525. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45526. */
  45527. protected _specularIntensity: number;
  45528. /**
  45529. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45530. */
  45531. private _lightingInfos;
  45532. /**
  45533. * Debug Control allowing disabling the bump map on this material.
  45534. */
  45535. protected _disableBumpMap: boolean;
  45536. /**
  45537. * AKA Diffuse Texture in standard nomenclature.
  45538. */
  45539. protected _albedoTexture: BaseTexture;
  45540. /**
  45541. * AKA Occlusion Texture in other nomenclature.
  45542. */
  45543. protected _ambientTexture: BaseTexture;
  45544. /**
  45545. * AKA Occlusion Texture Intensity in other nomenclature.
  45546. */
  45547. protected _ambientTextureStrength: number;
  45548. /**
  45549. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45550. * 1 means it completely occludes it
  45551. * 0 mean it has no impact
  45552. */
  45553. protected _ambientTextureImpactOnAnalyticalLights: number;
  45554. /**
  45555. * Stores the alpha values in a texture.
  45556. */
  45557. protected _opacityTexture: BaseTexture;
  45558. /**
  45559. * Stores the reflection values in a texture.
  45560. */
  45561. protected _reflectionTexture: BaseTexture;
  45562. /**
  45563. * Stores the refraction values in a texture.
  45564. */
  45565. protected _refractionTexture: BaseTexture;
  45566. /**
  45567. * Stores the emissive values in a texture.
  45568. */
  45569. protected _emissiveTexture: BaseTexture;
  45570. /**
  45571. * AKA Specular texture in other nomenclature.
  45572. */
  45573. protected _reflectivityTexture: BaseTexture;
  45574. /**
  45575. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45576. */
  45577. protected _metallicTexture: BaseTexture;
  45578. /**
  45579. * Specifies the metallic scalar of the metallic/roughness workflow.
  45580. * Can also be used to scale the metalness values of the metallic texture.
  45581. */
  45582. protected _metallic: Nullable<number>;
  45583. /**
  45584. * Specifies the roughness scalar of the metallic/roughness workflow.
  45585. * Can also be used to scale the roughness values of the metallic texture.
  45586. */
  45587. protected _roughness: Nullable<number>;
  45588. /**
  45589. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45590. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45591. */
  45592. protected _microSurfaceTexture: BaseTexture;
  45593. /**
  45594. * Stores surface normal data used to displace a mesh in a texture.
  45595. */
  45596. protected _bumpTexture: BaseTexture;
  45597. /**
  45598. * Stores the pre-calculated light information of a mesh in a texture.
  45599. */
  45600. protected _lightmapTexture: BaseTexture;
  45601. /**
  45602. * The color of a material in ambient lighting.
  45603. */
  45604. protected _ambientColor: Color3;
  45605. /**
  45606. * AKA Diffuse Color in other nomenclature.
  45607. */
  45608. protected _albedoColor: Color3;
  45609. /**
  45610. * AKA Specular Color in other nomenclature.
  45611. */
  45612. protected _reflectivityColor: Color3;
  45613. /**
  45614. * The color applied when light is reflected from a material.
  45615. */
  45616. protected _reflectionColor: Color3;
  45617. /**
  45618. * The color applied when light is emitted from a material.
  45619. */
  45620. protected _emissiveColor: Color3;
  45621. /**
  45622. * AKA Glossiness in other nomenclature.
  45623. */
  45624. protected _microSurface: number;
  45625. /**
  45626. * source material index of refraction (IOR)' / 'destination material IOR.
  45627. */
  45628. protected _indexOfRefraction: number;
  45629. /**
  45630. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45631. */
  45632. protected _invertRefractionY: boolean;
  45633. /**
  45634. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45635. * Materials half opaque for instance using refraction could benefit from this control.
  45636. */
  45637. protected _linkRefractionWithTransparency: boolean;
  45638. /**
  45639. * Specifies that the material will use the light map as a show map.
  45640. */
  45641. protected _useLightmapAsShadowmap: boolean;
  45642. /**
  45643. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45644. * makes the reflect vector face the model (under horizon).
  45645. */
  45646. protected _useHorizonOcclusion: boolean;
  45647. /**
  45648. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45649. * too much the area relying on ambient texture to define their ambient occlusion.
  45650. */
  45651. protected _useRadianceOcclusion: boolean;
  45652. /**
  45653. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45654. */
  45655. protected _useAlphaFromAlbedoTexture: boolean;
  45656. /**
  45657. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45658. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45659. */
  45660. protected _useSpecularOverAlpha: boolean;
  45661. /**
  45662. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45663. */
  45664. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45665. /**
  45666. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45667. */
  45668. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45669. /**
  45670. * Specifies if the metallic texture contains the roughness information in its green channel.
  45671. */
  45672. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45673. /**
  45674. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45675. */
  45676. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45677. /**
  45678. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45679. */
  45680. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45681. /**
  45682. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45683. */
  45684. protected _useAmbientInGrayScale: boolean;
  45685. /**
  45686. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45687. * The material will try to infer what glossiness each pixel should be.
  45688. */
  45689. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45690. /**
  45691. * Defines the falloff type used in this material.
  45692. * It by default is Physical.
  45693. */
  45694. protected _lightFalloff: number;
  45695. /**
  45696. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45697. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45698. */
  45699. protected _useRadianceOverAlpha: boolean;
  45700. /**
  45701. * Allows using an object space normal map (instead of tangent space).
  45702. */
  45703. protected _useObjectSpaceNormalMap: boolean;
  45704. /**
  45705. * Allows using the bump map in parallax mode.
  45706. */
  45707. protected _useParallax: boolean;
  45708. /**
  45709. * Allows using the bump map in parallax occlusion mode.
  45710. */
  45711. protected _useParallaxOcclusion: boolean;
  45712. /**
  45713. * Controls the scale bias of the parallax mode.
  45714. */
  45715. protected _parallaxScaleBias: number;
  45716. /**
  45717. * If sets to true, disables all the lights affecting the material.
  45718. */
  45719. protected _disableLighting: boolean;
  45720. /**
  45721. * Number of Simultaneous lights allowed on the material.
  45722. */
  45723. protected _maxSimultaneousLights: number;
  45724. /**
  45725. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45726. */
  45727. protected _invertNormalMapX: boolean;
  45728. /**
  45729. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45730. */
  45731. protected _invertNormalMapY: boolean;
  45732. /**
  45733. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45734. */
  45735. protected _twoSidedLighting: boolean;
  45736. /**
  45737. * Defines the alpha limits in alpha test mode.
  45738. */
  45739. protected _alphaCutOff: number;
  45740. /**
  45741. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45742. */
  45743. protected _forceAlphaTest: boolean;
  45744. /**
  45745. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45746. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45747. */
  45748. protected _useAlphaFresnel: boolean;
  45749. /**
  45750. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45751. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45752. */
  45753. protected _useLinearAlphaFresnel: boolean;
  45754. /**
  45755. * The transparency mode of the material.
  45756. */
  45757. protected _transparencyMode: Nullable<number>;
  45758. /**
  45759. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45760. * from cos thetav and roughness:
  45761. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45762. */
  45763. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45764. /**
  45765. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45766. */
  45767. protected _forceIrradianceInFragment: boolean;
  45768. /**
  45769. * Force normal to face away from face.
  45770. */
  45771. protected _forceNormalForward: boolean;
  45772. /**
  45773. * Enables specular anti aliasing in the PBR shader.
  45774. * It will both interacts on the Geometry for analytical and IBL lighting.
  45775. * It also prefilter the roughness map based on the bump values.
  45776. */
  45777. protected _enableSpecularAntiAliasing: boolean;
  45778. /**
  45779. * Default configuration related to image processing available in the PBR Material.
  45780. */
  45781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45782. /**
  45783. * Keep track of the image processing observer to allow dispose and replace.
  45784. */
  45785. private _imageProcessingObserver;
  45786. /**
  45787. * Attaches a new image processing configuration to the PBR Material.
  45788. * @param configuration
  45789. */
  45790. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45791. /**
  45792. * Stores the available render targets.
  45793. */
  45794. private _renderTargets;
  45795. /**
  45796. * Sets the global ambient color for the material used in lighting calculations.
  45797. */
  45798. private _globalAmbientColor;
  45799. /**
  45800. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45801. */
  45802. private _useLogarithmicDepth;
  45803. /**
  45804. * If set to true, no lighting calculations will be applied.
  45805. */
  45806. private _unlit;
  45807. private _debugMode;
  45808. /**
  45809. * @hidden
  45810. * This is reserved for the inspector.
  45811. * Defines the material debug mode.
  45812. * It helps seeing only some components of the material while troubleshooting.
  45813. */
  45814. debugMode: number;
  45815. /**
  45816. * @hidden
  45817. * This is reserved for the inspector.
  45818. * Specify from where on screen the debug mode should start.
  45819. * The value goes from -1 (full screen) to 1 (not visible)
  45820. * It helps with side by side comparison against the final render
  45821. * This defaults to -1
  45822. */
  45823. private debugLimit;
  45824. /**
  45825. * @hidden
  45826. * This is reserved for the inspector.
  45827. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45828. * You can use the factor to better multiply the final value.
  45829. */
  45830. private debugFactor;
  45831. /**
  45832. * Defines the clear coat layer parameters for the material.
  45833. */
  45834. readonly clearCoat: PBRClearCoatConfiguration;
  45835. /**
  45836. * Defines the anisotropic parameters for the material.
  45837. */
  45838. readonly anisotropy: PBRAnisotropicConfiguration;
  45839. /**
  45840. * Defines the BRDF parameters for the material.
  45841. */
  45842. readonly brdf: PBRBRDFConfiguration;
  45843. /**
  45844. * Defines the Sheen parameters for the material.
  45845. */
  45846. readonly sheen: PBRSheenConfiguration;
  45847. /**
  45848. * Instantiates a new PBRMaterial instance.
  45849. *
  45850. * @param name The material name
  45851. * @param scene The scene the material will be use in.
  45852. */
  45853. constructor(name: string, scene: Scene);
  45854. /**
  45855. * Gets a boolean indicating that current material needs to register RTT
  45856. */
  45857. readonly hasRenderTargetTextures: boolean;
  45858. /**
  45859. * Gets the name of the material class.
  45860. */
  45861. getClassName(): string;
  45862. /**
  45863. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45864. */
  45865. /**
  45866. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45867. */
  45868. useLogarithmicDepth: boolean;
  45869. /**
  45870. * Gets the current transparency mode.
  45871. */
  45872. /**
  45873. * Sets the transparency mode of the material.
  45874. *
  45875. * | Value | Type | Description |
  45876. * | ----- | ----------------------------------- | ----------- |
  45877. * | 0 | OPAQUE | |
  45878. * | 1 | ALPHATEST | |
  45879. * | 2 | ALPHABLEND | |
  45880. * | 3 | ALPHATESTANDBLEND | |
  45881. *
  45882. */
  45883. transparencyMode: Nullable<number>;
  45884. /**
  45885. * Returns true if alpha blending should be disabled.
  45886. */
  45887. private readonly _disableAlphaBlending;
  45888. /**
  45889. * Specifies whether or not this material should be rendered in alpha blend mode.
  45890. */
  45891. needAlphaBlending(): boolean;
  45892. /**
  45893. * Specifies if the mesh will require alpha blending.
  45894. * @param mesh - BJS mesh.
  45895. */
  45896. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45897. /**
  45898. * Specifies whether or not this material should be rendered in alpha test mode.
  45899. */
  45900. needAlphaTesting(): boolean;
  45901. /**
  45902. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45903. */
  45904. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45905. /**
  45906. * Gets the texture used for the alpha test.
  45907. */
  45908. getAlphaTestTexture(): BaseTexture;
  45909. /**
  45910. * Specifies that the submesh is ready to be used.
  45911. * @param mesh - BJS mesh.
  45912. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45913. * @param useInstances - Specifies that instances should be used.
  45914. * @returns - boolean indicating that the submesh is ready or not.
  45915. */
  45916. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45917. /**
  45918. * Specifies if the material uses metallic roughness workflow.
  45919. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45920. */
  45921. isMetallicWorkflow(): boolean;
  45922. private _prepareEffect;
  45923. private _prepareDefines;
  45924. /**
  45925. * Force shader compilation
  45926. */
  45927. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45928. clipPlane: boolean;
  45929. }>): void;
  45930. /**
  45931. * Initializes the uniform buffer layout for the shader.
  45932. */
  45933. buildUniformLayout(): void;
  45934. /**
  45935. * Unbinds the textures.
  45936. */
  45937. unbind(): void;
  45938. /**
  45939. * Binds the submesh data.
  45940. * @param world - The world matrix.
  45941. * @param mesh - The BJS mesh.
  45942. * @param subMesh - A submesh of the BJS mesh.
  45943. */
  45944. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45945. /**
  45946. * Returns the animatable textures.
  45947. * @returns - Array of animatable textures.
  45948. */
  45949. getAnimatables(): IAnimatable[];
  45950. /**
  45951. * Returns the texture used for reflections.
  45952. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45953. */
  45954. private _getReflectionTexture;
  45955. /**
  45956. * Returns the texture used for refraction or null if none is used.
  45957. * @returns - Refection texture if present. If no refraction texture and refraction
  45958. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45959. */
  45960. private _getRefractionTexture;
  45961. /**
  45962. * Returns an array of the actively used textures.
  45963. * @returns - Array of BaseTextures
  45964. */
  45965. getActiveTextures(): BaseTexture[];
  45966. /**
  45967. * Checks to see if a texture is used in the material.
  45968. * @param texture - Base texture to use.
  45969. * @returns - Boolean specifying if a texture is used in the material.
  45970. */
  45971. hasTexture(texture: BaseTexture): boolean;
  45972. /**
  45973. * Disposes the resources of the material.
  45974. * @param forceDisposeEffect - Forces the disposal of effects.
  45975. * @param forceDisposeTextures - Forces the disposal of all textures.
  45976. */
  45977. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45978. }
  45979. }
  45980. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45981. import { Nullable } from "babylonjs/types";
  45982. import { Scene } from "babylonjs/scene";
  45983. import { Color3 } from "babylonjs/Maths/math";
  45984. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45985. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45987. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45988. /**
  45989. * The Physically based material of BJS.
  45990. *
  45991. * This offers the main features of a standard PBR material.
  45992. * For more information, please refer to the documentation :
  45993. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45994. */
  45995. export class PBRMaterial extends PBRBaseMaterial {
  45996. /**
  45997. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45998. */
  45999. static readonly PBRMATERIAL_OPAQUE: number;
  46000. /**
  46001. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46002. */
  46003. static readonly PBRMATERIAL_ALPHATEST: number;
  46004. /**
  46005. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46006. */
  46007. static readonly PBRMATERIAL_ALPHABLEND: number;
  46008. /**
  46009. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46010. * They are also discarded below the alpha cutoff threshold to improve performances.
  46011. */
  46012. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46013. /**
  46014. * Defines the default value of how much AO map is occluding the analytical lights
  46015. * (point spot...).
  46016. */
  46017. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46018. /**
  46019. * Intensity of the direct lights e.g. the four lights available in your scene.
  46020. * This impacts both the direct diffuse and specular highlights.
  46021. */
  46022. directIntensity: number;
  46023. /**
  46024. * Intensity of the emissive part of the material.
  46025. * This helps controlling the emissive effect without modifying the emissive color.
  46026. */
  46027. emissiveIntensity: number;
  46028. /**
  46029. * Intensity of the environment e.g. how much the environment will light the object
  46030. * either through harmonics for rough material or through the refelction for shiny ones.
  46031. */
  46032. environmentIntensity: number;
  46033. /**
  46034. * This is a special control allowing the reduction of the specular highlights coming from the
  46035. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46036. */
  46037. specularIntensity: number;
  46038. /**
  46039. * Debug Control allowing disabling the bump map on this material.
  46040. */
  46041. disableBumpMap: boolean;
  46042. /**
  46043. * AKA Diffuse Texture in standard nomenclature.
  46044. */
  46045. albedoTexture: BaseTexture;
  46046. /**
  46047. * AKA Occlusion Texture in other nomenclature.
  46048. */
  46049. ambientTexture: BaseTexture;
  46050. /**
  46051. * AKA Occlusion Texture Intensity in other nomenclature.
  46052. */
  46053. ambientTextureStrength: number;
  46054. /**
  46055. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46056. * 1 means it completely occludes it
  46057. * 0 mean it has no impact
  46058. */
  46059. ambientTextureImpactOnAnalyticalLights: number;
  46060. /**
  46061. * Stores the alpha values in a texture.
  46062. */
  46063. opacityTexture: BaseTexture;
  46064. /**
  46065. * Stores the reflection values in a texture.
  46066. */
  46067. reflectionTexture: Nullable<BaseTexture>;
  46068. /**
  46069. * Stores the emissive values in a texture.
  46070. */
  46071. emissiveTexture: BaseTexture;
  46072. /**
  46073. * AKA Specular texture in other nomenclature.
  46074. */
  46075. reflectivityTexture: BaseTexture;
  46076. /**
  46077. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46078. */
  46079. metallicTexture: BaseTexture;
  46080. /**
  46081. * Specifies the metallic scalar of the metallic/roughness workflow.
  46082. * Can also be used to scale the metalness values of the metallic texture.
  46083. */
  46084. metallic: Nullable<number>;
  46085. /**
  46086. * Specifies the roughness scalar of the metallic/roughness workflow.
  46087. * Can also be used to scale the roughness values of the metallic texture.
  46088. */
  46089. roughness: Nullable<number>;
  46090. /**
  46091. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46092. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46093. */
  46094. microSurfaceTexture: BaseTexture;
  46095. /**
  46096. * Stores surface normal data used to displace a mesh in a texture.
  46097. */
  46098. bumpTexture: BaseTexture;
  46099. /**
  46100. * Stores the pre-calculated light information of a mesh in a texture.
  46101. */
  46102. lightmapTexture: BaseTexture;
  46103. /**
  46104. * Stores the refracted light information in a texture.
  46105. */
  46106. refractionTexture: BaseTexture;
  46107. /**
  46108. * The color of a material in ambient lighting.
  46109. */
  46110. ambientColor: Color3;
  46111. /**
  46112. * AKA Diffuse Color in other nomenclature.
  46113. */
  46114. albedoColor: Color3;
  46115. /**
  46116. * AKA Specular Color in other nomenclature.
  46117. */
  46118. reflectivityColor: Color3;
  46119. /**
  46120. * The color reflected from the material.
  46121. */
  46122. reflectionColor: Color3;
  46123. /**
  46124. * The color emitted from the material.
  46125. */
  46126. emissiveColor: Color3;
  46127. /**
  46128. * AKA Glossiness in other nomenclature.
  46129. */
  46130. microSurface: number;
  46131. /**
  46132. * source material index of refraction (IOR)' / 'destination material IOR.
  46133. */
  46134. indexOfRefraction: number;
  46135. /**
  46136. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46137. */
  46138. invertRefractionY: boolean;
  46139. /**
  46140. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46141. * Materials half opaque for instance using refraction could benefit from this control.
  46142. */
  46143. linkRefractionWithTransparency: boolean;
  46144. /**
  46145. * If true, the light map contains occlusion information instead of lighting info.
  46146. */
  46147. useLightmapAsShadowmap: boolean;
  46148. /**
  46149. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46150. */
  46151. useAlphaFromAlbedoTexture: boolean;
  46152. /**
  46153. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46154. */
  46155. forceAlphaTest: boolean;
  46156. /**
  46157. * Defines the alpha limits in alpha test mode.
  46158. */
  46159. alphaCutOff: number;
  46160. /**
  46161. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46162. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46163. */
  46164. useSpecularOverAlpha: boolean;
  46165. /**
  46166. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46167. */
  46168. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46169. /**
  46170. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46171. */
  46172. useRoughnessFromMetallicTextureAlpha: boolean;
  46173. /**
  46174. * Specifies if the metallic texture contains the roughness information in its green channel.
  46175. */
  46176. useRoughnessFromMetallicTextureGreen: boolean;
  46177. /**
  46178. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46179. */
  46180. useMetallnessFromMetallicTextureBlue: boolean;
  46181. /**
  46182. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46183. */
  46184. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46185. /**
  46186. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46187. */
  46188. useAmbientInGrayScale: boolean;
  46189. /**
  46190. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46191. * The material will try to infer what glossiness each pixel should be.
  46192. */
  46193. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46194. /**
  46195. * BJS is using an harcoded light falloff based on a manually sets up range.
  46196. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46197. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46198. */
  46199. /**
  46200. * BJS is using an harcoded light falloff based on a manually sets up range.
  46201. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46202. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46203. */
  46204. usePhysicalLightFalloff: boolean;
  46205. /**
  46206. * In order to support the falloff compatibility with gltf, a special mode has been added
  46207. * to reproduce the gltf light falloff.
  46208. */
  46209. /**
  46210. * In order to support the falloff compatibility with gltf, a special mode has been added
  46211. * to reproduce the gltf light falloff.
  46212. */
  46213. useGLTFLightFalloff: boolean;
  46214. /**
  46215. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46216. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46217. */
  46218. useRadianceOverAlpha: boolean;
  46219. /**
  46220. * Allows using an object space normal map (instead of tangent space).
  46221. */
  46222. useObjectSpaceNormalMap: boolean;
  46223. /**
  46224. * Allows using the bump map in parallax mode.
  46225. */
  46226. useParallax: boolean;
  46227. /**
  46228. * Allows using the bump map in parallax occlusion mode.
  46229. */
  46230. useParallaxOcclusion: boolean;
  46231. /**
  46232. * Controls the scale bias of the parallax mode.
  46233. */
  46234. parallaxScaleBias: number;
  46235. /**
  46236. * If sets to true, disables all the lights affecting the material.
  46237. */
  46238. disableLighting: boolean;
  46239. /**
  46240. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46241. */
  46242. forceIrradianceInFragment: boolean;
  46243. /**
  46244. * Number of Simultaneous lights allowed on the material.
  46245. */
  46246. maxSimultaneousLights: number;
  46247. /**
  46248. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46249. */
  46250. invertNormalMapX: boolean;
  46251. /**
  46252. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46253. */
  46254. invertNormalMapY: boolean;
  46255. /**
  46256. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46257. */
  46258. twoSidedLighting: boolean;
  46259. /**
  46260. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46261. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46262. */
  46263. useAlphaFresnel: boolean;
  46264. /**
  46265. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46266. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46267. */
  46268. useLinearAlphaFresnel: boolean;
  46269. /**
  46270. * Let user defines the brdf lookup texture used for IBL.
  46271. * A default 8bit version is embedded but you could point at :
  46272. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46273. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46274. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46275. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46276. */
  46277. environmentBRDFTexture: Nullable<BaseTexture>;
  46278. /**
  46279. * Force normal to face away from face.
  46280. */
  46281. forceNormalForward: boolean;
  46282. /**
  46283. * Enables specular anti aliasing in the PBR shader.
  46284. * It will both interacts on the Geometry for analytical and IBL lighting.
  46285. * It also prefilter the roughness map based on the bump values.
  46286. */
  46287. enableSpecularAntiAliasing: boolean;
  46288. /**
  46289. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46290. * makes the reflect vector face the model (under horizon).
  46291. */
  46292. useHorizonOcclusion: boolean;
  46293. /**
  46294. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46295. * too much the area relying on ambient texture to define their ambient occlusion.
  46296. */
  46297. useRadianceOcclusion: boolean;
  46298. /**
  46299. * If set to true, no lighting calculations will be applied.
  46300. */
  46301. unlit: boolean;
  46302. /**
  46303. * Gets the image processing configuration used either in this material.
  46304. */
  46305. /**
  46306. * Sets the Default image processing configuration used either in the this material.
  46307. *
  46308. * If sets to null, the scene one is in use.
  46309. */
  46310. imageProcessingConfiguration: ImageProcessingConfiguration;
  46311. /**
  46312. * Gets wether the color curves effect is enabled.
  46313. */
  46314. /**
  46315. * Sets wether the color curves effect is enabled.
  46316. */
  46317. cameraColorCurvesEnabled: boolean;
  46318. /**
  46319. * Gets wether the color grading effect is enabled.
  46320. */
  46321. /**
  46322. * Gets wether the color grading effect is enabled.
  46323. */
  46324. cameraColorGradingEnabled: boolean;
  46325. /**
  46326. * Gets wether tonemapping is enabled or not.
  46327. */
  46328. /**
  46329. * Sets wether tonemapping is enabled or not
  46330. */
  46331. cameraToneMappingEnabled: boolean;
  46332. /**
  46333. * The camera exposure used on this material.
  46334. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46335. * This corresponds to a photographic exposure.
  46336. */
  46337. /**
  46338. * The camera exposure used on this material.
  46339. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46340. * This corresponds to a photographic exposure.
  46341. */
  46342. cameraExposure: number;
  46343. /**
  46344. * Gets The camera contrast used on this material.
  46345. */
  46346. /**
  46347. * Sets The camera contrast used on this material.
  46348. */
  46349. cameraContrast: number;
  46350. /**
  46351. * Gets the Color Grading 2D Lookup Texture.
  46352. */
  46353. /**
  46354. * Sets the Color Grading 2D Lookup Texture.
  46355. */
  46356. cameraColorGradingTexture: Nullable<BaseTexture>;
  46357. /**
  46358. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46359. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46360. * 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;
  46361. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46362. */
  46363. /**
  46364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46366. * 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;
  46367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46368. */
  46369. cameraColorCurves: Nullable<ColorCurves>;
  46370. /**
  46371. * Instantiates a new PBRMaterial instance.
  46372. *
  46373. * @param name The material name
  46374. * @param scene The scene the material will be use in.
  46375. */
  46376. constructor(name: string, scene: Scene);
  46377. /**
  46378. * Returns the name of this material class.
  46379. */
  46380. getClassName(): string;
  46381. /**
  46382. * Makes a duplicate of the current material.
  46383. * @param name - name to use for the new material.
  46384. */
  46385. clone(name: string): PBRMaterial;
  46386. /**
  46387. * Serializes this PBR Material.
  46388. * @returns - An object with the serialized material.
  46389. */
  46390. serialize(): any;
  46391. /**
  46392. * Parses a PBR Material from a serialized object.
  46393. * @param source - Serialized object.
  46394. * @param scene - BJS scene instance.
  46395. * @param rootUrl - url for the scene object
  46396. * @returns - PBRMaterial
  46397. */
  46398. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46399. }
  46400. }
  46401. declare module "babylonjs/Misc/dds" {
  46402. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46403. import { Engine } from "babylonjs/Engines/engine";
  46404. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46405. import { Nullable } from "babylonjs/types";
  46406. import { Scene } from "babylonjs/scene";
  46407. /**
  46408. * Direct draw surface info
  46409. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46410. */
  46411. export interface DDSInfo {
  46412. /**
  46413. * Width of the texture
  46414. */
  46415. width: number;
  46416. /**
  46417. * Width of the texture
  46418. */
  46419. height: number;
  46420. /**
  46421. * Number of Mipmaps for the texture
  46422. * @see https://en.wikipedia.org/wiki/Mipmap
  46423. */
  46424. mipmapCount: number;
  46425. /**
  46426. * If the textures format is a known fourCC format
  46427. * @see https://www.fourcc.org/
  46428. */
  46429. isFourCC: boolean;
  46430. /**
  46431. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46432. */
  46433. isRGB: boolean;
  46434. /**
  46435. * If the texture is a lumincance format
  46436. */
  46437. isLuminance: boolean;
  46438. /**
  46439. * If this is a cube texture
  46440. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46441. */
  46442. isCube: boolean;
  46443. /**
  46444. * If the texture is a compressed format eg. FOURCC_DXT1
  46445. */
  46446. isCompressed: boolean;
  46447. /**
  46448. * The dxgiFormat of the texture
  46449. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46450. */
  46451. dxgiFormat: number;
  46452. /**
  46453. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46454. */
  46455. textureType: number;
  46456. /**
  46457. * Sphericle polynomial created for the dds texture
  46458. */
  46459. sphericalPolynomial?: SphericalPolynomial;
  46460. }
  46461. /**
  46462. * Class used to provide DDS decompression tools
  46463. */
  46464. export class DDSTools {
  46465. /**
  46466. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46467. */
  46468. static StoreLODInAlphaChannel: boolean;
  46469. /**
  46470. * Gets DDS information from an array buffer
  46471. * @param arrayBuffer defines the array buffer to read data from
  46472. * @returns the DDS information
  46473. */
  46474. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46475. private static _FloatView;
  46476. private static _Int32View;
  46477. private static _ToHalfFloat;
  46478. private static _FromHalfFloat;
  46479. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46480. private static _GetHalfFloatRGBAArrayBuffer;
  46481. private static _GetFloatRGBAArrayBuffer;
  46482. private static _GetFloatAsUIntRGBAArrayBuffer;
  46483. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46484. private static _GetRGBAArrayBuffer;
  46485. private static _ExtractLongWordOrder;
  46486. private static _GetRGBArrayBuffer;
  46487. private static _GetLuminanceArrayBuffer;
  46488. /**
  46489. * Uploads DDS Levels to a Babylon Texture
  46490. * @hidden
  46491. */
  46492. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46493. }
  46494. module "babylonjs/Engines/engine" {
  46495. interface Engine {
  46496. /**
  46497. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46498. * @param rootUrl defines the url where the file to load is located
  46499. * @param scene defines the current scene
  46500. * @param lodScale defines scale to apply to the mip map selection
  46501. * @param lodOffset defines offset to apply to the mip map selection
  46502. * @param onLoad defines an optional callback raised when the texture is loaded
  46503. * @param onError defines an optional callback raised if there is an issue to load the texture
  46504. * @param format defines the format of the data
  46505. * @param forcedExtension defines the extension to use to pick the right loader
  46506. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46507. * @returns the cube texture as an InternalTexture
  46508. */
  46509. 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;
  46510. }
  46511. }
  46512. }
  46513. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46514. import { Nullable } from "babylonjs/types";
  46515. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46516. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46517. /**
  46518. * Implementation of the DDS Texture Loader.
  46519. * @hidden
  46520. */
  46521. export class _DDSTextureLoader implements IInternalTextureLoader {
  46522. /**
  46523. * Defines wether the loader supports cascade loading the different faces.
  46524. */
  46525. readonly supportCascades: boolean;
  46526. /**
  46527. * This returns if the loader support the current file information.
  46528. * @param extension defines the file extension of the file being loaded
  46529. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46530. * @param fallback defines the fallback internal texture if any
  46531. * @param isBase64 defines whether the texture is encoded as a base64
  46532. * @param isBuffer defines whether the texture data are stored as a buffer
  46533. * @returns true if the loader can load the specified file
  46534. */
  46535. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46536. /**
  46537. * Transform the url before loading if required.
  46538. * @param rootUrl the url of the texture
  46539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46540. * @returns the transformed texture
  46541. */
  46542. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46543. /**
  46544. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46545. * @param rootUrl the url of the texture
  46546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46547. * @returns the fallback texture
  46548. */
  46549. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46550. /**
  46551. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46552. * @param data contains the texture data
  46553. * @param texture defines the BabylonJS internal texture
  46554. * @param createPolynomials will be true if polynomials have been requested
  46555. * @param onLoad defines the callback to trigger once the texture is ready
  46556. * @param onError defines the callback to trigger in case of error
  46557. */
  46558. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46559. /**
  46560. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46561. * @param data contains the texture data
  46562. * @param texture defines the BabylonJS internal texture
  46563. * @param callback defines the method to call once ready to upload
  46564. */
  46565. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46566. }
  46567. }
  46568. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46569. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46570. /** @hidden */
  46571. export var rgbdEncodePixelShader: {
  46572. name: string;
  46573. shader: string;
  46574. };
  46575. }
  46576. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46577. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46578. /** @hidden */
  46579. export var rgbdDecodePixelShader: {
  46580. name: string;
  46581. shader: string;
  46582. };
  46583. }
  46584. declare module "babylonjs/Misc/environmentTextureTools" {
  46585. import { Nullable } from "babylonjs/types";
  46586. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46588. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46589. import "babylonjs/Shaders/rgbdEncode.fragment";
  46590. import "babylonjs/Shaders/rgbdDecode.fragment";
  46591. /**
  46592. * Raw texture data and descriptor sufficient for WebGL texture upload
  46593. */
  46594. export interface EnvironmentTextureInfo {
  46595. /**
  46596. * Version of the environment map
  46597. */
  46598. version: number;
  46599. /**
  46600. * Width of image
  46601. */
  46602. width: number;
  46603. /**
  46604. * Irradiance information stored in the file.
  46605. */
  46606. irradiance: any;
  46607. /**
  46608. * Specular information stored in the file.
  46609. */
  46610. specular: any;
  46611. }
  46612. /**
  46613. * Sets of helpers addressing the serialization and deserialization of environment texture
  46614. * stored in a BabylonJS env file.
  46615. * Those files are usually stored as .env files.
  46616. */
  46617. export class EnvironmentTextureTools {
  46618. /**
  46619. * Magic number identifying the env file.
  46620. */
  46621. private static _MagicBytes;
  46622. /**
  46623. * Gets the environment info from an env file.
  46624. * @param data The array buffer containing the .env bytes.
  46625. * @returns the environment file info (the json header) if successfully parsed.
  46626. */
  46627. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46628. /**
  46629. * Creates an environment texture from a loaded cube texture.
  46630. * @param texture defines the cube texture to convert in env file
  46631. * @return a promise containing the environment data if succesfull.
  46632. */
  46633. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46634. /**
  46635. * Creates a JSON representation of the spherical data.
  46636. * @param texture defines the texture containing the polynomials
  46637. * @return the JSON representation of the spherical info
  46638. */
  46639. private static _CreateEnvTextureIrradiance;
  46640. /**
  46641. * Uploads the texture info contained in the env file to the GPU.
  46642. * @param texture defines the internal texture to upload to
  46643. * @param arrayBuffer defines the buffer cotaining the data to load
  46644. * @param info defines the texture info retrieved through the GetEnvInfo method
  46645. * @returns a promise
  46646. */
  46647. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46648. /**
  46649. * Uploads the levels of image data to the GPU.
  46650. * @param texture defines the internal texture to upload to
  46651. * @param imageData defines the array buffer views of image data [mipmap][face]
  46652. * @returns a promise
  46653. */
  46654. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46655. /**
  46656. * Uploads spherical polynomials information to the texture.
  46657. * @param texture defines the texture we are trying to upload the information to
  46658. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46659. */
  46660. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46661. /** @hidden */
  46662. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46663. }
  46664. }
  46665. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46666. import { Nullable } from "babylonjs/types";
  46667. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46668. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46669. /**
  46670. * Implementation of the ENV Texture Loader.
  46671. * @hidden
  46672. */
  46673. export class _ENVTextureLoader implements IInternalTextureLoader {
  46674. /**
  46675. * Defines wether the loader supports cascade loading the different faces.
  46676. */
  46677. readonly supportCascades: boolean;
  46678. /**
  46679. * This returns if the loader support the current file information.
  46680. * @param extension defines the file extension of the file being loaded
  46681. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46682. * @param fallback defines the fallback internal texture if any
  46683. * @param isBase64 defines whether the texture is encoded as a base64
  46684. * @param isBuffer defines whether the texture data are stored as a buffer
  46685. * @returns true if the loader can load the specified file
  46686. */
  46687. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46688. /**
  46689. * Transform the url before loading if required.
  46690. * @param rootUrl the url of the texture
  46691. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46692. * @returns the transformed texture
  46693. */
  46694. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46695. /**
  46696. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46697. * @param rootUrl the url of the texture
  46698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46699. * @returns the fallback texture
  46700. */
  46701. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46702. /**
  46703. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46704. * @param data contains the texture data
  46705. * @param texture defines the BabylonJS internal texture
  46706. * @param createPolynomials will be true if polynomials have been requested
  46707. * @param onLoad defines the callback to trigger once the texture is ready
  46708. * @param onError defines the callback to trigger in case of error
  46709. */
  46710. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46711. /**
  46712. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46713. * @param data contains the texture data
  46714. * @param texture defines the BabylonJS internal texture
  46715. * @param callback defines the method to call once ready to upload
  46716. */
  46717. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46718. }
  46719. }
  46720. declare module "babylonjs/Misc/khronosTextureContainer" {
  46721. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46722. /**
  46723. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46724. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46725. */
  46726. export class KhronosTextureContainer {
  46727. /** contents of the KTX container file */
  46728. arrayBuffer: any;
  46729. private static HEADER_LEN;
  46730. private static COMPRESSED_2D;
  46731. private static COMPRESSED_3D;
  46732. private static TEX_2D;
  46733. private static TEX_3D;
  46734. /**
  46735. * Gets the openGL type
  46736. */
  46737. glType: number;
  46738. /**
  46739. * Gets the openGL type size
  46740. */
  46741. glTypeSize: number;
  46742. /**
  46743. * Gets the openGL format
  46744. */
  46745. glFormat: number;
  46746. /**
  46747. * Gets the openGL internal format
  46748. */
  46749. glInternalFormat: number;
  46750. /**
  46751. * Gets the base internal format
  46752. */
  46753. glBaseInternalFormat: number;
  46754. /**
  46755. * Gets image width in pixel
  46756. */
  46757. pixelWidth: number;
  46758. /**
  46759. * Gets image height in pixel
  46760. */
  46761. pixelHeight: number;
  46762. /**
  46763. * Gets image depth in pixels
  46764. */
  46765. pixelDepth: number;
  46766. /**
  46767. * Gets the number of array elements
  46768. */
  46769. numberOfArrayElements: number;
  46770. /**
  46771. * Gets the number of faces
  46772. */
  46773. numberOfFaces: number;
  46774. /**
  46775. * Gets the number of mipmap levels
  46776. */
  46777. numberOfMipmapLevels: number;
  46778. /**
  46779. * Gets the bytes of key value data
  46780. */
  46781. bytesOfKeyValueData: number;
  46782. /**
  46783. * Gets the load type
  46784. */
  46785. loadType: number;
  46786. /**
  46787. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46788. */
  46789. isInvalid: boolean;
  46790. /**
  46791. * Creates a new KhronosTextureContainer
  46792. * @param arrayBuffer contents of the KTX container file
  46793. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46794. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46795. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46796. */
  46797. constructor(
  46798. /** contents of the KTX container file */
  46799. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46800. /**
  46801. * Uploads KTX content to a Babylon Texture.
  46802. * It is assumed that the texture has already been created & is currently bound
  46803. * @hidden
  46804. */
  46805. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46806. private _upload2DCompressedLevels;
  46807. }
  46808. }
  46809. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46810. import { Nullable } from "babylonjs/types";
  46811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46812. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46813. /**
  46814. * Implementation of the KTX Texture Loader.
  46815. * @hidden
  46816. */
  46817. export class _KTXTextureLoader implements IInternalTextureLoader {
  46818. /**
  46819. * Defines wether the loader supports cascade loading the different faces.
  46820. */
  46821. readonly supportCascades: boolean;
  46822. /**
  46823. * This returns if the loader support the current file information.
  46824. * @param extension defines the file extension of the file being loaded
  46825. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46826. * @param fallback defines the fallback internal texture if any
  46827. * @param isBase64 defines whether the texture is encoded as a base64
  46828. * @param isBuffer defines whether the texture data are stored as a buffer
  46829. * @returns true if the loader can load the specified file
  46830. */
  46831. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46832. /**
  46833. * Transform the url before loading if required.
  46834. * @param rootUrl the url of the texture
  46835. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46836. * @returns the transformed texture
  46837. */
  46838. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46839. /**
  46840. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46841. * @param rootUrl the url of the texture
  46842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46843. * @returns the fallback texture
  46844. */
  46845. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46846. /**
  46847. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46848. * @param data contains the texture data
  46849. * @param texture defines the BabylonJS internal texture
  46850. * @param createPolynomials will be true if polynomials have been requested
  46851. * @param onLoad defines the callback to trigger once the texture is ready
  46852. * @param onError defines the callback to trigger in case of error
  46853. */
  46854. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46855. /**
  46856. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46857. * @param data contains the texture data
  46858. * @param texture defines the BabylonJS internal texture
  46859. * @param callback defines the method to call once ready to upload
  46860. */
  46861. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46862. }
  46863. }
  46864. declare module "babylonjs/Helpers/sceneHelpers" {
  46865. import { Nullable } from "babylonjs/types";
  46866. import { Mesh } from "babylonjs/Meshes/mesh";
  46867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46868. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46869. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46870. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46871. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46872. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46873. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46874. import "babylonjs/Meshes/Builders/boxBuilder";
  46875. /** @hidden */
  46876. export var _forceSceneHelpersToBundle: boolean;
  46877. module "babylonjs/scene" {
  46878. interface Scene {
  46879. /**
  46880. * Creates a default light for the scene.
  46881. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46882. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46883. */
  46884. createDefaultLight(replace?: boolean): void;
  46885. /**
  46886. * Creates a default camera for the scene.
  46887. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46888. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46889. * @param replace has default false, when true replaces the active camera in the scene
  46890. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46891. */
  46892. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46893. /**
  46894. * Creates a default camera and a default light.
  46895. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46896. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46897. * @param replace has the default false, when true replaces the active camera/light in the scene
  46898. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46899. */
  46900. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46901. /**
  46902. * Creates a new sky box
  46903. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46904. * @param environmentTexture defines the texture to use as environment texture
  46905. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46906. * @param scale defines the overall scale of the skybox
  46907. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46908. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46909. * @returns a new mesh holding the sky box
  46910. */
  46911. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46912. /**
  46913. * Creates a new environment
  46914. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46915. * @param options defines the options you can use to configure the environment
  46916. * @returns the new EnvironmentHelper
  46917. */
  46918. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46919. /**
  46920. * Creates a new VREXperienceHelper
  46921. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46922. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46923. * @returns a new VREXperienceHelper
  46924. */
  46925. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46926. /**
  46927. * Creates a new XREXperienceHelper
  46928. * @see http://doc.babylonjs.com/how_to/webxr
  46929. * @returns a promise for a new XREXperienceHelper
  46930. */
  46931. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46932. }
  46933. }
  46934. }
  46935. declare module "babylonjs/Helpers/videoDome" {
  46936. import { Scene } from "babylonjs/scene";
  46937. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46938. import { Mesh } from "babylonjs/Meshes/mesh";
  46939. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46940. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46941. import "babylonjs/Meshes/Builders/sphereBuilder";
  46942. /**
  46943. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46944. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46945. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46946. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46947. */
  46948. export class VideoDome extends TransformNode {
  46949. /**
  46950. * Define the video source as a Monoscopic panoramic 360 video.
  46951. */
  46952. static readonly MODE_MONOSCOPIC: number;
  46953. /**
  46954. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46955. */
  46956. static readonly MODE_TOPBOTTOM: number;
  46957. /**
  46958. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46959. */
  46960. static readonly MODE_SIDEBYSIDE: number;
  46961. private _useDirectMapping;
  46962. /**
  46963. * The video texture being displayed on the sphere
  46964. */
  46965. protected _videoTexture: VideoTexture;
  46966. /**
  46967. * Gets the video texture being displayed on the sphere
  46968. */
  46969. readonly videoTexture: VideoTexture;
  46970. /**
  46971. * The skybox material
  46972. */
  46973. protected _material: BackgroundMaterial;
  46974. /**
  46975. * The surface used for the skybox
  46976. */
  46977. protected _mesh: Mesh;
  46978. /**
  46979. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46980. * Also see the options.resolution property.
  46981. */
  46982. fovMultiplier: number;
  46983. private _videoMode;
  46984. /**
  46985. * Gets or set the current video mode for the video. It can be:
  46986. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46987. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46988. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46989. */
  46990. videoMode: number;
  46991. /**
  46992. * Oberserver used in Stereoscopic VR Mode.
  46993. */
  46994. private _onBeforeCameraRenderObserver;
  46995. /**
  46996. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46997. * @param name Element's name, child elements will append suffixes for their own names.
  46998. * @param urlsOrVideo defines the url(s) or the video element to use
  46999. * @param options An object containing optional or exposed sub element properties
  47000. */
  47001. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47002. resolution?: number;
  47003. clickToPlay?: boolean;
  47004. autoPlay?: boolean;
  47005. loop?: boolean;
  47006. size?: number;
  47007. poster?: string;
  47008. faceForward?: boolean;
  47009. useDirectMapping?: boolean;
  47010. }, scene: Scene);
  47011. private _changeVideoMode;
  47012. /**
  47013. * Releases resources associated with this node.
  47014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47016. */
  47017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47018. }
  47019. }
  47020. declare module "babylonjs/Helpers/index" {
  47021. export * from "babylonjs/Helpers/environmentHelper";
  47022. export * from "babylonjs/Helpers/photoDome";
  47023. export * from "babylonjs/Helpers/sceneHelpers";
  47024. export * from "babylonjs/Helpers/videoDome";
  47025. }
  47026. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47027. import { PerfCounter } from "babylonjs/Misc/tools";
  47028. import { IDisposable } from "babylonjs/scene";
  47029. import { Engine } from "babylonjs/Engines/engine";
  47030. /**
  47031. * This class can be used to get instrumentation data from a Babylon engine
  47032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47033. */
  47034. export class EngineInstrumentation implements IDisposable {
  47035. /**
  47036. * Define the instrumented engine.
  47037. */
  47038. engine: Engine;
  47039. private _captureGPUFrameTime;
  47040. private _gpuFrameTimeToken;
  47041. private _gpuFrameTime;
  47042. private _captureShaderCompilationTime;
  47043. private _shaderCompilationTime;
  47044. private _onBeginFrameObserver;
  47045. private _onEndFrameObserver;
  47046. private _onBeforeShaderCompilationObserver;
  47047. private _onAfterShaderCompilationObserver;
  47048. /**
  47049. * Gets the perf counter used for GPU frame time
  47050. */
  47051. readonly gpuFrameTimeCounter: PerfCounter;
  47052. /**
  47053. * Gets the GPU frame time capture status
  47054. */
  47055. /**
  47056. * Enable or disable the GPU frame time capture
  47057. */
  47058. captureGPUFrameTime: boolean;
  47059. /**
  47060. * Gets the perf counter used for shader compilation time
  47061. */
  47062. readonly shaderCompilationTimeCounter: PerfCounter;
  47063. /**
  47064. * Gets the shader compilation time capture status
  47065. */
  47066. /**
  47067. * Enable or disable the shader compilation time capture
  47068. */
  47069. captureShaderCompilationTime: boolean;
  47070. /**
  47071. * Instantiates a new engine instrumentation.
  47072. * This class can be used to get instrumentation data from a Babylon engine
  47073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47074. * @param engine Defines the engine to instrument
  47075. */
  47076. constructor(
  47077. /**
  47078. * Define the instrumented engine.
  47079. */
  47080. engine: Engine);
  47081. /**
  47082. * Dispose and release associated resources.
  47083. */
  47084. dispose(): void;
  47085. }
  47086. }
  47087. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47088. import { PerfCounter } from "babylonjs/Misc/tools";
  47089. import { Scene, IDisposable } from "babylonjs/scene";
  47090. /**
  47091. * This class can be used to get instrumentation data from a Babylon engine
  47092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47093. */
  47094. export class SceneInstrumentation implements IDisposable {
  47095. /**
  47096. * Defines the scene to instrument
  47097. */
  47098. scene: Scene;
  47099. private _captureActiveMeshesEvaluationTime;
  47100. private _activeMeshesEvaluationTime;
  47101. private _captureRenderTargetsRenderTime;
  47102. private _renderTargetsRenderTime;
  47103. private _captureFrameTime;
  47104. private _frameTime;
  47105. private _captureRenderTime;
  47106. private _renderTime;
  47107. private _captureInterFrameTime;
  47108. private _interFrameTime;
  47109. private _captureParticlesRenderTime;
  47110. private _particlesRenderTime;
  47111. private _captureSpritesRenderTime;
  47112. private _spritesRenderTime;
  47113. private _capturePhysicsTime;
  47114. private _physicsTime;
  47115. private _captureAnimationsTime;
  47116. private _animationsTime;
  47117. private _captureCameraRenderTime;
  47118. private _cameraRenderTime;
  47119. private _onBeforeActiveMeshesEvaluationObserver;
  47120. private _onAfterActiveMeshesEvaluationObserver;
  47121. private _onBeforeRenderTargetsRenderObserver;
  47122. private _onAfterRenderTargetsRenderObserver;
  47123. private _onAfterRenderObserver;
  47124. private _onBeforeDrawPhaseObserver;
  47125. private _onAfterDrawPhaseObserver;
  47126. private _onBeforeAnimationsObserver;
  47127. private _onBeforeParticlesRenderingObserver;
  47128. private _onAfterParticlesRenderingObserver;
  47129. private _onBeforeSpritesRenderingObserver;
  47130. private _onAfterSpritesRenderingObserver;
  47131. private _onBeforePhysicsObserver;
  47132. private _onAfterPhysicsObserver;
  47133. private _onAfterAnimationsObserver;
  47134. private _onBeforeCameraRenderObserver;
  47135. private _onAfterCameraRenderObserver;
  47136. /**
  47137. * Gets the perf counter used for active meshes evaluation time
  47138. */
  47139. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47140. /**
  47141. * Gets the active meshes evaluation time capture status
  47142. */
  47143. /**
  47144. * Enable or disable the active meshes evaluation time capture
  47145. */
  47146. captureActiveMeshesEvaluationTime: boolean;
  47147. /**
  47148. * Gets the perf counter used for render targets render time
  47149. */
  47150. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47151. /**
  47152. * Gets the render targets render time capture status
  47153. */
  47154. /**
  47155. * Enable or disable the render targets render time capture
  47156. */
  47157. captureRenderTargetsRenderTime: boolean;
  47158. /**
  47159. * Gets the perf counter used for particles render time
  47160. */
  47161. readonly particlesRenderTimeCounter: PerfCounter;
  47162. /**
  47163. * Gets the particles render time capture status
  47164. */
  47165. /**
  47166. * Enable or disable the particles render time capture
  47167. */
  47168. captureParticlesRenderTime: boolean;
  47169. /**
  47170. * Gets the perf counter used for sprites render time
  47171. */
  47172. readonly spritesRenderTimeCounter: PerfCounter;
  47173. /**
  47174. * Gets the sprites render time capture status
  47175. */
  47176. /**
  47177. * Enable or disable the sprites render time capture
  47178. */
  47179. captureSpritesRenderTime: boolean;
  47180. /**
  47181. * Gets the perf counter used for physics time
  47182. */
  47183. readonly physicsTimeCounter: PerfCounter;
  47184. /**
  47185. * Gets the physics time capture status
  47186. */
  47187. /**
  47188. * Enable or disable the physics time capture
  47189. */
  47190. capturePhysicsTime: boolean;
  47191. /**
  47192. * Gets the perf counter used for animations time
  47193. */
  47194. readonly animationsTimeCounter: PerfCounter;
  47195. /**
  47196. * Gets the animations time capture status
  47197. */
  47198. /**
  47199. * Enable or disable the animations time capture
  47200. */
  47201. captureAnimationsTime: boolean;
  47202. /**
  47203. * Gets the perf counter used for frame time capture
  47204. */
  47205. readonly frameTimeCounter: PerfCounter;
  47206. /**
  47207. * Gets the frame time capture status
  47208. */
  47209. /**
  47210. * Enable or disable the frame time capture
  47211. */
  47212. captureFrameTime: boolean;
  47213. /**
  47214. * Gets the perf counter used for inter-frames time capture
  47215. */
  47216. readonly interFrameTimeCounter: PerfCounter;
  47217. /**
  47218. * Gets the inter-frames time capture status
  47219. */
  47220. /**
  47221. * Enable or disable the inter-frames time capture
  47222. */
  47223. captureInterFrameTime: boolean;
  47224. /**
  47225. * Gets the perf counter used for render time capture
  47226. */
  47227. readonly renderTimeCounter: PerfCounter;
  47228. /**
  47229. * Gets the render time capture status
  47230. */
  47231. /**
  47232. * Enable or disable the render time capture
  47233. */
  47234. captureRenderTime: boolean;
  47235. /**
  47236. * Gets the perf counter used for camera render time capture
  47237. */
  47238. readonly cameraRenderTimeCounter: PerfCounter;
  47239. /**
  47240. * Gets the camera render time capture status
  47241. */
  47242. /**
  47243. * Enable or disable the camera render time capture
  47244. */
  47245. captureCameraRenderTime: boolean;
  47246. /**
  47247. * Gets the perf counter used for draw calls
  47248. */
  47249. readonly drawCallsCounter: PerfCounter;
  47250. /**
  47251. * Gets the perf counter used for texture collisions
  47252. */
  47253. readonly textureCollisionsCounter: PerfCounter;
  47254. /**
  47255. * Instantiates a new scene instrumentation.
  47256. * This class can be used to get instrumentation data from a Babylon engine
  47257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47258. * @param scene Defines the scene to instrument
  47259. */
  47260. constructor(
  47261. /**
  47262. * Defines the scene to instrument
  47263. */
  47264. scene: Scene);
  47265. /**
  47266. * Dispose and release associated resources.
  47267. */
  47268. dispose(): void;
  47269. }
  47270. }
  47271. declare module "babylonjs/Instrumentation/index" {
  47272. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47273. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47274. export * from "babylonjs/Instrumentation/timeToken";
  47275. }
  47276. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47277. /** @hidden */
  47278. export var glowMapGenerationPixelShader: {
  47279. name: string;
  47280. shader: string;
  47281. };
  47282. }
  47283. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47284. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47285. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47286. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47287. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47288. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47289. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47290. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47291. /** @hidden */
  47292. export var glowMapGenerationVertexShader: {
  47293. name: string;
  47294. shader: string;
  47295. };
  47296. }
  47297. declare module "babylonjs/Layers/effectLayer" {
  47298. import { Observable } from "babylonjs/Misc/observable";
  47299. import { Nullable } from "babylonjs/types";
  47300. import { Camera } from "babylonjs/Cameras/camera";
  47301. import { Scene } from "babylonjs/scene";
  47302. import { Color4, ISize } from "babylonjs/Maths/math";
  47303. import { Engine } from "babylonjs/Engines/engine";
  47304. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47306. import { Mesh } from "babylonjs/Meshes/mesh";
  47307. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47309. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47310. import { Effect } from "babylonjs/Materials/effect";
  47311. import { Material } from "babylonjs/Materials/material";
  47312. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47313. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47314. /**
  47315. * Effect layer options. This helps customizing the behaviour
  47316. * of the effect layer.
  47317. */
  47318. export interface IEffectLayerOptions {
  47319. /**
  47320. * Multiplication factor apply to the canvas size to compute the render target size
  47321. * used to generated the objects (the smaller the faster).
  47322. */
  47323. mainTextureRatio: number;
  47324. /**
  47325. * Enforces a fixed size texture to ensure effect stability across devices.
  47326. */
  47327. mainTextureFixedSize?: number;
  47328. /**
  47329. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47330. */
  47331. alphaBlendingMode: number;
  47332. /**
  47333. * The camera attached to the layer.
  47334. */
  47335. camera: Nullable<Camera>;
  47336. /**
  47337. * The rendering group to draw the layer in.
  47338. */
  47339. renderingGroupId: number;
  47340. }
  47341. /**
  47342. * The effect layer Helps adding post process effect blended with the main pass.
  47343. *
  47344. * This can be for instance use to generate glow or higlight effects on the scene.
  47345. *
  47346. * The effect layer class can not be used directly and is intented to inherited from to be
  47347. * customized per effects.
  47348. */
  47349. export abstract class EffectLayer {
  47350. private _vertexBuffers;
  47351. private _indexBuffer;
  47352. private _cachedDefines;
  47353. private _effectLayerMapGenerationEffect;
  47354. private _effectLayerOptions;
  47355. private _mergeEffect;
  47356. protected _scene: Scene;
  47357. protected _engine: Engine;
  47358. protected _maxSize: number;
  47359. protected _mainTextureDesiredSize: ISize;
  47360. protected _mainTexture: RenderTargetTexture;
  47361. protected _shouldRender: boolean;
  47362. protected _postProcesses: PostProcess[];
  47363. protected _textures: BaseTexture[];
  47364. protected _emissiveTextureAndColor: {
  47365. texture: Nullable<BaseTexture>;
  47366. color: Color4;
  47367. };
  47368. /**
  47369. * The name of the layer
  47370. */
  47371. name: string;
  47372. /**
  47373. * The clear color of the texture used to generate the glow map.
  47374. */
  47375. neutralColor: Color4;
  47376. /**
  47377. * Specifies wether the highlight layer is enabled or not.
  47378. */
  47379. isEnabled: boolean;
  47380. /**
  47381. * Gets the camera attached to the layer.
  47382. */
  47383. readonly camera: Nullable<Camera>;
  47384. /**
  47385. * Gets the rendering group id the layer should render in.
  47386. */
  47387. readonly renderingGroupId: number;
  47388. /**
  47389. * An event triggered when the effect layer has been disposed.
  47390. */
  47391. onDisposeObservable: Observable<EffectLayer>;
  47392. /**
  47393. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47394. */
  47395. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47396. /**
  47397. * An event triggered when the generated texture is being merged in the scene.
  47398. */
  47399. onBeforeComposeObservable: Observable<EffectLayer>;
  47400. /**
  47401. * An event triggered when the generated texture has been merged in the scene.
  47402. */
  47403. onAfterComposeObservable: Observable<EffectLayer>;
  47404. /**
  47405. * An event triggered when the efffect layer changes its size.
  47406. */
  47407. onSizeChangedObservable: Observable<EffectLayer>;
  47408. /** @hidden */
  47409. static _SceneComponentInitialization: (scene: Scene) => void;
  47410. /**
  47411. * Instantiates a new effect Layer and references it in the scene.
  47412. * @param name The name of the layer
  47413. * @param scene The scene to use the layer in
  47414. */
  47415. constructor(
  47416. /** The Friendly of the effect in the scene */
  47417. name: string, scene: Scene);
  47418. /**
  47419. * Get the effect name of the layer.
  47420. * @return The effect name
  47421. */
  47422. abstract getEffectName(): string;
  47423. /**
  47424. * Checks for the readiness of the element composing the layer.
  47425. * @param subMesh the mesh to check for
  47426. * @param useInstances specify wether or not to use instances to render the mesh
  47427. * @return true if ready otherwise, false
  47428. */
  47429. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47430. /**
  47431. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47432. * @returns true if the effect requires stencil during the main canvas render pass.
  47433. */
  47434. abstract needStencil(): boolean;
  47435. /**
  47436. * Create the merge effect. This is the shader use to blit the information back
  47437. * to the main canvas at the end of the scene rendering.
  47438. * @returns The effect containing the shader used to merge the effect on the main canvas
  47439. */
  47440. protected abstract _createMergeEffect(): Effect;
  47441. /**
  47442. * Creates the render target textures and post processes used in the effect layer.
  47443. */
  47444. protected abstract _createTextureAndPostProcesses(): void;
  47445. /**
  47446. * Implementation specific of rendering the generating effect on the main canvas.
  47447. * @param effect The effect used to render through
  47448. */
  47449. protected abstract _internalRender(effect: Effect): void;
  47450. /**
  47451. * Sets the required values for both the emissive texture and and the main color.
  47452. */
  47453. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47454. /**
  47455. * Free any resources and references associated to a mesh.
  47456. * Internal use
  47457. * @param mesh The mesh to free.
  47458. */
  47459. abstract _disposeMesh(mesh: Mesh): void;
  47460. /**
  47461. * Serializes this layer (Glow or Highlight for example)
  47462. * @returns a serialized layer object
  47463. */
  47464. abstract serialize?(): any;
  47465. /**
  47466. * Initializes the effect layer with the required options.
  47467. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47468. */
  47469. protected _init(options: Partial<IEffectLayerOptions>): void;
  47470. /**
  47471. * Generates the index buffer of the full screen quad blending to the main canvas.
  47472. */
  47473. private _generateIndexBuffer;
  47474. /**
  47475. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47476. */
  47477. private _genrateVertexBuffer;
  47478. /**
  47479. * Sets the main texture desired size which is the closest power of two
  47480. * of the engine canvas size.
  47481. */
  47482. private _setMainTextureSize;
  47483. /**
  47484. * Creates the main texture for the effect layer.
  47485. */
  47486. protected _createMainTexture(): void;
  47487. /**
  47488. * Adds specific effects defines.
  47489. * @param defines The defines to add specifics to.
  47490. */
  47491. protected _addCustomEffectDefines(defines: string[]): void;
  47492. /**
  47493. * Checks for the readiness of the element composing the layer.
  47494. * @param subMesh the mesh to check for
  47495. * @param useInstances specify wether or not to use instances to render the mesh
  47496. * @param emissiveTexture the associated emissive texture used to generate the glow
  47497. * @return true if ready otherwise, false
  47498. */
  47499. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47500. /**
  47501. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47502. */
  47503. render(): void;
  47504. /**
  47505. * Determine if a given mesh will be used in the current effect.
  47506. * @param mesh mesh to test
  47507. * @returns true if the mesh will be used
  47508. */
  47509. hasMesh(mesh: AbstractMesh): boolean;
  47510. /**
  47511. * Returns true if the layer contains information to display, otherwise false.
  47512. * @returns true if the glow layer should be rendered
  47513. */
  47514. shouldRender(): boolean;
  47515. /**
  47516. * Returns true if the mesh should render, otherwise false.
  47517. * @param mesh The mesh to render
  47518. * @returns true if it should render otherwise false
  47519. */
  47520. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47521. /**
  47522. * Returns true if the mesh can be rendered, otherwise false.
  47523. * @param mesh The mesh to render
  47524. * @param material The material used on the mesh
  47525. * @returns true if it can be rendered otherwise false
  47526. */
  47527. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47528. /**
  47529. * Returns true if the mesh should render, otherwise false.
  47530. * @param mesh The mesh to render
  47531. * @returns true if it should render otherwise false
  47532. */
  47533. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47534. /**
  47535. * Renders the submesh passed in parameter to the generation map.
  47536. */
  47537. protected _renderSubMesh(subMesh: SubMesh): void;
  47538. /**
  47539. * Rebuild the required buffers.
  47540. * @hidden Internal use only.
  47541. */
  47542. _rebuild(): void;
  47543. /**
  47544. * Dispose only the render target textures and post process.
  47545. */
  47546. private _disposeTextureAndPostProcesses;
  47547. /**
  47548. * Dispose the highlight layer and free resources.
  47549. */
  47550. dispose(): void;
  47551. /**
  47552. * Gets the class name of the effect layer
  47553. * @returns the string with the class name of the effect layer
  47554. */
  47555. getClassName(): string;
  47556. /**
  47557. * Creates an effect layer from parsed effect layer data
  47558. * @param parsedEffectLayer defines effect layer data
  47559. * @param scene defines the current scene
  47560. * @param rootUrl defines the root URL containing the effect layer information
  47561. * @returns a parsed effect Layer
  47562. */
  47563. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47564. }
  47565. }
  47566. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47567. import { Scene } from "babylonjs/scene";
  47568. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47569. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47570. import { AbstractScene } from "babylonjs/abstractScene";
  47571. module "babylonjs/abstractScene" {
  47572. interface AbstractScene {
  47573. /**
  47574. * The list of effect layers (highlights/glow) added to the scene
  47575. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47576. * @see http://doc.babylonjs.com/how_to/glow_layer
  47577. */
  47578. effectLayers: Array<EffectLayer>;
  47579. /**
  47580. * Removes the given effect layer from this scene.
  47581. * @param toRemove defines the effect layer to remove
  47582. * @returns the index of the removed effect layer
  47583. */
  47584. removeEffectLayer(toRemove: EffectLayer): number;
  47585. /**
  47586. * Adds the given effect layer to this scene
  47587. * @param newEffectLayer defines the effect layer to add
  47588. */
  47589. addEffectLayer(newEffectLayer: EffectLayer): void;
  47590. }
  47591. }
  47592. /**
  47593. * Defines the layer scene component responsible to manage any effect layers
  47594. * in a given scene.
  47595. */
  47596. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47597. /**
  47598. * The component name helpfull to identify the component in the list of scene components.
  47599. */
  47600. readonly name: string;
  47601. /**
  47602. * The scene the component belongs to.
  47603. */
  47604. scene: Scene;
  47605. private _engine;
  47606. private _renderEffects;
  47607. private _needStencil;
  47608. private _previousStencilState;
  47609. /**
  47610. * Creates a new instance of the component for the given scene
  47611. * @param scene Defines the scene to register the component in
  47612. */
  47613. constructor(scene: Scene);
  47614. /**
  47615. * Registers the component in a given scene
  47616. */
  47617. register(): void;
  47618. /**
  47619. * Rebuilds the elements related to this component in case of
  47620. * context lost for instance.
  47621. */
  47622. rebuild(): void;
  47623. /**
  47624. * Serializes the component data to the specified json object
  47625. * @param serializationObject The object to serialize to
  47626. */
  47627. serialize(serializationObject: any): void;
  47628. /**
  47629. * Adds all the element from the container to the scene
  47630. * @param container the container holding the elements
  47631. */
  47632. addFromContainer(container: AbstractScene): void;
  47633. /**
  47634. * Removes all the elements in the container from the scene
  47635. * @param container contains the elements to remove
  47636. */
  47637. removeFromContainer(container: AbstractScene): void;
  47638. /**
  47639. * Disposes the component and the associated ressources.
  47640. */
  47641. dispose(): void;
  47642. private _isReadyForMesh;
  47643. private _renderMainTexture;
  47644. private _setStencil;
  47645. private _setStencilBack;
  47646. private _draw;
  47647. private _drawCamera;
  47648. private _drawRenderingGroup;
  47649. }
  47650. }
  47651. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47652. /** @hidden */
  47653. export var glowMapMergePixelShader: {
  47654. name: string;
  47655. shader: string;
  47656. };
  47657. }
  47658. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47659. /** @hidden */
  47660. export var glowMapMergeVertexShader: {
  47661. name: string;
  47662. shader: string;
  47663. };
  47664. }
  47665. declare module "babylonjs/Layers/glowLayer" {
  47666. import { Nullable } from "babylonjs/types";
  47667. import { Camera } from "babylonjs/Cameras/camera";
  47668. import { Scene } from "babylonjs/scene";
  47669. import { Color4 } from "babylonjs/Maths/math";
  47670. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47672. import { Mesh } from "babylonjs/Meshes/mesh";
  47673. import { Texture } from "babylonjs/Materials/Textures/texture";
  47674. import { Effect } from "babylonjs/Materials/effect";
  47675. import { Material } from "babylonjs/Materials/material";
  47676. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47677. import "babylonjs/Shaders/glowMapMerge.fragment";
  47678. import "babylonjs/Shaders/glowMapMerge.vertex";
  47679. import "babylonjs/Layers/effectLayerSceneComponent";
  47680. module "babylonjs/abstractScene" {
  47681. interface AbstractScene {
  47682. /**
  47683. * Return a the first highlight layer of the scene with a given name.
  47684. * @param name The name of the highlight layer to look for.
  47685. * @return The highlight layer if found otherwise null.
  47686. */
  47687. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47688. }
  47689. }
  47690. /**
  47691. * Glow layer options. This helps customizing the behaviour
  47692. * of the glow layer.
  47693. */
  47694. export interface IGlowLayerOptions {
  47695. /**
  47696. * Multiplication factor apply to the canvas size to compute the render target size
  47697. * used to generated the glowing objects (the smaller the faster).
  47698. */
  47699. mainTextureRatio: number;
  47700. /**
  47701. * Enforces a fixed size texture to ensure resize independant blur.
  47702. */
  47703. mainTextureFixedSize?: number;
  47704. /**
  47705. * How big is the kernel of the blur texture.
  47706. */
  47707. blurKernelSize: number;
  47708. /**
  47709. * The camera attached to the layer.
  47710. */
  47711. camera: Nullable<Camera>;
  47712. /**
  47713. * Enable MSAA by chosing the number of samples.
  47714. */
  47715. mainTextureSamples?: number;
  47716. /**
  47717. * The rendering group to draw the layer in.
  47718. */
  47719. renderingGroupId: number;
  47720. }
  47721. /**
  47722. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47723. *
  47724. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47725. * glowy meshes to your scene.
  47726. *
  47727. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47728. */
  47729. export class GlowLayer extends EffectLayer {
  47730. /**
  47731. * Effect Name of the layer.
  47732. */
  47733. static readonly EffectName: string;
  47734. /**
  47735. * The default blur kernel size used for the glow.
  47736. */
  47737. static DefaultBlurKernelSize: number;
  47738. /**
  47739. * The default texture size ratio used for the glow.
  47740. */
  47741. static DefaultTextureRatio: number;
  47742. /**
  47743. * Sets the kernel size of the blur.
  47744. */
  47745. /**
  47746. * Gets the kernel size of the blur.
  47747. */
  47748. blurKernelSize: number;
  47749. /**
  47750. * Sets the glow intensity.
  47751. */
  47752. /**
  47753. * Gets the glow intensity.
  47754. */
  47755. intensity: number;
  47756. private _options;
  47757. private _intensity;
  47758. private _horizontalBlurPostprocess1;
  47759. private _verticalBlurPostprocess1;
  47760. private _horizontalBlurPostprocess2;
  47761. private _verticalBlurPostprocess2;
  47762. private _blurTexture1;
  47763. private _blurTexture2;
  47764. private _postProcesses1;
  47765. private _postProcesses2;
  47766. private _includedOnlyMeshes;
  47767. private _excludedMeshes;
  47768. /**
  47769. * Callback used to let the user override the color selection on a per mesh basis
  47770. */
  47771. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47772. /**
  47773. * Callback used to let the user override the texture selection on a per mesh basis
  47774. */
  47775. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47776. /**
  47777. * Instantiates a new glow Layer and references it to the scene.
  47778. * @param name The name of the layer
  47779. * @param scene The scene to use the layer in
  47780. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47781. */
  47782. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47783. /**
  47784. * Get the effect name of the layer.
  47785. * @return The effect name
  47786. */
  47787. getEffectName(): string;
  47788. /**
  47789. * Create the merge effect. This is the shader use to blit the information back
  47790. * to the main canvas at the end of the scene rendering.
  47791. */
  47792. protected _createMergeEffect(): Effect;
  47793. /**
  47794. * Creates the render target textures and post processes used in the glow layer.
  47795. */
  47796. protected _createTextureAndPostProcesses(): void;
  47797. /**
  47798. * Checks for the readiness of the element composing the layer.
  47799. * @param subMesh the mesh to check for
  47800. * @param useInstances specify wether or not to use instances to render the mesh
  47801. * @param emissiveTexture the associated emissive texture used to generate the glow
  47802. * @return true if ready otherwise, false
  47803. */
  47804. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47805. /**
  47806. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47807. */
  47808. needStencil(): boolean;
  47809. /**
  47810. * Returns true if the mesh can be rendered, otherwise false.
  47811. * @param mesh The mesh to render
  47812. * @param material The material used on the mesh
  47813. * @returns true if it can be rendered otherwise false
  47814. */
  47815. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47816. /**
  47817. * Implementation specific of rendering the generating effect on the main canvas.
  47818. * @param effect The effect used to render through
  47819. */
  47820. protected _internalRender(effect: Effect): void;
  47821. /**
  47822. * Sets the required values for both the emissive texture and and the main color.
  47823. */
  47824. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47825. /**
  47826. * Returns true if the mesh should render, otherwise false.
  47827. * @param mesh The mesh to render
  47828. * @returns true if it should render otherwise false
  47829. */
  47830. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47831. /**
  47832. * Adds specific effects defines.
  47833. * @param defines The defines to add specifics to.
  47834. */
  47835. protected _addCustomEffectDefines(defines: string[]): void;
  47836. /**
  47837. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47838. * @param mesh The mesh to exclude from the glow layer
  47839. */
  47840. addExcludedMesh(mesh: Mesh): void;
  47841. /**
  47842. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47843. * @param mesh The mesh to remove
  47844. */
  47845. removeExcludedMesh(mesh: Mesh): void;
  47846. /**
  47847. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47848. * @param mesh The mesh to include in the glow layer
  47849. */
  47850. addIncludedOnlyMesh(mesh: Mesh): void;
  47851. /**
  47852. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47853. * @param mesh The mesh to remove
  47854. */
  47855. removeIncludedOnlyMesh(mesh: Mesh): void;
  47856. /**
  47857. * Determine if a given mesh will be used in the glow layer
  47858. * @param mesh The mesh to test
  47859. * @returns true if the mesh will be highlighted by the current glow layer
  47860. */
  47861. hasMesh(mesh: AbstractMesh): boolean;
  47862. /**
  47863. * Free any resources and references associated to a mesh.
  47864. * Internal use
  47865. * @param mesh The mesh to free.
  47866. * @hidden
  47867. */
  47868. _disposeMesh(mesh: Mesh): void;
  47869. /**
  47870. * Gets the class name of the effect layer
  47871. * @returns the string with the class name of the effect layer
  47872. */
  47873. getClassName(): string;
  47874. /**
  47875. * Serializes this glow layer
  47876. * @returns a serialized glow layer object
  47877. */
  47878. serialize(): any;
  47879. /**
  47880. * Creates a Glow Layer from parsed glow layer data
  47881. * @param parsedGlowLayer defines glow layer data
  47882. * @param scene defines the current scene
  47883. * @param rootUrl defines the root URL containing the glow layer information
  47884. * @returns a parsed Glow Layer
  47885. */
  47886. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47887. }
  47888. }
  47889. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47890. /** @hidden */
  47891. export var glowBlurPostProcessPixelShader: {
  47892. name: string;
  47893. shader: string;
  47894. };
  47895. }
  47896. declare module "babylonjs/Layers/highlightLayer" {
  47897. import { Observable } from "babylonjs/Misc/observable";
  47898. import { Nullable } from "babylonjs/types";
  47899. import { Camera } from "babylonjs/Cameras/camera";
  47900. import { Scene } from "babylonjs/scene";
  47901. import { Color3, Color4 } from "babylonjs/Maths/math";
  47902. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47904. import { Mesh } from "babylonjs/Meshes/mesh";
  47905. import { Effect } from "babylonjs/Materials/effect";
  47906. import { Material } from "babylonjs/Materials/material";
  47907. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47908. import "babylonjs/Shaders/glowMapMerge.fragment";
  47909. import "babylonjs/Shaders/glowMapMerge.vertex";
  47910. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47911. module "babylonjs/abstractScene" {
  47912. interface AbstractScene {
  47913. /**
  47914. * Return a the first highlight layer of the scene with a given name.
  47915. * @param name The name of the highlight layer to look for.
  47916. * @return The highlight layer if found otherwise null.
  47917. */
  47918. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47919. }
  47920. }
  47921. /**
  47922. * Highlight layer options. This helps customizing the behaviour
  47923. * of the highlight layer.
  47924. */
  47925. export interface IHighlightLayerOptions {
  47926. /**
  47927. * Multiplication factor apply to the canvas size to compute the render target size
  47928. * used to generated the glowing objects (the smaller the faster).
  47929. */
  47930. mainTextureRatio: number;
  47931. /**
  47932. * Enforces a fixed size texture to ensure resize independant blur.
  47933. */
  47934. mainTextureFixedSize?: number;
  47935. /**
  47936. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47937. * of the picture to blur (the smaller the faster).
  47938. */
  47939. blurTextureSizeRatio: number;
  47940. /**
  47941. * How big in texel of the blur texture is the vertical blur.
  47942. */
  47943. blurVerticalSize: number;
  47944. /**
  47945. * How big in texel of the blur texture is the horizontal blur.
  47946. */
  47947. blurHorizontalSize: number;
  47948. /**
  47949. * Alpha blending mode used to apply the blur. Default is combine.
  47950. */
  47951. alphaBlendingMode: number;
  47952. /**
  47953. * The camera attached to the layer.
  47954. */
  47955. camera: Nullable<Camera>;
  47956. /**
  47957. * Should we display highlight as a solid stroke?
  47958. */
  47959. isStroke?: boolean;
  47960. /**
  47961. * The rendering group to draw the layer in.
  47962. */
  47963. renderingGroupId: number;
  47964. }
  47965. /**
  47966. * The highlight layer Helps adding a glow effect around a mesh.
  47967. *
  47968. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47969. * glowy meshes to your scene.
  47970. *
  47971. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47972. */
  47973. export class HighlightLayer extends EffectLayer {
  47974. name: string;
  47975. /**
  47976. * Effect Name of the highlight layer.
  47977. */
  47978. static readonly EffectName: string;
  47979. /**
  47980. * The neutral color used during the preparation of the glow effect.
  47981. * This is black by default as the blend operation is a blend operation.
  47982. */
  47983. static NeutralColor: Color4;
  47984. /**
  47985. * Stencil value used for glowing meshes.
  47986. */
  47987. static GlowingMeshStencilReference: number;
  47988. /**
  47989. * Stencil value used for the other meshes in the scene.
  47990. */
  47991. static NormalMeshStencilReference: number;
  47992. /**
  47993. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47994. */
  47995. innerGlow: boolean;
  47996. /**
  47997. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47998. */
  47999. outerGlow: boolean;
  48000. /**
  48001. * Specifies the horizontal size of the blur.
  48002. */
  48003. /**
  48004. * Gets the horizontal size of the blur.
  48005. */
  48006. blurHorizontalSize: number;
  48007. /**
  48008. * Specifies the vertical size of the blur.
  48009. */
  48010. /**
  48011. * Gets the vertical size of the blur.
  48012. */
  48013. blurVerticalSize: number;
  48014. /**
  48015. * An event triggered when the highlight layer is being blurred.
  48016. */
  48017. onBeforeBlurObservable: Observable<HighlightLayer>;
  48018. /**
  48019. * An event triggered when the highlight layer has been blurred.
  48020. */
  48021. onAfterBlurObservable: Observable<HighlightLayer>;
  48022. private _instanceGlowingMeshStencilReference;
  48023. private _options;
  48024. private _downSamplePostprocess;
  48025. private _horizontalBlurPostprocess;
  48026. private _verticalBlurPostprocess;
  48027. private _blurTexture;
  48028. private _meshes;
  48029. private _excludedMeshes;
  48030. /**
  48031. * Instantiates a new highlight Layer and references it to the scene..
  48032. * @param name The name of the layer
  48033. * @param scene The scene to use the layer in
  48034. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48035. */
  48036. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48037. /**
  48038. * Get the effect name of the layer.
  48039. * @return The effect name
  48040. */
  48041. getEffectName(): string;
  48042. /**
  48043. * Create the merge effect. This is the shader use to blit the information back
  48044. * to the main canvas at the end of the scene rendering.
  48045. */
  48046. protected _createMergeEffect(): Effect;
  48047. /**
  48048. * Creates the render target textures and post processes used in the highlight layer.
  48049. */
  48050. protected _createTextureAndPostProcesses(): void;
  48051. /**
  48052. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48053. */
  48054. needStencil(): boolean;
  48055. /**
  48056. * Checks for the readiness of the element composing the layer.
  48057. * @param subMesh the mesh to check for
  48058. * @param useInstances specify wether or not to use instances to render the mesh
  48059. * @param emissiveTexture the associated emissive texture used to generate the glow
  48060. * @return true if ready otherwise, false
  48061. */
  48062. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48063. /**
  48064. * Implementation specific of rendering the generating effect on the main canvas.
  48065. * @param effect The effect used to render through
  48066. */
  48067. protected _internalRender(effect: Effect): void;
  48068. /**
  48069. * Returns true if the layer contains information to display, otherwise false.
  48070. */
  48071. shouldRender(): boolean;
  48072. /**
  48073. * Returns true if the mesh should render, otherwise false.
  48074. * @param mesh The mesh to render
  48075. * @returns true if it should render otherwise false
  48076. */
  48077. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48078. /**
  48079. * Sets the required values for both the emissive texture and and the main color.
  48080. */
  48081. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48082. /**
  48083. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48084. * @param mesh The mesh to exclude from the highlight layer
  48085. */
  48086. addExcludedMesh(mesh: Mesh): void;
  48087. /**
  48088. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48089. * @param mesh The mesh to highlight
  48090. */
  48091. removeExcludedMesh(mesh: Mesh): void;
  48092. /**
  48093. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48094. * @param mesh mesh to test
  48095. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48096. */
  48097. hasMesh(mesh: AbstractMesh): boolean;
  48098. /**
  48099. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48100. * @param mesh The mesh to highlight
  48101. * @param color The color of the highlight
  48102. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48103. */
  48104. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48105. /**
  48106. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48107. * @param mesh The mesh to highlight
  48108. */
  48109. removeMesh(mesh: Mesh): void;
  48110. /**
  48111. * Force the stencil to the normal expected value for none glowing parts
  48112. */
  48113. private _defaultStencilReference;
  48114. /**
  48115. * Free any resources and references associated to a mesh.
  48116. * Internal use
  48117. * @param mesh The mesh to free.
  48118. * @hidden
  48119. */
  48120. _disposeMesh(mesh: Mesh): void;
  48121. /**
  48122. * Dispose the highlight layer and free resources.
  48123. */
  48124. dispose(): void;
  48125. /**
  48126. * Gets the class name of the effect layer
  48127. * @returns the string with the class name of the effect layer
  48128. */
  48129. getClassName(): string;
  48130. /**
  48131. * Serializes this Highlight layer
  48132. * @returns a serialized Highlight layer object
  48133. */
  48134. serialize(): any;
  48135. /**
  48136. * Creates a Highlight layer from parsed Highlight layer data
  48137. * @param parsedHightlightLayer defines the Highlight layer data
  48138. * @param scene defines the current scene
  48139. * @param rootUrl defines the root URL containing the Highlight layer information
  48140. * @returns a parsed Highlight layer
  48141. */
  48142. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48143. }
  48144. }
  48145. declare module "babylonjs/Layers/index" {
  48146. export * from "babylonjs/Layers/effectLayer";
  48147. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48148. export * from "babylonjs/Layers/glowLayer";
  48149. export * from "babylonjs/Layers/highlightLayer";
  48150. export * from "babylonjs/Layers/layer";
  48151. export * from "babylonjs/Layers/layerSceneComponent";
  48152. }
  48153. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48154. /** @hidden */
  48155. export var lensFlarePixelShader: {
  48156. name: string;
  48157. shader: string;
  48158. };
  48159. }
  48160. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48161. /** @hidden */
  48162. export var lensFlareVertexShader: {
  48163. name: string;
  48164. shader: string;
  48165. };
  48166. }
  48167. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48168. import { Scene } from "babylonjs/scene";
  48169. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48171. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48172. import "babylonjs/Shaders/lensFlare.fragment";
  48173. import "babylonjs/Shaders/lensFlare.vertex";
  48174. /**
  48175. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48176. * It is usually composed of several `lensFlare`.
  48177. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48178. */
  48179. export class LensFlareSystem {
  48180. /**
  48181. * Define the name of the lens flare system
  48182. */
  48183. name: string;
  48184. /**
  48185. * List of lens flares used in this system.
  48186. */
  48187. lensFlares: LensFlare[];
  48188. /**
  48189. * Define a limit from the border the lens flare can be visible.
  48190. */
  48191. borderLimit: number;
  48192. /**
  48193. * Define a viewport border we do not want to see the lens flare in.
  48194. */
  48195. viewportBorder: number;
  48196. /**
  48197. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48198. */
  48199. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48200. /**
  48201. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48202. */
  48203. layerMask: number;
  48204. /**
  48205. * Define the id of the lens flare system in the scene.
  48206. * (equal to name by default)
  48207. */
  48208. id: string;
  48209. private _scene;
  48210. private _emitter;
  48211. private _vertexBuffers;
  48212. private _indexBuffer;
  48213. private _effect;
  48214. private _positionX;
  48215. private _positionY;
  48216. private _isEnabled;
  48217. /** @hidden */
  48218. static _SceneComponentInitialization: (scene: Scene) => void;
  48219. /**
  48220. * Instantiates a lens flare system.
  48221. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48222. * It is usually composed of several `lensFlare`.
  48223. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48224. * @param name Define the name of the lens flare system in the scene
  48225. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48226. * @param scene Define the scene the lens flare system belongs to
  48227. */
  48228. constructor(
  48229. /**
  48230. * Define the name of the lens flare system
  48231. */
  48232. name: string, emitter: any, scene: Scene);
  48233. /**
  48234. * Define if the lens flare system is enabled.
  48235. */
  48236. isEnabled: boolean;
  48237. /**
  48238. * Get the scene the effects belongs to.
  48239. * @returns the scene holding the lens flare system
  48240. */
  48241. getScene(): Scene;
  48242. /**
  48243. * Get the emitter of the lens flare system.
  48244. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48245. * @returns the emitter of the lens flare system
  48246. */
  48247. getEmitter(): any;
  48248. /**
  48249. * Set the emitter of the lens flare system.
  48250. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48251. * @param newEmitter Define the new emitter of the system
  48252. */
  48253. setEmitter(newEmitter: any): void;
  48254. /**
  48255. * Get the lens flare system emitter position.
  48256. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48257. * @returns the position
  48258. */
  48259. getEmitterPosition(): Vector3;
  48260. /**
  48261. * @hidden
  48262. */
  48263. computeEffectivePosition(globalViewport: Viewport): boolean;
  48264. /** @hidden */
  48265. _isVisible(): boolean;
  48266. /**
  48267. * @hidden
  48268. */
  48269. render(): boolean;
  48270. /**
  48271. * Dispose and release the lens flare with its associated resources.
  48272. */
  48273. dispose(): void;
  48274. /**
  48275. * Parse a lens flare system from a JSON repressentation
  48276. * @param parsedLensFlareSystem Define the JSON to parse
  48277. * @param scene Define the scene the parsed system should be instantiated in
  48278. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48279. * @returns the parsed system
  48280. */
  48281. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48282. /**
  48283. * Serialize the current Lens Flare System into a JSON representation.
  48284. * @returns the serialized JSON
  48285. */
  48286. serialize(): any;
  48287. }
  48288. }
  48289. declare module "babylonjs/LensFlares/lensFlare" {
  48290. import { Nullable } from "babylonjs/types";
  48291. import { Color3 } from "babylonjs/Maths/math";
  48292. import { Texture } from "babylonjs/Materials/Textures/texture";
  48293. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48294. /**
  48295. * This represents one of the lens effect in a `lensFlareSystem`.
  48296. * It controls one of the indiviual texture used in the effect.
  48297. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48298. */
  48299. export class LensFlare {
  48300. /**
  48301. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48302. */
  48303. size: number;
  48304. /**
  48305. * 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.
  48306. */
  48307. position: number;
  48308. /**
  48309. * Define the lens color.
  48310. */
  48311. color: Color3;
  48312. /**
  48313. * Define the lens texture.
  48314. */
  48315. texture: Nullable<Texture>;
  48316. /**
  48317. * Define the alpha mode to render this particular lens.
  48318. */
  48319. alphaMode: number;
  48320. private _system;
  48321. /**
  48322. * Creates a new Lens Flare.
  48323. * This represents one of the lens effect in a `lensFlareSystem`.
  48324. * It controls one of the indiviual texture used in the effect.
  48325. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48326. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48327. * @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.
  48328. * @param color Define the lens color
  48329. * @param imgUrl Define the lens texture url
  48330. * @param system Define the `lensFlareSystem` this flare is part of
  48331. * @returns The newly created Lens Flare
  48332. */
  48333. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48334. /**
  48335. * Instantiates a new Lens Flare.
  48336. * This represents one of the lens effect in a `lensFlareSystem`.
  48337. * It controls one of the indiviual texture used in the effect.
  48338. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48339. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48340. * @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.
  48341. * @param color Define the lens color
  48342. * @param imgUrl Define the lens texture url
  48343. * @param system Define the `lensFlareSystem` this flare is part of
  48344. */
  48345. constructor(
  48346. /**
  48347. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48348. */
  48349. size: number,
  48350. /**
  48351. * 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.
  48352. */
  48353. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48354. /**
  48355. * Dispose and release the lens flare with its associated resources.
  48356. */
  48357. dispose(): void;
  48358. }
  48359. }
  48360. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48361. import { Nullable } from "babylonjs/types";
  48362. import { Scene } from "babylonjs/scene";
  48363. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48364. import { AbstractScene } from "babylonjs/abstractScene";
  48365. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48366. module "babylonjs/abstractScene" {
  48367. interface AbstractScene {
  48368. /**
  48369. * The list of lens flare system added to the scene
  48370. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48371. */
  48372. lensFlareSystems: Array<LensFlareSystem>;
  48373. /**
  48374. * Removes the given lens flare system from this scene.
  48375. * @param toRemove The lens flare system to remove
  48376. * @returns The index of the removed lens flare system
  48377. */
  48378. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48379. /**
  48380. * Adds the given lens flare system to this scene
  48381. * @param newLensFlareSystem The lens flare system to add
  48382. */
  48383. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48384. /**
  48385. * Gets a lens flare system using its name
  48386. * @param name defines the name to look for
  48387. * @returns the lens flare system or null if not found
  48388. */
  48389. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48390. /**
  48391. * Gets a lens flare system using its id
  48392. * @param id defines the id to look for
  48393. * @returns the lens flare system or null if not found
  48394. */
  48395. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48396. }
  48397. }
  48398. /**
  48399. * Defines the lens flare scene component responsible to manage any lens flares
  48400. * in a given scene.
  48401. */
  48402. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48403. /**
  48404. * The component name helpfull to identify the component in the list of scene components.
  48405. */
  48406. readonly name: string;
  48407. /**
  48408. * The scene the component belongs to.
  48409. */
  48410. scene: Scene;
  48411. /**
  48412. * Creates a new instance of the component for the given scene
  48413. * @param scene Defines the scene to register the component in
  48414. */
  48415. constructor(scene: Scene);
  48416. /**
  48417. * Registers the component in a given scene
  48418. */
  48419. register(): void;
  48420. /**
  48421. * Rebuilds the elements related to this component in case of
  48422. * context lost for instance.
  48423. */
  48424. rebuild(): void;
  48425. /**
  48426. * Adds all the element from the container to the scene
  48427. * @param container the container holding the elements
  48428. */
  48429. addFromContainer(container: AbstractScene): void;
  48430. /**
  48431. * Removes all the elements in the container from the scene
  48432. * @param container contains the elements to remove
  48433. */
  48434. removeFromContainer(container: AbstractScene): void;
  48435. /**
  48436. * Serializes the component data to the specified json object
  48437. * @param serializationObject The object to serialize to
  48438. */
  48439. serialize(serializationObject: any): void;
  48440. /**
  48441. * Disposes the component and the associated ressources.
  48442. */
  48443. dispose(): void;
  48444. private _draw;
  48445. }
  48446. }
  48447. declare module "babylonjs/LensFlares/index" {
  48448. export * from "babylonjs/LensFlares/lensFlare";
  48449. export * from "babylonjs/LensFlares/lensFlareSystem";
  48450. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48451. }
  48452. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48453. import { Scene } from "babylonjs/scene";
  48454. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48455. import { AbstractScene } from "babylonjs/abstractScene";
  48456. /**
  48457. * Defines the shadow generator component responsible to manage any shadow generators
  48458. * in a given scene.
  48459. */
  48460. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48461. /**
  48462. * The component name helpfull to identify the component in the list of scene components.
  48463. */
  48464. readonly name: string;
  48465. /**
  48466. * The scene the component belongs to.
  48467. */
  48468. scene: Scene;
  48469. /**
  48470. * Creates a new instance of the component for the given scene
  48471. * @param scene Defines the scene to register the component in
  48472. */
  48473. constructor(scene: Scene);
  48474. /**
  48475. * Registers the component in a given scene
  48476. */
  48477. register(): void;
  48478. /**
  48479. * Rebuilds the elements related to this component in case of
  48480. * context lost for instance.
  48481. */
  48482. rebuild(): void;
  48483. /**
  48484. * Serializes the component data to the specified json object
  48485. * @param serializationObject The object to serialize to
  48486. */
  48487. serialize(serializationObject: any): void;
  48488. /**
  48489. * Adds all the element from the container to the scene
  48490. * @param container the container holding the elements
  48491. */
  48492. addFromContainer(container: AbstractScene): void;
  48493. /**
  48494. * Removes all the elements in the container from the scene
  48495. * @param container contains the elements to remove
  48496. */
  48497. removeFromContainer(container: AbstractScene): void;
  48498. /**
  48499. * Rebuilds the elements related to this component in case of
  48500. * context lost for instance.
  48501. */
  48502. dispose(): void;
  48503. private _gatherRenderTargets;
  48504. }
  48505. }
  48506. declare module "babylonjs/Lights/Shadows/index" {
  48507. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48508. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48509. }
  48510. declare module "babylonjs/Lights/directionalLight" {
  48511. import { Camera } from "babylonjs/Cameras/camera";
  48512. import { Scene } from "babylonjs/scene";
  48513. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48515. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48516. import { Effect } from "babylonjs/Materials/effect";
  48517. /**
  48518. * A directional light is defined by a direction (what a surprise!).
  48519. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48520. * 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.
  48521. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48522. */
  48523. export class DirectionalLight extends ShadowLight {
  48524. private _shadowFrustumSize;
  48525. /**
  48526. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48527. */
  48528. /**
  48529. * Specifies a fix frustum size for the shadow generation.
  48530. */
  48531. shadowFrustumSize: number;
  48532. private _shadowOrthoScale;
  48533. /**
  48534. * Gets the shadow projection scale against the optimal computed one.
  48535. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48536. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48537. */
  48538. /**
  48539. * Sets the shadow projection scale against the optimal computed one.
  48540. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48541. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48542. */
  48543. shadowOrthoScale: number;
  48544. /**
  48545. * Automatically compute the projection matrix to best fit (including all the casters)
  48546. * on each frame.
  48547. */
  48548. autoUpdateExtends: boolean;
  48549. private _orthoLeft;
  48550. private _orthoRight;
  48551. private _orthoTop;
  48552. private _orthoBottom;
  48553. /**
  48554. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48555. * The directional light is emitted from everywhere in the given direction.
  48556. * It can cast shadows.
  48557. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48558. * @param name The friendly name of the light
  48559. * @param direction The direction of the light
  48560. * @param scene The scene the light belongs to
  48561. */
  48562. constructor(name: string, direction: Vector3, scene: Scene);
  48563. /**
  48564. * Returns the string "DirectionalLight".
  48565. * @return The class name
  48566. */
  48567. getClassName(): string;
  48568. /**
  48569. * Returns the integer 1.
  48570. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48571. */
  48572. getTypeID(): number;
  48573. /**
  48574. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48575. * Returns the DirectionalLight Shadow projection matrix.
  48576. */
  48577. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48578. /**
  48579. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48580. * Returns the DirectionalLight Shadow projection matrix.
  48581. */
  48582. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48583. /**
  48584. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48585. * Returns the DirectionalLight Shadow projection matrix.
  48586. */
  48587. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48588. protected _buildUniformLayout(): void;
  48589. /**
  48590. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48591. * @param effect The effect to update
  48592. * @param lightIndex The index of the light in the effect to update
  48593. * @returns The directional light
  48594. */
  48595. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48596. /**
  48597. * Gets the minZ used for shadow according to both the scene and the light.
  48598. *
  48599. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48600. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48601. * @param activeCamera The camera we are returning the min for
  48602. * @returns the depth min z
  48603. */
  48604. getDepthMinZ(activeCamera: Camera): number;
  48605. /**
  48606. * Gets the maxZ used for shadow according to both the scene and the light.
  48607. *
  48608. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48609. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48610. * @param activeCamera The camera we are returning the max for
  48611. * @returns the depth max z
  48612. */
  48613. getDepthMaxZ(activeCamera: Camera): number;
  48614. /**
  48615. * Prepares the list of defines specific to the light type.
  48616. * @param defines the list of defines
  48617. * @param lightIndex defines the index of the light for the effect
  48618. */
  48619. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48620. }
  48621. }
  48622. declare module "babylonjs/Lights/pointLight" {
  48623. import { Scene } from "babylonjs/scene";
  48624. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48626. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48627. import { Effect } from "babylonjs/Materials/effect";
  48628. /**
  48629. * A point light is a light defined by an unique point in world space.
  48630. * The light is emitted in every direction from this point.
  48631. * A good example of a point light is a standard light bulb.
  48632. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48633. */
  48634. export class PointLight extends ShadowLight {
  48635. private _shadowAngle;
  48636. /**
  48637. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48638. * This specifies what angle the shadow will use to be created.
  48639. *
  48640. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48641. */
  48642. /**
  48643. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48644. * This specifies what angle the shadow will use to be created.
  48645. *
  48646. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48647. */
  48648. shadowAngle: number;
  48649. /**
  48650. * Gets the direction if it has been set.
  48651. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48652. */
  48653. /**
  48654. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48655. */
  48656. direction: Vector3;
  48657. /**
  48658. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48659. * A PointLight emits the light in every direction.
  48660. * It can cast shadows.
  48661. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48662. * ```javascript
  48663. * var pointLight = new PointLight("pl", camera.position, scene);
  48664. * ```
  48665. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48666. * @param name The light friendly name
  48667. * @param position The position of the point light in the scene
  48668. * @param scene The scene the lights belongs to
  48669. */
  48670. constructor(name: string, position: Vector3, scene: Scene);
  48671. /**
  48672. * Returns the string "PointLight"
  48673. * @returns the class name
  48674. */
  48675. getClassName(): string;
  48676. /**
  48677. * Returns the integer 0.
  48678. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48679. */
  48680. getTypeID(): number;
  48681. /**
  48682. * Specifies wether or not the shadowmap should be a cube texture.
  48683. * @returns true if the shadowmap needs to be a cube texture.
  48684. */
  48685. needCube(): boolean;
  48686. /**
  48687. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48688. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48689. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48690. */
  48691. getShadowDirection(faceIndex?: number): Vector3;
  48692. /**
  48693. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48694. * - fov = PI / 2
  48695. * - aspect ratio : 1.0
  48696. * - z-near and far equal to the active camera minZ and maxZ.
  48697. * Returns the PointLight.
  48698. */
  48699. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48700. protected _buildUniformLayout(): void;
  48701. /**
  48702. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48703. * @param effect The effect to update
  48704. * @param lightIndex The index of the light in the effect to update
  48705. * @returns The point light
  48706. */
  48707. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48708. /**
  48709. * Prepares the list of defines specific to the light type.
  48710. * @param defines the list of defines
  48711. * @param lightIndex defines the index of the light for the effect
  48712. */
  48713. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48714. }
  48715. }
  48716. declare module "babylonjs/Lights/spotLight" {
  48717. import { Nullable } from "babylonjs/types";
  48718. import { Scene } from "babylonjs/scene";
  48719. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48720. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48721. import { Effect } from "babylonjs/Materials/effect";
  48722. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48723. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48724. /**
  48725. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48726. * These values define a cone of light starting from the position, emitting toward the direction.
  48727. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48728. * and the exponent defines the speed of the decay of the light with distance (reach).
  48729. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48730. */
  48731. export class SpotLight extends ShadowLight {
  48732. private _angle;
  48733. private _innerAngle;
  48734. private _cosHalfAngle;
  48735. private _lightAngleScale;
  48736. private _lightAngleOffset;
  48737. /**
  48738. * Gets the cone angle of the spot light in Radians.
  48739. */
  48740. /**
  48741. * Sets the cone angle of the spot light in Radians.
  48742. */
  48743. angle: number;
  48744. /**
  48745. * Only used in gltf falloff mode, this defines the angle where
  48746. * the directional falloff will start before cutting at angle which could be seen
  48747. * as outer angle.
  48748. */
  48749. /**
  48750. * Only used in gltf falloff mode, this defines the angle where
  48751. * the directional falloff will start before cutting at angle which could be seen
  48752. * as outer angle.
  48753. */
  48754. innerAngle: number;
  48755. private _shadowAngleScale;
  48756. /**
  48757. * Allows scaling the angle of the light for shadow generation only.
  48758. */
  48759. /**
  48760. * Allows scaling the angle of the light for shadow generation only.
  48761. */
  48762. shadowAngleScale: number;
  48763. /**
  48764. * The light decay speed with the distance from the emission spot.
  48765. */
  48766. exponent: number;
  48767. private _projectionTextureMatrix;
  48768. /**
  48769. * Allows reading the projecton texture
  48770. */
  48771. readonly projectionTextureMatrix: Matrix;
  48772. protected _projectionTextureLightNear: number;
  48773. /**
  48774. * Gets the near clip of the Spotlight for texture projection.
  48775. */
  48776. /**
  48777. * Sets the near clip of the Spotlight for texture projection.
  48778. */
  48779. projectionTextureLightNear: number;
  48780. protected _projectionTextureLightFar: number;
  48781. /**
  48782. * Gets the far clip of the Spotlight for texture projection.
  48783. */
  48784. /**
  48785. * Sets the far clip of the Spotlight for texture projection.
  48786. */
  48787. projectionTextureLightFar: number;
  48788. protected _projectionTextureUpDirection: Vector3;
  48789. /**
  48790. * Gets the Up vector of the Spotlight for texture projection.
  48791. */
  48792. /**
  48793. * Sets the Up vector of the Spotlight for texture projection.
  48794. */
  48795. projectionTextureUpDirection: Vector3;
  48796. private _projectionTexture;
  48797. /**
  48798. * Gets the projection texture of the light.
  48799. */
  48800. /**
  48801. * Sets the projection texture of the light.
  48802. */
  48803. projectionTexture: Nullable<BaseTexture>;
  48804. private _projectionTextureViewLightDirty;
  48805. private _projectionTextureProjectionLightDirty;
  48806. private _projectionTextureDirty;
  48807. private _projectionTextureViewTargetVector;
  48808. private _projectionTextureViewLightMatrix;
  48809. private _projectionTextureProjectionLightMatrix;
  48810. private _projectionTextureScalingMatrix;
  48811. /**
  48812. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48813. * It can cast shadows.
  48814. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48815. * @param name The light friendly name
  48816. * @param position The position of the spot light in the scene
  48817. * @param direction The direction of the light in the scene
  48818. * @param angle The cone angle of the light in Radians
  48819. * @param exponent The light decay speed with the distance from the emission spot
  48820. * @param scene The scene the lights belongs to
  48821. */
  48822. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48823. /**
  48824. * Returns the string "SpotLight".
  48825. * @returns the class name
  48826. */
  48827. getClassName(): string;
  48828. /**
  48829. * Returns the integer 2.
  48830. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48831. */
  48832. getTypeID(): number;
  48833. /**
  48834. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48835. */
  48836. protected _setDirection(value: Vector3): void;
  48837. /**
  48838. * Overrides the position setter to recompute the projection texture view light Matrix.
  48839. */
  48840. protected _setPosition(value: Vector3): void;
  48841. /**
  48842. * 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.
  48843. * Returns the SpotLight.
  48844. */
  48845. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48846. protected _computeProjectionTextureViewLightMatrix(): void;
  48847. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48848. /**
  48849. * Main function for light texture projection matrix computing.
  48850. */
  48851. protected _computeProjectionTextureMatrix(): void;
  48852. protected _buildUniformLayout(): void;
  48853. private _computeAngleValues;
  48854. /**
  48855. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48856. * @param effect The effect to update
  48857. * @param lightIndex The index of the light in the effect to update
  48858. * @returns The spot light
  48859. */
  48860. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48861. /**
  48862. * Disposes the light and the associated resources.
  48863. */
  48864. dispose(): void;
  48865. /**
  48866. * Prepares the list of defines specific to the light type.
  48867. * @param defines the list of defines
  48868. * @param lightIndex defines the index of the light for the effect
  48869. */
  48870. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48871. }
  48872. }
  48873. declare module "babylonjs/Lights/index" {
  48874. export * from "babylonjs/Lights/light";
  48875. export * from "babylonjs/Lights/shadowLight";
  48876. export * from "babylonjs/Lights/Shadows/index";
  48877. export * from "babylonjs/Lights/directionalLight";
  48878. export * from "babylonjs/Lights/hemisphericLight";
  48879. export * from "babylonjs/Lights/pointLight";
  48880. export * from "babylonjs/Lights/spotLight";
  48881. }
  48882. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48883. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48884. /**
  48885. * Header information of HDR texture files.
  48886. */
  48887. export interface HDRInfo {
  48888. /**
  48889. * The height of the texture in pixels.
  48890. */
  48891. height: number;
  48892. /**
  48893. * The width of the texture in pixels.
  48894. */
  48895. width: number;
  48896. /**
  48897. * The index of the beginning of the data in the binary file.
  48898. */
  48899. dataPosition: number;
  48900. }
  48901. /**
  48902. * This groups tools to convert HDR texture to native colors array.
  48903. */
  48904. export class HDRTools {
  48905. private static Ldexp;
  48906. private static Rgbe2float;
  48907. private static readStringLine;
  48908. /**
  48909. * Reads header information from an RGBE texture stored in a native array.
  48910. * More information on this format are available here:
  48911. * https://en.wikipedia.org/wiki/RGBE_image_format
  48912. *
  48913. * @param uint8array The binary file stored in native array.
  48914. * @return The header information.
  48915. */
  48916. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48917. /**
  48918. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48919. * This RGBE texture needs to store the information as a panorama.
  48920. *
  48921. * More information on this format are available here:
  48922. * https://en.wikipedia.org/wiki/RGBE_image_format
  48923. *
  48924. * @param buffer The binary file stored in an array buffer.
  48925. * @param size The expected size of the extracted cubemap.
  48926. * @return The Cube Map information.
  48927. */
  48928. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48929. /**
  48930. * Returns the pixels data extracted from an RGBE texture.
  48931. * This pixels will be stored left to right up to down in the R G B order in one array.
  48932. *
  48933. * More information on this format are available here:
  48934. * https://en.wikipedia.org/wiki/RGBE_image_format
  48935. *
  48936. * @param uint8array The binary file stored in an array buffer.
  48937. * @param hdrInfo The header information of the file.
  48938. * @return The pixels data in RGB right to left up to down order.
  48939. */
  48940. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48941. private static RGBE_ReadPixels_RLE;
  48942. }
  48943. }
  48944. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48945. import { Nullable } from "babylonjs/types";
  48946. import { Scene } from "babylonjs/scene";
  48947. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48948. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48949. /**
  48950. * This represents a texture coming from an HDR input.
  48951. *
  48952. * The only supported format is currently panorama picture stored in RGBE format.
  48953. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48954. */
  48955. export class HDRCubeTexture extends BaseTexture {
  48956. private static _facesMapping;
  48957. private _generateHarmonics;
  48958. private _noMipmap;
  48959. private _textureMatrix;
  48960. private _size;
  48961. private _onLoad;
  48962. private _onError;
  48963. /**
  48964. * The texture URL.
  48965. */
  48966. url: string;
  48967. /**
  48968. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48969. */
  48970. coordinatesMode: number;
  48971. protected _isBlocking: boolean;
  48972. /**
  48973. * Sets wether or not the texture is blocking during loading.
  48974. */
  48975. /**
  48976. * Gets wether or not the texture is blocking during loading.
  48977. */
  48978. isBlocking: boolean;
  48979. protected _rotationY: number;
  48980. /**
  48981. * Sets texture matrix rotation angle around Y axis in radians.
  48982. */
  48983. /**
  48984. * Gets texture matrix rotation angle around Y axis radians.
  48985. */
  48986. rotationY: number;
  48987. /**
  48988. * Gets or sets the center of the bounding box associated with the cube texture
  48989. * It must define where the camera used to render the texture was set
  48990. */
  48991. boundingBoxPosition: Vector3;
  48992. private _boundingBoxSize;
  48993. /**
  48994. * Gets or sets the size of the bounding box associated with the cube texture
  48995. * When defined, the cubemap will switch to local mode
  48996. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48997. * @example https://www.babylonjs-playground.com/#RNASML
  48998. */
  48999. boundingBoxSize: Vector3;
  49000. /**
  49001. * Instantiates an HDRTexture from the following parameters.
  49002. *
  49003. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49004. * @param scene The scene the texture will be used in
  49005. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49006. * @param noMipmap Forces to not generate the mipmap if true
  49007. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49008. * @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)
  49009. * @param reserved Reserved flag for internal use.
  49010. */
  49011. 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>);
  49012. /**
  49013. * Get the current class name of the texture useful for serialization or dynamic coding.
  49014. * @returns "HDRCubeTexture"
  49015. */
  49016. getClassName(): string;
  49017. /**
  49018. * Occurs when the file is raw .hdr file.
  49019. */
  49020. private loadTexture;
  49021. clone(): HDRCubeTexture;
  49022. delayLoad(): void;
  49023. /**
  49024. * Get the texture reflection matrix used to rotate/transform the reflection.
  49025. * @returns the reflection matrix
  49026. */
  49027. getReflectionTextureMatrix(): Matrix;
  49028. /**
  49029. * Set the texture reflection matrix used to rotate/transform the reflection.
  49030. * @param value Define the reflection matrix to set
  49031. */
  49032. setReflectionTextureMatrix(value: Matrix): void;
  49033. /**
  49034. * Parses a JSON representation of an HDR Texture in order to create the texture
  49035. * @param parsedTexture Define the JSON representation
  49036. * @param scene Define the scene the texture should be created in
  49037. * @param rootUrl Define the root url in case we need to load relative dependencies
  49038. * @returns the newly created texture after parsing
  49039. */
  49040. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49041. serialize(): any;
  49042. }
  49043. }
  49044. declare module "babylonjs/Physics/physicsEngine" {
  49045. import { Nullable } from "babylonjs/types";
  49046. import { Vector3 } from "babylonjs/Maths/math";
  49047. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49048. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49049. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49050. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49051. /**
  49052. * Class used to control physics engine
  49053. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49054. */
  49055. export class PhysicsEngine implements IPhysicsEngine {
  49056. private _physicsPlugin;
  49057. /**
  49058. * Global value used to control the smallest number supported by the simulation
  49059. */
  49060. static Epsilon: number;
  49061. private _impostors;
  49062. private _joints;
  49063. /**
  49064. * Gets the gravity vector used by the simulation
  49065. */
  49066. gravity: Vector3;
  49067. /**
  49068. * Factory used to create the default physics plugin.
  49069. * @returns The default physics plugin
  49070. */
  49071. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49072. /**
  49073. * Creates a new Physics Engine
  49074. * @param gravity defines the gravity vector used by the simulation
  49075. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49076. */
  49077. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49078. /**
  49079. * Sets the gravity vector used by the simulation
  49080. * @param gravity defines the gravity vector to use
  49081. */
  49082. setGravity(gravity: Vector3): void;
  49083. /**
  49084. * Set the time step of the physics engine.
  49085. * Default is 1/60.
  49086. * To slow it down, enter 1/600 for example.
  49087. * To speed it up, 1/30
  49088. * @param newTimeStep defines the new timestep to apply to this world.
  49089. */
  49090. setTimeStep(newTimeStep?: number): void;
  49091. /**
  49092. * Get the time step of the physics engine.
  49093. * @returns the current time step
  49094. */
  49095. getTimeStep(): number;
  49096. /**
  49097. * Release all resources
  49098. */
  49099. dispose(): void;
  49100. /**
  49101. * Gets the name of the current physics plugin
  49102. * @returns the name of the plugin
  49103. */
  49104. getPhysicsPluginName(): string;
  49105. /**
  49106. * Adding a new impostor for the impostor tracking.
  49107. * This will be done by the impostor itself.
  49108. * @param impostor the impostor to add
  49109. */
  49110. addImpostor(impostor: PhysicsImpostor): void;
  49111. /**
  49112. * Remove an impostor from the engine.
  49113. * This impostor and its mesh will not longer be updated by the physics engine.
  49114. * @param impostor the impostor to remove
  49115. */
  49116. removeImpostor(impostor: PhysicsImpostor): void;
  49117. /**
  49118. * Add a joint to the physics engine
  49119. * @param mainImpostor defines the main impostor to which the joint is added.
  49120. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49121. * @param joint defines the joint that will connect both impostors.
  49122. */
  49123. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49124. /**
  49125. * Removes a joint from the simulation
  49126. * @param mainImpostor defines the impostor used with the joint
  49127. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49128. * @param joint defines the joint to remove
  49129. */
  49130. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49131. /**
  49132. * Called by the scene. No need to call it.
  49133. * @param delta defines the timespam between frames
  49134. */
  49135. _step(delta: number): void;
  49136. /**
  49137. * Gets the current plugin used to run the simulation
  49138. * @returns current plugin
  49139. */
  49140. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49141. /**
  49142. * Gets the list of physic impostors
  49143. * @returns an array of PhysicsImpostor
  49144. */
  49145. getImpostors(): Array<PhysicsImpostor>;
  49146. /**
  49147. * Gets the impostor for a physics enabled object
  49148. * @param object defines the object impersonated by the impostor
  49149. * @returns the PhysicsImpostor or null if not found
  49150. */
  49151. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49152. /**
  49153. * Gets the impostor for a physics body object
  49154. * @param body defines physics body used by the impostor
  49155. * @returns the PhysicsImpostor or null if not found
  49156. */
  49157. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49158. /**
  49159. * Does a raycast in the physics world
  49160. * @param from when should the ray start?
  49161. * @param to when should the ray end?
  49162. * @returns PhysicsRaycastResult
  49163. */
  49164. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49165. }
  49166. }
  49167. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49168. import { Nullable } from "babylonjs/types";
  49169. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49171. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49172. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49173. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49174. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49175. /** @hidden */
  49176. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49177. private _useDeltaForWorldStep;
  49178. world: any;
  49179. name: string;
  49180. private _physicsMaterials;
  49181. private _fixedTimeStep;
  49182. private _cannonRaycastResult;
  49183. private _raycastResult;
  49184. BJSCANNON: any;
  49185. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49186. setGravity(gravity: Vector3): void;
  49187. setTimeStep(timeStep: number): void;
  49188. getTimeStep(): number;
  49189. executeStep(delta: number): void;
  49190. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49191. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49192. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49193. private _processChildMeshes;
  49194. removePhysicsBody(impostor: PhysicsImpostor): void;
  49195. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49196. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49197. private _addMaterial;
  49198. private _checkWithEpsilon;
  49199. private _createShape;
  49200. private _createHeightmap;
  49201. private _minus90X;
  49202. private _plus90X;
  49203. private _tmpPosition;
  49204. private _tmpDeltaPosition;
  49205. private _tmpUnityRotation;
  49206. private _updatePhysicsBodyTransformation;
  49207. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49208. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49209. isSupported(): boolean;
  49210. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49211. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49212. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49213. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49214. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49215. getBodyMass(impostor: PhysicsImpostor): number;
  49216. getBodyFriction(impostor: PhysicsImpostor): number;
  49217. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49218. getBodyRestitution(impostor: PhysicsImpostor): number;
  49219. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49220. sleepBody(impostor: PhysicsImpostor): void;
  49221. wakeUpBody(impostor: PhysicsImpostor): void;
  49222. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49223. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49224. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49225. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49226. getRadius(impostor: PhysicsImpostor): number;
  49227. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49228. dispose(): void;
  49229. private _extendNamespace;
  49230. /**
  49231. * Does a raycast in the physics world
  49232. * @param from when should the ray start?
  49233. * @param to when should the ray end?
  49234. * @returns PhysicsRaycastResult
  49235. */
  49236. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49237. }
  49238. }
  49239. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49240. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49241. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49242. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49244. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49245. import { Nullable } from "babylonjs/types";
  49246. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49247. /** @hidden */
  49248. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49249. world: any;
  49250. name: string;
  49251. BJSOIMO: any;
  49252. private _raycastResult;
  49253. constructor(iterations?: number, oimoInjection?: any);
  49254. setGravity(gravity: Vector3): void;
  49255. setTimeStep(timeStep: number): void;
  49256. getTimeStep(): number;
  49257. private _tmpImpostorsArray;
  49258. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49259. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49260. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49261. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49262. private _tmpPositionVector;
  49263. removePhysicsBody(impostor: PhysicsImpostor): void;
  49264. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49265. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49266. isSupported(): boolean;
  49267. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49268. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49269. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49270. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49271. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49272. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49273. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49274. getBodyMass(impostor: PhysicsImpostor): number;
  49275. getBodyFriction(impostor: PhysicsImpostor): number;
  49276. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49277. getBodyRestitution(impostor: PhysicsImpostor): number;
  49278. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49279. sleepBody(impostor: PhysicsImpostor): void;
  49280. wakeUpBody(impostor: PhysicsImpostor): void;
  49281. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49282. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49283. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49284. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49285. getRadius(impostor: PhysicsImpostor): number;
  49286. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49287. dispose(): void;
  49288. /**
  49289. * Does a raycast in the physics world
  49290. * @param from when should the ray start?
  49291. * @param to when should the ray end?
  49292. * @returns PhysicsRaycastResult
  49293. */
  49294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49295. }
  49296. }
  49297. declare module "babylonjs/Probes/reflectionProbe" {
  49298. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49299. import { Vector3 } from "babylonjs/Maths/math";
  49300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49301. import { Nullable } from "babylonjs/types";
  49302. import { Scene } from "babylonjs/scene";
  49303. module "babylonjs/abstractScene" {
  49304. interface AbstractScene {
  49305. /**
  49306. * The list of reflection probes added to the scene
  49307. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49308. */
  49309. reflectionProbes: Array<ReflectionProbe>;
  49310. /**
  49311. * Removes the given reflection probe from this scene.
  49312. * @param toRemove The reflection probe to remove
  49313. * @returns The index of the removed reflection probe
  49314. */
  49315. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49316. /**
  49317. * Adds the given reflection probe to this scene.
  49318. * @param newReflectionProbe The reflection probe to add
  49319. */
  49320. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49321. }
  49322. }
  49323. /**
  49324. * Class used to generate realtime reflection / refraction cube textures
  49325. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49326. */
  49327. export class ReflectionProbe {
  49328. /** defines the name of the probe */
  49329. name: string;
  49330. private _scene;
  49331. private _renderTargetTexture;
  49332. private _projectionMatrix;
  49333. private _viewMatrix;
  49334. private _target;
  49335. private _add;
  49336. private _attachedMesh;
  49337. private _invertYAxis;
  49338. /** Gets or sets probe position (center of the cube map) */
  49339. position: Vector3;
  49340. /**
  49341. * Creates a new reflection probe
  49342. * @param name defines the name of the probe
  49343. * @param size defines the texture resolution (for each face)
  49344. * @param scene defines the hosting scene
  49345. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49346. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49347. */
  49348. constructor(
  49349. /** defines the name of the probe */
  49350. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49351. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49352. samples: number;
  49353. /** Gets or sets the refresh rate to use (on every frame by default) */
  49354. refreshRate: number;
  49355. /**
  49356. * Gets the hosting scene
  49357. * @returns a Scene
  49358. */
  49359. getScene(): Scene;
  49360. /** Gets the internal CubeTexture used to render to */
  49361. readonly cubeTexture: RenderTargetTexture;
  49362. /** Gets the list of meshes to render */
  49363. readonly renderList: Nullable<AbstractMesh[]>;
  49364. /**
  49365. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49366. * @param mesh defines the mesh to attach to
  49367. */
  49368. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49369. /**
  49370. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49371. * @param renderingGroupId The rendering group id corresponding to its index
  49372. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49373. */
  49374. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49375. /**
  49376. * Clean all associated resources
  49377. */
  49378. dispose(): void;
  49379. /**
  49380. * Converts the reflection probe information to a readable string for debug purpose.
  49381. * @param fullDetails Supports for multiple levels of logging within scene loading
  49382. * @returns the human readable reflection probe info
  49383. */
  49384. toString(fullDetails?: boolean): string;
  49385. /**
  49386. * Get the class name of the relfection probe.
  49387. * @returns "ReflectionProbe"
  49388. */
  49389. getClassName(): string;
  49390. /**
  49391. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49392. * @returns The JSON representation of the texture
  49393. */
  49394. serialize(): any;
  49395. /**
  49396. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49397. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49398. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49399. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49400. * @returns The parsed reflection probe if successful
  49401. */
  49402. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49403. }
  49404. }
  49405. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49406. /** @hidden */
  49407. export var _BabylonLoaderRegistered: boolean;
  49408. }
  49409. declare module "babylonjs/Loading/Plugins/index" {
  49410. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49411. }
  49412. declare module "babylonjs/Loading/index" {
  49413. export * from "babylonjs/Loading/loadingScreen";
  49414. export * from "babylonjs/Loading/Plugins/index";
  49415. export * from "babylonjs/Loading/sceneLoader";
  49416. export * from "babylonjs/Loading/sceneLoaderFlags";
  49417. }
  49418. declare module "babylonjs/Materials/Background/index" {
  49419. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49420. }
  49421. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49422. import { Scene } from "babylonjs/scene";
  49423. import { Color3 } from "babylonjs/Maths/math";
  49424. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49426. /**
  49427. * The Physically based simple base material of BJS.
  49428. *
  49429. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49430. * It is used as the base class for both the specGloss and metalRough conventions.
  49431. */
  49432. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49433. /**
  49434. * Number of Simultaneous lights allowed on the material.
  49435. */
  49436. maxSimultaneousLights: number;
  49437. /**
  49438. * If sets to true, disables all the lights affecting the material.
  49439. */
  49440. disableLighting: boolean;
  49441. /**
  49442. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49443. */
  49444. environmentTexture: BaseTexture;
  49445. /**
  49446. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49447. */
  49448. invertNormalMapX: boolean;
  49449. /**
  49450. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49451. */
  49452. invertNormalMapY: boolean;
  49453. /**
  49454. * Normal map used in the model.
  49455. */
  49456. normalTexture: BaseTexture;
  49457. /**
  49458. * Emissivie color used to self-illuminate the model.
  49459. */
  49460. emissiveColor: Color3;
  49461. /**
  49462. * Emissivie texture used to self-illuminate the model.
  49463. */
  49464. emissiveTexture: BaseTexture;
  49465. /**
  49466. * Occlusion Channel Strenght.
  49467. */
  49468. occlusionStrength: number;
  49469. /**
  49470. * Occlusion Texture of the material (adding extra occlusion effects).
  49471. */
  49472. occlusionTexture: BaseTexture;
  49473. /**
  49474. * Defines the alpha limits in alpha test mode.
  49475. */
  49476. alphaCutOff: number;
  49477. /**
  49478. * Gets the current double sided mode.
  49479. */
  49480. /**
  49481. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49482. */
  49483. doubleSided: boolean;
  49484. /**
  49485. * Stores the pre-calculated light information of a mesh in a texture.
  49486. */
  49487. lightmapTexture: BaseTexture;
  49488. /**
  49489. * If true, the light map contains occlusion information instead of lighting info.
  49490. */
  49491. useLightmapAsShadowmap: boolean;
  49492. /**
  49493. * Instantiates a new PBRMaterial instance.
  49494. *
  49495. * @param name The material name
  49496. * @param scene The scene the material will be use in.
  49497. */
  49498. constructor(name: string, scene: Scene);
  49499. getClassName(): string;
  49500. }
  49501. }
  49502. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49503. import { Scene } from "babylonjs/scene";
  49504. import { Color3 } from "babylonjs/Maths/math";
  49505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49506. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49507. /**
  49508. * The PBR material of BJS following the metal roughness convention.
  49509. *
  49510. * This fits to the PBR convention in the GLTF definition:
  49511. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49512. */
  49513. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49514. /**
  49515. * The base color has two different interpretations depending on the value of metalness.
  49516. * When the material is a metal, the base color is the specific measured reflectance value
  49517. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49518. * of the material.
  49519. */
  49520. baseColor: Color3;
  49521. /**
  49522. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49523. * well as opacity information in the alpha channel.
  49524. */
  49525. baseTexture: BaseTexture;
  49526. /**
  49527. * Specifies the metallic scalar value of the material.
  49528. * Can also be used to scale the metalness values of the metallic texture.
  49529. */
  49530. metallic: number;
  49531. /**
  49532. * Specifies the roughness scalar value of the material.
  49533. * Can also be used to scale the roughness values of the metallic texture.
  49534. */
  49535. roughness: number;
  49536. /**
  49537. * Texture containing both the metallic value in the B channel and the
  49538. * roughness value in the G channel to keep better precision.
  49539. */
  49540. metallicRoughnessTexture: BaseTexture;
  49541. /**
  49542. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49543. *
  49544. * @param name The material name
  49545. * @param scene The scene the material will be use in.
  49546. */
  49547. constructor(name: string, scene: Scene);
  49548. /**
  49549. * Return the currrent class name of the material.
  49550. */
  49551. getClassName(): string;
  49552. /**
  49553. * Makes a duplicate of the current material.
  49554. * @param name - name to use for the new material.
  49555. */
  49556. clone(name: string): PBRMetallicRoughnessMaterial;
  49557. /**
  49558. * Serialize the material to a parsable JSON object.
  49559. */
  49560. serialize(): any;
  49561. /**
  49562. * Parses a JSON object correponding to the serialize function.
  49563. */
  49564. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49565. }
  49566. }
  49567. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49568. import { Scene } from "babylonjs/scene";
  49569. import { Color3 } from "babylonjs/Maths/math";
  49570. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49571. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49572. /**
  49573. * The PBR material of BJS following the specular glossiness convention.
  49574. *
  49575. * This fits to the PBR convention in the GLTF definition:
  49576. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49577. */
  49578. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49579. /**
  49580. * Specifies the diffuse color of the material.
  49581. */
  49582. diffuseColor: Color3;
  49583. /**
  49584. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49585. * channel.
  49586. */
  49587. diffuseTexture: BaseTexture;
  49588. /**
  49589. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49590. */
  49591. specularColor: Color3;
  49592. /**
  49593. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49594. */
  49595. glossiness: number;
  49596. /**
  49597. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49598. */
  49599. specularGlossinessTexture: BaseTexture;
  49600. /**
  49601. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49602. *
  49603. * @param name The material name
  49604. * @param scene The scene the material will be use in.
  49605. */
  49606. constructor(name: string, scene: Scene);
  49607. /**
  49608. * Return the currrent class name of the material.
  49609. */
  49610. getClassName(): string;
  49611. /**
  49612. * Makes a duplicate of the current material.
  49613. * @param name - name to use for the new material.
  49614. */
  49615. clone(name: string): PBRSpecularGlossinessMaterial;
  49616. /**
  49617. * Serialize the material to a parsable JSON object.
  49618. */
  49619. serialize(): any;
  49620. /**
  49621. * Parses a JSON object correponding to the serialize function.
  49622. */
  49623. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49624. }
  49625. }
  49626. declare module "babylonjs/Materials/PBR/index" {
  49627. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49628. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49629. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49630. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49631. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49632. }
  49633. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49634. import { Nullable } from "babylonjs/types";
  49635. import { Scene } from "babylonjs/scene";
  49636. import { Matrix } from "babylonjs/Maths/math";
  49637. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49638. /**
  49639. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49640. * It can help converting any input color in a desired output one. This can then be used to create effects
  49641. * from sepia, black and white to sixties or futuristic rendering...
  49642. *
  49643. * The only supported format is currently 3dl.
  49644. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49645. */
  49646. export class ColorGradingTexture extends BaseTexture {
  49647. /**
  49648. * The current texture matrix. (will always be identity in color grading texture)
  49649. */
  49650. private _textureMatrix;
  49651. /**
  49652. * The texture URL.
  49653. */
  49654. url: string;
  49655. /**
  49656. * Empty line regex stored for GC.
  49657. */
  49658. private static _noneEmptyLineRegex;
  49659. private _engine;
  49660. /**
  49661. * Instantiates a ColorGradingTexture from the following parameters.
  49662. *
  49663. * @param url The location of the color gradind data (currently only supporting 3dl)
  49664. * @param scene The scene the texture will be used in
  49665. */
  49666. constructor(url: string, scene: Scene);
  49667. /**
  49668. * Returns the texture matrix used in most of the material.
  49669. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49670. */
  49671. getTextureMatrix(): Matrix;
  49672. /**
  49673. * Occurs when the file being loaded is a .3dl LUT file.
  49674. */
  49675. private load3dlTexture;
  49676. /**
  49677. * Starts the loading process of the texture.
  49678. */
  49679. private loadTexture;
  49680. /**
  49681. * Clones the color gradind texture.
  49682. */
  49683. clone(): ColorGradingTexture;
  49684. /**
  49685. * Called during delayed load for textures.
  49686. */
  49687. delayLoad(): void;
  49688. /**
  49689. * Parses a color grading texture serialized by Babylon.
  49690. * @param parsedTexture The texture information being parsedTexture
  49691. * @param scene The scene to load the texture in
  49692. * @param rootUrl The root url of the data assets to load
  49693. * @return A color gradind texture
  49694. */
  49695. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49696. /**
  49697. * Serializes the LUT texture to json format.
  49698. */
  49699. serialize(): any;
  49700. }
  49701. }
  49702. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49703. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49704. import { Scene } from "babylonjs/scene";
  49705. import { Nullable } from "babylonjs/types";
  49706. /**
  49707. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49708. */
  49709. export class EquiRectangularCubeTexture extends BaseTexture {
  49710. /** The six faces of the cube. */
  49711. private static _FacesMapping;
  49712. private _noMipmap;
  49713. private _onLoad;
  49714. private _onError;
  49715. /** The size of the cubemap. */
  49716. private _size;
  49717. /** The buffer of the image. */
  49718. private _buffer;
  49719. /** The width of the input image. */
  49720. private _width;
  49721. /** The height of the input image. */
  49722. private _height;
  49723. /** The URL to the image. */
  49724. url: string;
  49725. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49726. coordinatesMode: number;
  49727. /**
  49728. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49729. * @param url The location of the image
  49730. * @param scene The scene the texture will be used in
  49731. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49732. * @param noMipmap Forces to not generate the mipmap if true
  49733. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49734. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49735. * @param onLoad — defines a callback called when texture is loaded
  49736. * @param onError — defines a callback called if there is an error
  49737. */
  49738. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49739. /**
  49740. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49741. */
  49742. private loadImage;
  49743. /**
  49744. * Convert the image buffer into a cubemap and create a CubeTexture.
  49745. */
  49746. private loadTexture;
  49747. /**
  49748. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49749. * @param buffer The ArrayBuffer that should be converted.
  49750. * @returns The buffer as Float32Array.
  49751. */
  49752. private getFloat32ArrayFromArrayBuffer;
  49753. /**
  49754. * Get the current class name of the texture useful for serialization or dynamic coding.
  49755. * @returns "EquiRectangularCubeTexture"
  49756. */
  49757. getClassName(): string;
  49758. /**
  49759. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49760. * @returns A clone of the current EquiRectangularCubeTexture.
  49761. */
  49762. clone(): EquiRectangularCubeTexture;
  49763. }
  49764. }
  49765. declare module "babylonjs/Misc/tga" {
  49766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49767. /**
  49768. * Based on jsTGALoader - Javascript loader for TGA file
  49769. * By Vincent Thibault
  49770. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49771. */
  49772. export class TGATools {
  49773. private static _TYPE_INDEXED;
  49774. private static _TYPE_RGB;
  49775. private static _TYPE_GREY;
  49776. private static _TYPE_RLE_INDEXED;
  49777. private static _TYPE_RLE_RGB;
  49778. private static _TYPE_RLE_GREY;
  49779. private static _ORIGIN_MASK;
  49780. private static _ORIGIN_SHIFT;
  49781. private static _ORIGIN_BL;
  49782. private static _ORIGIN_BR;
  49783. private static _ORIGIN_UL;
  49784. private static _ORIGIN_UR;
  49785. /**
  49786. * Gets the header of a TGA file
  49787. * @param data defines the TGA data
  49788. * @returns the header
  49789. */
  49790. static GetTGAHeader(data: Uint8Array): any;
  49791. /**
  49792. * Uploads TGA content to a Babylon Texture
  49793. * @hidden
  49794. */
  49795. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49796. /** @hidden */
  49797. 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;
  49798. /** @hidden */
  49799. 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;
  49800. /** @hidden */
  49801. 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;
  49802. /** @hidden */
  49803. 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;
  49804. /** @hidden */
  49805. 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;
  49806. /** @hidden */
  49807. 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;
  49808. }
  49809. }
  49810. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49811. import { Nullable } from "babylonjs/types";
  49812. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49813. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49814. /**
  49815. * Implementation of the TGA Texture Loader.
  49816. * @hidden
  49817. */
  49818. export class _TGATextureLoader implements IInternalTextureLoader {
  49819. /**
  49820. * Defines wether the loader supports cascade loading the different faces.
  49821. */
  49822. readonly supportCascades: boolean;
  49823. /**
  49824. * This returns if the loader support the current file information.
  49825. * @param extension defines the file extension of the file being loaded
  49826. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49827. * @param fallback defines the fallback internal texture if any
  49828. * @param isBase64 defines whether the texture is encoded as a base64
  49829. * @param isBuffer defines whether the texture data are stored as a buffer
  49830. * @returns true if the loader can load the specified file
  49831. */
  49832. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49833. /**
  49834. * Transform the url before loading if required.
  49835. * @param rootUrl the url of the texture
  49836. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49837. * @returns the transformed texture
  49838. */
  49839. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49840. /**
  49841. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49842. * @param rootUrl the url of the texture
  49843. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49844. * @returns the fallback texture
  49845. */
  49846. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49847. /**
  49848. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49849. * @param data contains the texture data
  49850. * @param texture defines the BabylonJS internal texture
  49851. * @param createPolynomials will be true if polynomials have been requested
  49852. * @param onLoad defines the callback to trigger once the texture is ready
  49853. * @param onError defines the callback to trigger in case of error
  49854. */
  49855. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49856. /**
  49857. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49858. * @param data contains the texture data
  49859. * @param texture defines the BabylonJS internal texture
  49860. * @param callback defines the method to call once ready to upload
  49861. */
  49862. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49863. }
  49864. }
  49865. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49866. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49867. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49868. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49869. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49870. }
  49871. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49872. import { Scene } from "babylonjs/scene";
  49873. import { Texture } from "babylonjs/Materials/Textures/texture";
  49874. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49875. /**
  49876. * 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.
  49877. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49878. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49879. */
  49880. export class CustomProceduralTexture extends ProceduralTexture {
  49881. private _animate;
  49882. private _time;
  49883. private _config;
  49884. private _texturePath;
  49885. /**
  49886. * Instantiates a new Custom Procedural Texture.
  49887. * 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.
  49888. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49889. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49890. * @param name Define the name of the texture
  49891. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49892. * @param size Define the size of the texture to create
  49893. * @param scene Define the scene the texture belongs to
  49894. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49895. * @param generateMipMaps Define if the texture should creates mip maps or not
  49896. */
  49897. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49898. private _loadJson;
  49899. /**
  49900. * Is the texture ready to be used ? (rendered at least once)
  49901. * @returns true if ready, otherwise, false.
  49902. */
  49903. isReady(): boolean;
  49904. /**
  49905. * Render the texture to its associated render target.
  49906. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49907. */
  49908. render(useCameraPostProcess?: boolean): void;
  49909. /**
  49910. * Update the list of dependant textures samplers in the shader.
  49911. */
  49912. updateTextures(): void;
  49913. /**
  49914. * Update the uniform values of the procedural texture in the shader.
  49915. */
  49916. updateShaderUniforms(): void;
  49917. /**
  49918. * Define if the texture animates or not.
  49919. */
  49920. animate: boolean;
  49921. }
  49922. }
  49923. declare module "babylonjs/Shaders/noise.fragment" {
  49924. /** @hidden */
  49925. export var noisePixelShader: {
  49926. name: string;
  49927. shader: string;
  49928. };
  49929. }
  49930. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49931. import { Nullable } from "babylonjs/types";
  49932. import { Scene } from "babylonjs/scene";
  49933. import { Texture } from "babylonjs/Materials/Textures/texture";
  49934. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49935. import "babylonjs/Shaders/noise.fragment";
  49936. /**
  49937. * Class used to generate noise procedural textures
  49938. */
  49939. export class NoiseProceduralTexture extends ProceduralTexture {
  49940. private _time;
  49941. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49942. brightness: number;
  49943. /** Defines the number of octaves to process */
  49944. octaves: number;
  49945. /** Defines the level of persistence (0.8 by default) */
  49946. persistence: number;
  49947. /** Gets or sets animation speed factor (default is 1) */
  49948. animationSpeedFactor: number;
  49949. /**
  49950. * Creates a new NoiseProceduralTexture
  49951. * @param name defines the name fo the texture
  49952. * @param size defines the size of the texture (default is 256)
  49953. * @param scene defines the hosting scene
  49954. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49955. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49956. */
  49957. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49958. private _updateShaderUniforms;
  49959. protected _getDefines(): string;
  49960. /** Generate the current state of the procedural texture */
  49961. render(useCameraPostProcess?: boolean): void;
  49962. /**
  49963. * Serializes this noise procedural texture
  49964. * @returns a serialized noise procedural texture object
  49965. */
  49966. serialize(): any;
  49967. /**
  49968. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49969. * @param parsedTexture defines parsed texture data
  49970. * @param scene defines the current scene
  49971. * @param rootUrl defines the root URL containing noise procedural texture information
  49972. * @returns a parsed NoiseProceduralTexture
  49973. */
  49974. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49975. }
  49976. }
  49977. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49978. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49979. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49980. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49981. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49982. }
  49983. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49984. import { Nullable } from "babylonjs/types";
  49985. import { Scene } from "babylonjs/scene";
  49986. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49987. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49988. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49989. /**
  49990. * Raw cube texture where the raw buffers are passed in
  49991. */
  49992. export class RawCubeTexture extends CubeTexture {
  49993. /**
  49994. * Creates a cube texture where the raw buffers are passed in.
  49995. * @param scene defines the scene the texture is attached to
  49996. * @param data defines the array of data to use to create each face
  49997. * @param size defines the size of the textures
  49998. * @param format defines the format of the data
  49999. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50000. * @param generateMipMaps defines if the engine should generate the mip levels
  50001. * @param invertY defines if data must be stored with Y axis inverted
  50002. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50003. * @param compression defines the compression used (null by default)
  50004. */
  50005. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50006. /**
  50007. * Updates the raw cube texture.
  50008. * @param data defines the data to store
  50009. * @param format defines the data format
  50010. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50011. * @param invertY defines if data must be stored with Y axis inverted
  50012. * @param compression defines the compression used (null by default)
  50013. * @param level defines which level of the texture to update
  50014. */
  50015. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50016. /**
  50017. * Updates a raw cube texture with RGBD encoded data.
  50018. * @param data defines the array of data [mipmap][face] to use to create each face
  50019. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50020. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50021. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50022. * @returns a promsie that resolves when the operation is complete
  50023. */
  50024. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50025. /**
  50026. * Clones the raw cube texture.
  50027. * @return a new cube texture
  50028. */
  50029. clone(): CubeTexture;
  50030. /** @hidden */
  50031. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50032. }
  50033. }
  50034. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50035. import { Scene } from "babylonjs/scene";
  50036. import { Texture } from "babylonjs/Materials/Textures/texture";
  50037. /**
  50038. * Class used to store 3D textures containing user data
  50039. */
  50040. export class RawTexture3D extends Texture {
  50041. /** Gets or sets the texture format to use */
  50042. format: number;
  50043. private _engine;
  50044. /**
  50045. * Create a new RawTexture3D
  50046. * @param data defines the data of the texture
  50047. * @param width defines the width of the texture
  50048. * @param height defines the height of the texture
  50049. * @param depth defines the depth of the texture
  50050. * @param format defines the texture format to use
  50051. * @param scene defines the hosting scene
  50052. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50053. * @param invertY defines if texture must be stored with Y axis inverted
  50054. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50055. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50056. */
  50057. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50058. /** Gets or sets the texture format to use */
  50059. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50060. /**
  50061. * Update the texture with new data
  50062. * @param data defines the data to store in the texture
  50063. */
  50064. update(data: ArrayBufferView): void;
  50065. }
  50066. }
  50067. declare module "babylonjs/Materials/Textures/refractionTexture" {
  50068. import { Scene } from "babylonjs/scene";
  50069. import { Plane } from "babylonjs/Maths/math";
  50070. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50071. /**
  50072. * Creates a refraction texture used by refraction channel of the standard material.
  50073. * It is like a mirror but to see through a material.
  50074. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50075. */
  50076. export class RefractionTexture extends RenderTargetTexture {
  50077. /**
  50078. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50079. * 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.
  50080. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50081. */
  50082. refractionPlane: Plane;
  50083. /**
  50084. * Define how deep under the surface we should see.
  50085. */
  50086. depth: number;
  50087. /**
  50088. * Creates a refraction texture used by refraction channel of the standard material.
  50089. * It is like a mirror but to see through a material.
  50090. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50091. * @param name Define the texture name
  50092. * @param size Define the size of the underlying texture
  50093. * @param scene Define the scene the refraction belongs to
  50094. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50095. */
  50096. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50097. /**
  50098. * Clone the refraction texture.
  50099. * @returns the cloned texture
  50100. */
  50101. clone(): RefractionTexture;
  50102. /**
  50103. * Serialize the texture to a JSON representation you could use in Parse later on
  50104. * @returns the serialized JSON representation
  50105. */
  50106. serialize(): any;
  50107. }
  50108. }
  50109. declare module "babylonjs/Materials/Textures/index" {
  50110. export * from "babylonjs/Materials/Textures/baseTexture";
  50111. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50112. export * from "babylonjs/Materials/Textures/cubeTexture";
  50113. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50114. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50115. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50116. export * from "babylonjs/Materials/Textures/internalTexture";
  50117. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50118. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50119. export * from "babylonjs/Materials/Textures/Loaders/index";
  50120. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50121. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50122. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50123. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50124. export * from "babylonjs/Materials/Textures/rawTexture";
  50125. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50126. export * from "babylonjs/Materials/Textures/refractionTexture";
  50127. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50128. export * from "babylonjs/Materials/Textures/texture";
  50129. export * from "babylonjs/Materials/Textures/videoTexture";
  50130. }
  50131. declare module "babylonjs/Materials/index" {
  50132. export * from "babylonjs/Materials/Background/index";
  50133. export * from "babylonjs/Materials/colorCurves";
  50134. export * from "babylonjs/Materials/effect";
  50135. export * from "babylonjs/Materials/fresnelParameters";
  50136. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50137. export * from "babylonjs/Materials/material";
  50138. export * from "babylonjs/Materials/materialDefines";
  50139. export * from "babylonjs/Materials/materialHelper";
  50140. export * from "babylonjs/Materials/multiMaterial";
  50141. export * from "babylonjs/Materials/PBR/index";
  50142. export * from "babylonjs/Materials/pushMaterial";
  50143. export * from "babylonjs/Materials/shaderMaterial";
  50144. export * from "babylonjs/Materials/standardMaterial";
  50145. export * from "babylonjs/Materials/Textures/index";
  50146. export * from "babylonjs/Materials/uniformBuffer";
  50147. export * from "babylonjs/Materials/materialFlags";
  50148. }
  50149. declare module "babylonjs/Maths/index" {
  50150. export * from "babylonjs/Maths/math.scalar";
  50151. export * from "babylonjs/Maths/math";
  50152. export * from "babylonjs/Maths/sphericalPolynomial";
  50153. }
  50154. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50155. import { IDisposable } from "babylonjs/scene";
  50156. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50157. /**
  50158. * Configuration for Draco compression
  50159. */
  50160. export interface IDracoCompressionConfiguration {
  50161. /**
  50162. * Configuration for the decoder.
  50163. */
  50164. decoder?: {
  50165. /**
  50166. * The url to the WebAssembly module.
  50167. */
  50168. wasmUrl?: string;
  50169. /**
  50170. * The url to the WebAssembly binary.
  50171. */
  50172. wasmBinaryUrl?: string;
  50173. /**
  50174. * The url to the fallback JavaScript module.
  50175. */
  50176. fallbackUrl?: string;
  50177. };
  50178. }
  50179. /**
  50180. * Draco compression (https://google.github.io/draco/)
  50181. *
  50182. * This class wraps the Draco module.
  50183. *
  50184. * **Encoder**
  50185. *
  50186. * The encoder is not currently implemented.
  50187. *
  50188. * **Decoder**
  50189. *
  50190. * 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.
  50191. *
  50192. * To update the configuration, use the following code:
  50193. * ```javascript
  50194. * DracoCompression.Configuration = {
  50195. * decoder: {
  50196. * wasmUrl: "<url to the WebAssembly library>",
  50197. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50198. * fallbackUrl: "<url to the fallback JavaScript library>",
  50199. * }
  50200. * };
  50201. * ```
  50202. *
  50203. * 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.
  50204. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50205. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50206. *
  50207. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50208. * ```javascript
  50209. * var dracoCompression = new DracoCompression();
  50210. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50211. * [VertexBuffer.PositionKind]: 0
  50212. * });
  50213. * ```
  50214. *
  50215. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50216. */
  50217. export class DracoCompression implements IDisposable {
  50218. private static _DecoderModulePromise;
  50219. /**
  50220. * The configuration. Defaults to the following urls:
  50221. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50222. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50223. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50224. */
  50225. static Configuration: IDracoCompressionConfiguration;
  50226. /**
  50227. * Returns true if the decoder is available.
  50228. */
  50229. static readonly DecoderAvailable: boolean;
  50230. /**
  50231. * Constructor
  50232. */
  50233. constructor();
  50234. /**
  50235. * Stop all async operations and release resources.
  50236. */
  50237. dispose(): void;
  50238. /**
  50239. * Decode Draco compressed mesh data to vertex data.
  50240. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50241. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50242. * @returns A promise that resolves with the decoded vertex data
  50243. */
  50244. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50245. [kind: string]: number;
  50246. }): Promise<VertexData>;
  50247. private static _GetDecoderModule;
  50248. private static _LoadScriptAsync;
  50249. private static _LoadFileAsync;
  50250. }
  50251. }
  50252. declare module "babylonjs/Meshes/Compression/index" {
  50253. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50254. }
  50255. declare module "babylonjs/Meshes/csg" {
  50256. import { Nullable } from "babylonjs/types";
  50257. import { Scene } from "babylonjs/scene";
  50258. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50259. import { Mesh } from "babylonjs/Meshes/mesh";
  50260. import { Material } from "babylonjs/Materials/material";
  50261. /**
  50262. * Class for building Constructive Solid Geometry
  50263. */
  50264. export class CSG {
  50265. private polygons;
  50266. /**
  50267. * The world matrix
  50268. */
  50269. matrix: Matrix;
  50270. /**
  50271. * Stores the position
  50272. */
  50273. position: Vector3;
  50274. /**
  50275. * Stores the rotation
  50276. */
  50277. rotation: Vector3;
  50278. /**
  50279. * Stores the rotation quaternion
  50280. */
  50281. rotationQuaternion: Nullable<Quaternion>;
  50282. /**
  50283. * Stores the scaling vector
  50284. */
  50285. scaling: Vector3;
  50286. /**
  50287. * Convert the Mesh to CSG
  50288. * @param mesh The Mesh to convert to CSG
  50289. * @returns A new CSG from the Mesh
  50290. */
  50291. static FromMesh(mesh: Mesh): CSG;
  50292. /**
  50293. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50294. * @param polygons Polygons used to construct a CSG solid
  50295. */
  50296. private static FromPolygons;
  50297. /**
  50298. * Clones, or makes a deep copy, of the CSG
  50299. * @returns A new CSG
  50300. */
  50301. clone(): CSG;
  50302. /**
  50303. * Unions this CSG with another CSG
  50304. * @param csg The CSG to union against this CSG
  50305. * @returns The unioned CSG
  50306. */
  50307. union(csg: CSG): CSG;
  50308. /**
  50309. * Unions this CSG with another CSG in place
  50310. * @param csg The CSG to union against this CSG
  50311. */
  50312. unionInPlace(csg: CSG): void;
  50313. /**
  50314. * Subtracts this CSG with another CSG
  50315. * @param csg The CSG to subtract against this CSG
  50316. * @returns A new CSG
  50317. */
  50318. subtract(csg: CSG): CSG;
  50319. /**
  50320. * Subtracts this CSG with another CSG in place
  50321. * @param csg The CSG to subtact against this CSG
  50322. */
  50323. subtractInPlace(csg: CSG): void;
  50324. /**
  50325. * Intersect this CSG with another CSG
  50326. * @param csg The CSG to intersect against this CSG
  50327. * @returns A new CSG
  50328. */
  50329. intersect(csg: CSG): CSG;
  50330. /**
  50331. * Intersects this CSG with another CSG in place
  50332. * @param csg The CSG to intersect against this CSG
  50333. */
  50334. intersectInPlace(csg: CSG): void;
  50335. /**
  50336. * Return a new CSG solid with solid and empty space switched. This solid is
  50337. * not modified.
  50338. * @returns A new CSG solid with solid and empty space switched
  50339. */
  50340. inverse(): CSG;
  50341. /**
  50342. * Inverses the CSG in place
  50343. */
  50344. inverseInPlace(): void;
  50345. /**
  50346. * This is used to keep meshes transformations so they can be restored
  50347. * when we build back a Babylon Mesh
  50348. * NB : All CSG operations are performed in world coordinates
  50349. * @param csg The CSG to copy the transform attributes from
  50350. * @returns This CSG
  50351. */
  50352. copyTransformAttributes(csg: CSG): CSG;
  50353. /**
  50354. * Build Raw mesh from CSG
  50355. * Coordinates here are in world space
  50356. * @param name The name of the mesh geometry
  50357. * @param scene The Scene
  50358. * @param keepSubMeshes Specifies if the submeshes should be kept
  50359. * @returns A new Mesh
  50360. */
  50361. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50362. /**
  50363. * Build Mesh from CSG taking material and transforms into account
  50364. * @param name The name of the Mesh
  50365. * @param material The material of the Mesh
  50366. * @param scene The Scene
  50367. * @param keepSubMeshes Specifies if submeshes should be kept
  50368. * @returns The new Mesh
  50369. */
  50370. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50371. }
  50372. }
  50373. declare module "babylonjs/Meshes/trailMesh" {
  50374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50375. import { Mesh } from "babylonjs/Meshes/mesh";
  50376. import { Scene } from "babylonjs/scene";
  50377. /**
  50378. * Class used to create a trail following a mesh
  50379. */
  50380. export class TrailMesh extends Mesh {
  50381. private _generator;
  50382. private _autoStart;
  50383. private _running;
  50384. private _diameter;
  50385. private _length;
  50386. private _sectionPolygonPointsCount;
  50387. private _sectionVectors;
  50388. private _sectionNormalVectors;
  50389. private _beforeRenderObserver;
  50390. /**
  50391. * @constructor
  50392. * @param name The value used by scene.getMeshByName() to do a lookup.
  50393. * @param generator The mesh to generate a trail.
  50394. * @param scene The scene to add this mesh to.
  50395. * @param diameter Diameter of trailing mesh. Default is 1.
  50396. * @param length Length of trailing mesh. Default is 60.
  50397. * @param autoStart Automatically start trailing mesh. Default true.
  50398. */
  50399. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50400. /**
  50401. * "TrailMesh"
  50402. * @returns "TrailMesh"
  50403. */
  50404. getClassName(): string;
  50405. private _createMesh;
  50406. /**
  50407. * Start trailing mesh.
  50408. */
  50409. start(): void;
  50410. /**
  50411. * Stop trailing mesh.
  50412. */
  50413. stop(): void;
  50414. /**
  50415. * Update trailing mesh geometry.
  50416. */
  50417. update(): void;
  50418. /**
  50419. * Returns a new TrailMesh object.
  50420. * @param name is a string, the name given to the new mesh
  50421. * @param newGenerator use new generator object for cloned trail mesh
  50422. * @returns a new mesh
  50423. */
  50424. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50425. /**
  50426. * Serializes this trail mesh
  50427. * @param serializationObject object to write serialization to
  50428. */
  50429. serialize(serializationObject: any): void;
  50430. /**
  50431. * Parses a serialized trail mesh
  50432. * @param parsedMesh the serialized mesh
  50433. * @param scene the scene to create the trail mesh in
  50434. * @returns the created trail mesh
  50435. */
  50436. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50437. }
  50438. }
  50439. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50440. import { Nullable } from "babylonjs/types";
  50441. import { Scene } from "babylonjs/scene";
  50442. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50443. import { Mesh } from "babylonjs/Meshes/mesh";
  50444. /**
  50445. * Class containing static functions to help procedurally build meshes
  50446. */
  50447. export class RibbonBuilder {
  50448. /**
  50449. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50450. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50451. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50452. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50453. * * 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
  50454. * * 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
  50455. * * 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
  50456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50459. * * 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
  50460. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50461. * * 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
  50462. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50464. * @param name defines the name of the mesh
  50465. * @param options defines the options used to create the mesh
  50466. * @param scene defines the hosting scene
  50467. * @returns the ribbon mesh
  50468. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50470. */
  50471. static CreateRibbon(name: string, options: {
  50472. pathArray: Vector3[][];
  50473. closeArray?: boolean;
  50474. closePath?: boolean;
  50475. offset?: number;
  50476. updatable?: boolean;
  50477. sideOrientation?: number;
  50478. frontUVs?: Vector4;
  50479. backUVs?: Vector4;
  50480. instance?: Mesh;
  50481. invertUV?: boolean;
  50482. uvs?: Vector2[];
  50483. colors?: Color4[];
  50484. }, scene?: Nullable<Scene>): Mesh;
  50485. }
  50486. }
  50487. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50488. import { Vector4 } from "babylonjs/Maths/math";
  50489. import { Mesh } from "babylonjs/Meshes/mesh";
  50490. /**
  50491. * Class containing static functions to help procedurally build meshes
  50492. */
  50493. export class TorusKnotBuilder {
  50494. /**
  50495. * Creates a torus knot mesh
  50496. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50497. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50498. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50499. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50503. * @param name defines the name of the mesh
  50504. * @param options defines the options used to create the mesh
  50505. * @param scene defines the hosting scene
  50506. * @returns the torus knot mesh
  50507. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50508. */
  50509. static CreateTorusKnot(name: string, options: {
  50510. radius?: number;
  50511. tube?: number;
  50512. radialSegments?: number;
  50513. tubularSegments?: number;
  50514. p?: number;
  50515. q?: number;
  50516. updatable?: boolean;
  50517. sideOrientation?: number;
  50518. frontUVs?: Vector4;
  50519. backUVs?: Vector4;
  50520. }, scene: any): Mesh;
  50521. }
  50522. }
  50523. declare module "babylonjs/Meshes/polygonMesh" {
  50524. import { Scene } from "babylonjs/scene";
  50525. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50526. import { Mesh } from "babylonjs/Meshes/mesh";
  50527. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50528. /**
  50529. * Polygon
  50530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50531. */
  50532. export class Polygon {
  50533. /**
  50534. * Creates a rectangle
  50535. * @param xmin bottom X coord
  50536. * @param ymin bottom Y coord
  50537. * @param xmax top X coord
  50538. * @param ymax top Y coord
  50539. * @returns points that make the resulting rectation
  50540. */
  50541. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50542. /**
  50543. * Creates a circle
  50544. * @param radius radius of circle
  50545. * @param cx scale in x
  50546. * @param cy scale in y
  50547. * @param numberOfSides number of sides that make up the circle
  50548. * @returns points that make the resulting circle
  50549. */
  50550. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50551. /**
  50552. * Creates a polygon from input string
  50553. * @param input Input polygon data
  50554. * @returns the parsed points
  50555. */
  50556. static Parse(input: string): Vector2[];
  50557. /**
  50558. * Starts building a polygon from x and y coordinates
  50559. * @param x x coordinate
  50560. * @param y y coordinate
  50561. * @returns the started path2
  50562. */
  50563. static StartingAt(x: number, y: number): Path2;
  50564. }
  50565. /**
  50566. * Builds a polygon
  50567. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50568. */
  50569. export class PolygonMeshBuilder {
  50570. private _points;
  50571. private _outlinepoints;
  50572. private _holes;
  50573. private _name;
  50574. private _scene;
  50575. private _epoints;
  50576. private _eholes;
  50577. private _addToepoint;
  50578. /**
  50579. * Babylon reference to the earcut plugin.
  50580. */
  50581. bjsEarcut: any;
  50582. /**
  50583. * Creates a PolygonMeshBuilder
  50584. * @param name name of the builder
  50585. * @param contours Path of the polygon
  50586. * @param scene scene to add to when creating the mesh
  50587. * @param earcutInjection can be used to inject your own earcut reference
  50588. */
  50589. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50590. /**
  50591. * Adds a whole within the polygon
  50592. * @param hole Array of points defining the hole
  50593. * @returns this
  50594. */
  50595. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50596. /**
  50597. * Creates the polygon
  50598. * @param updatable If the mesh should be updatable
  50599. * @param depth The depth of the mesh created
  50600. * @returns the created mesh
  50601. */
  50602. build(updatable?: boolean, depth?: number): Mesh;
  50603. /**
  50604. * Creates the polygon
  50605. * @param depth The depth of the mesh created
  50606. * @returns the created VertexData
  50607. */
  50608. buildVertexData(depth?: number): VertexData;
  50609. /**
  50610. * Adds a side to the polygon
  50611. * @param positions points that make the polygon
  50612. * @param normals normals of the polygon
  50613. * @param uvs uvs of the polygon
  50614. * @param indices indices of the polygon
  50615. * @param bounds bounds of the polygon
  50616. * @param points points of the polygon
  50617. * @param depth depth of the polygon
  50618. * @param flip flip of the polygon
  50619. */
  50620. private addSide;
  50621. }
  50622. }
  50623. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50624. import { Scene } from "babylonjs/scene";
  50625. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50626. import { Mesh } from "babylonjs/Meshes/mesh";
  50627. /**
  50628. * Class containing static functions to help procedurally build meshes
  50629. */
  50630. export class PolygonBuilder {
  50631. /**
  50632. * Creates a polygon mesh
  50633. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50634. * * 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
  50635. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50638. * * Remember you can only change the shape positions, not their number when updating a polygon
  50639. * @param name defines the name of the mesh
  50640. * @param options defines the options used to create the mesh
  50641. * @param scene defines the hosting scene
  50642. * @param earcutInjection can be used to inject your own earcut reference
  50643. * @returns the polygon mesh
  50644. */
  50645. static CreatePolygon(name: string, options: {
  50646. shape: Vector3[];
  50647. holes?: Vector3[][];
  50648. depth?: number;
  50649. faceUV?: Vector4[];
  50650. faceColors?: Color4[];
  50651. updatable?: boolean;
  50652. sideOrientation?: number;
  50653. frontUVs?: Vector4;
  50654. backUVs?: Vector4;
  50655. }, scene: Scene, earcutInjection?: any): Mesh;
  50656. /**
  50657. * Creates an extruded polygon mesh, with depth in the Y direction.
  50658. * * 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)
  50659. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50660. * @param name defines the name of the mesh
  50661. * @param options defines the options used to create the mesh
  50662. * @param scene defines the hosting scene
  50663. * @param earcutInjection can be used to inject your own earcut reference
  50664. * @returns the polygon mesh
  50665. */
  50666. static ExtrudePolygon(name: string, options: {
  50667. shape: Vector3[];
  50668. holes?: Vector3[][];
  50669. depth?: number;
  50670. faceUV?: Vector4[];
  50671. faceColors?: Color4[];
  50672. updatable?: boolean;
  50673. sideOrientation?: number;
  50674. frontUVs?: Vector4;
  50675. backUVs?: Vector4;
  50676. }, scene: Scene, earcutInjection?: any): Mesh;
  50677. }
  50678. }
  50679. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50680. import { Nullable } from "babylonjs/types";
  50681. import { Scene } from "babylonjs/scene";
  50682. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50683. import { Mesh } from "babylonjs/Meshes/mesh";
  50684. /**
  50685. * Class containing static functions to help procedurally build meshes
  50686. */
  50687. export class ShapeBuilder {
  50688. /**
  50689. * 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.
  50690. * * 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.
  50691. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50692. * * 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.
  50693. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50694. * * 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
  50695. * * 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
  50696. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50699. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50701. * @param name defines the name of the mesh
  50702. * @param options defines the options used to create the mesh
  50703. * @param scene defines the hosting scene
  50704. * @returns the extruded shape mesh
  50705. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50707. */
  50708. static ExtrudeShape(name: string, options: {
  50709. shape: Vector3[];
  50710. path: Vector3[];
  50711. scale?: number;
  50712. rotation?: number;
  50713. cap?: number;
  50714. updatable?: boolean;
  50715. sideOrientation?: number;
  50716. frontUVs?: Vector4;
  50717. backUVs?: Vector4;
  50718. instance?: Mesh;
  50719. invertUV?: boolean;
  50720. }, scene?: Nullable<Scene>): Mesh;
  50721. /**
  50722. * Creates an custom extruded shape mesh.
  50723. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50724. * * 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.
  50725. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50726. * * 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
  50727. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50728. * * 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
  50729. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50730. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50731. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50732. * * 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
  50733. * * 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
  50734. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50739. * @param name defines the name of the mesh
  50740. * @param options defines the options used to create the mesh
  50741. * @param scene defines the hosting scene
  50742. * @returns the custom extruded shape mesh
  50743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50744. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50746. */
  50747. static ExtrudeShapeCustom(name: string, options: {
  50748. shape: Vector3[];
  50749. path: Vector3[];
  50750. scaleFunction?: any;
  50751. rotationFunction?: any;
  50752. ribbonCloseArray?: boolean;
  50753. ribbonClosePath?: boolean;
  50754. cap?: number;
  50755. updatable?: boolean;
  50756. sideOrientation?: number;
  50757. frontUVs?: Vector4;
  50758. backUVs?: Vector4;
  50759. instance?: Mesh;
  50760. invertUV?: boolean;
  50761. }, scene: Scene): Mesh;
  50762. private static _ExtrudeShapeGeneric;
  50763. }
  50764. }
  50765. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50766. import { Scene } from "babylonjs/scene";
  50767. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50768. import { Mesh } from "babylonjs/Meshes/mesh";
  50769. /**
  50770. * Class containing static functions to help procedurally build meshes
  50771. */
  50772. export class LatheBuilder {
  50773. /**
  50774. * Creates lathe mesh.
  50775. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50776. * * 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
  50777. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50778. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50779. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50780. * * 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
  50781. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50782. * * 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
  50783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50785. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50787. * @param name defines the name of the mesh
  50788. * @param options defines the options used to create the mesh
  50789. * @param scene defines the hosting scene
  50790. * @returns the lathe mesh
  50791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50792. */
  50793. static CreateLathe(name: string, options: {
  50794. shape: Vector3[];
  50795. radius?: number;
  50796. tessellation?: number;
  50797. clip?: number;
  50798. arc?: number;
  50799. closed?: boolean;
  50800. updatable?: boolean;
  50801. sideOrientation?: number;
  50802. frontUVs?: Vector4;
  50803. backUVs?: Vector4;
  50804. cap?: number;
  50805. invertUV?: boolean;
  50806. }, scene: Scene): Mesh;
  50807. }
  50808. }
  50809. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50810. import { Scene } from "babylonjs/scene";
  50811. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50812. import { Mesh } from "babylonjs/Meshes/mesh";
  50813. /**
  50814. * Class containing static functions to help procedurally build meshes
  50815. */
  50816. export class TubeBuilder {
  50817. /**
  50818. * Creates a tube mesh.
  50819. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50820. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50821. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50822. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50823. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50824. * * 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)
  50825. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50826. * * 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
  50827. * * 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
  50828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50830. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50832. * @param name defines the name of the mesh
  50833. * @param options defines the options used to create the mesh
  50834. * @param scene defines the hosting scene
  50835. * @returns the tube mesh
  50836. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50837. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50838. */
  50839. static CreateTube(name: string, options: {
  50840. path: Vector3[];
  50841. radius?: number;
  50842. tessellation?: number;
  50843. radiusFunction?: {
  50844. (i: number, distance: number): number;
  50845. };
  50846. cap?: number;
  50847. arc?: number;
  50848. updatable?: boolean;
  50849. sideOrientation?: number;
  50850. frontUVs?: Vector4;
  50851. backUVs?: Vector4;
  50852. instance?: Mesh;
  50853. invertUV?: boolean;
  50854. }, scene: Scene): Mesh;
  50855. }
  50856. }
  50857. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50858. import { Scene } from "babylonjs/scene";
  50859. import { Vector4 } from "babylonjs/Maths/math";
  50860. import { Mesh } from "babylonjs/Meshes/mesh";
  50861. /**
  50862. * Class containing static functions to help procedurally build meshes
  50863. */
  50864. export class IcoSphereBuilder {
  50865. /**
  50866. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50867. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50868. * * 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`)
  50869. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50870. * * 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
  50871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50874. * @param name defines the name of the mesh
  50875. * @param options defines the options used to create the mesh
  50876. * @param scene defines the hosting scene
  50877. * @returns the icosahedron mesh
  50878. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50879. */
  50880. static CreateIcoSphere(name: string, options: {
  50881. radius?: number;
  50882. radiusX?: number;
  50883. radiusY?: number;
  50884. radiusZ?: number;
  50885. flat?: boolean;
  50886. subdivisions?: number;
  50887. sideOrientation?: number;
  50888. frontUVs?: Vector4;
  50889. backUVs?: Vector4;
  50890. updatable?: boolean;
  50891. }, scene: Scene): Mesh;
  50892. }
  50893. }
  50894. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50895. import { Vector3 } from "babylonjs/Maths/math";
  50896. import { Mesh } from "babylonjs/Meshes/mesh";
  50897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50898. /**
  50899. * Class containing static functions to help procedurally build meshes
  50900. */
  50901. export class DecalBuilder {
  50902. /**
  50903. * Creates a decal mesh.
  50904. * 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
  50905. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50906. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50907. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50908. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50909. * @param name defines the name of the mesh
  50910. * @param sourceMesh defines the mesh where the decal must be applied
  50911. * @param options defines the options used to create the mesh
  50912. * @param scene defines the hosting scene
  50913. * @returns the decal mesh
  50914. * @see https://doc.babylonjs.com/how_to/decals
  50915. */
  50916. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50917. position?: Vector3;
  50918. normal?: Vector3;
  50919. size?: Vector3;
  50920. angle?: number;
  50921. }): Mesh;
  50922. }
  50923. }
  50924. declare module "babylonjs/Meshes/meshBuilder" {
  50925. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50926. import { Nullable } from "babylonjs/types";
  50927. import { Scene } from "babylonjs/scene";
  50928. import { Mesh } from "babylonjs/Meshes/mesh";
  50929. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50930. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50932. /**
  50933. * Class containing static functions to help procedurally build meshes
  50934. */
  50935. export class MeshBuilder {
  50936. /**
  50937. * Creates a box mesh
  50938. * * The parameter `size` sets the size (float) of each box side (default 1)
  50939. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50940. * * 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)
  50941. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50945. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50946. * @param name defines the name of the mesh
  50947. * @param options defines the options used to create the mesh
  50948. * @param scene defines the hosting scene
  50949. * @returns the box mesh
  50950. */
  50951. static CreateBox(name: string, options: {
  50952. size?: number;
  50953. width?: number;
  50954. height?: number;
  50955. depth?: number;
  50956. faceUV?: Vector4[];
  50957. faceColors?: Color4[];
  50958. sideOrientation?: number;
  50959. frontUVs?: Vector4;
  50960. backUVs?: Vector4;
  50961. updatable?: boolean;
  50962. }, scene?: Nullable<Scene>): Mesh;
  50963. /**
  50964. * Creates a sphere mesh
  50965. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50966. * * 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`)
  50967. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50968. * * 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
  50969. * * 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)
  50970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50973. * @param name defines the name of the mesh
  50974. * @param options defines the options used to create the mesh
  50975. * @param scene defines the hosting scene
  50976. * @returns the sphere mesh
  50977. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50978. */
  50979. static CreateSphere(name: string, options: {
  50980. segments?: number;
  50981. diameter?: number;
  50982. diameterX?: number;
  50983. diameterY?: number;
  50984. diameterZ?: number;
  50985. arc?: number;
  50986. slice?: number;
  50987. sideOrientation?: number;
  50988. frontUVs?: Vector4;
  50989. backUVs?: Vector4;
  50990. updatable?: boolean;
  50991. }, scene: any): Mesh;
  50992. /**
  50993. * Creates a plane polygonal mesh. By default, this is a disc
  50994. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50995. * * 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
  50996. * * 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
  50997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51000. * @param name defines the name of the mesh
  51001. * @param options defines the options used to create the mesh
  51002. * @param scene defines the hosting scene
  51003. * @returns the plane polygonal mesh
  51004. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51005. */
  51006. static CreateDisc(name: string, options: {
  51007. radius?: number;
  51008. tessellation?: number;
  51009. arc?: number;
  51010. updatable?: boolean;
  51011. sideOrientation?: number;
  51012. frontUVs?: Vector4;
  51013. backUVs?: Vector4;
  51014. }, scene?: Nullable<Scene>): Mesh;
  51015. /**
  51016. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51017. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51018. * * 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`)
  51019. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51020. * * 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
  51021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51024. * @param name defines the name of the mesh
  51025. * @param options defines the options used to create the mesh
  51026. * @param scene defines the hosting scene
  51027. * @returns the icosahedron mesh
  51028. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51029. */
  51030. static CreateIcoSphere(name: string, options: {
  51031. radius?: number;
  51032. radiusX?: number;
  51033. radiusY?: number;
  51034. radiusZ?: number;
  51035. flat?: boolean;
  51036. subdivisions?: number;
  51037. sideOrientation?: number;
  51038. frontUVs?: Vector4;
  51039. backUVs?: Vector4;
  51040. updatable?: boolean;
  51041. }, scene: Scene): Mesh;
  51042. /**
  51043. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51044. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51045. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51046. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51047. * * 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
  51048. * * 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
  51049. * * 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
  51050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51053. * * 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
  51054. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51055. * * 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
  51056. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51058. * @param name defines the name of the mesh
  51059. * @param options defines the options used to create the mesh
  51060. * @param scene defines the hosting scene
  51061. * @returns the ribbon mesh
  51062. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51064. */
  51065. static CreateRibbon(name: string, options: {
  51066. pathArray: Vector3[][];
  51067. closeArray?: boolean;
  51068. closePath?: boolean;
  51069. offset?: number;
  51070. updatable?: boolean;
  51071. sideOrientation?: number;
  51072. frontUVs?: Vector4;
  51073. backUVs?: Vector4;
  51074. instance?: Mesh;
  51075. invertUV?: boolean;
  51076. uvs?: Vector2[];
  51077. colors?: Color4[];
  51078. }, scene?: Nullable<Scene>): Mesh;
  51079. /**
  51080. * Creates a cylinder or a cone mesh
  51081. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51082. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51083. * * 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.
  51084. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51085. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51086. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51087. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51088. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51089. * * 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).
  51090. * * 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
  51091. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51092. * * 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
  51093. * * 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.
  51094. * * If `enclose` is false, a ring surface is one element.
  51095. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51096. * * 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
  51097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51100. * @param name defines the name of the mesh
  51101. * @param options defines the options used to create the mesh
  51102. * @param scene defines the hosting scene
  51103. * @returns the cylinder mesh
  51104. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51105. */
  51106. static CreateCylinder(name: string, options: {
  51107. height?: number;
  51108. diameterTop?: number;
  51109. diameterBottom?: number;
  51110. diameter?: number;
  51111. tessellation?: number;
  51112. subdivisions?: number;
  51113. arc?: number;
  51114. faceColors?: Color4[];
  51115. faceUV?: Vector4[];
  51116. updatable?: boolean;
  51117. hasRings?: boolean;
  51118. enclose?: boolean;
  51119. sideOrientation?: number;
  51120. frontUVs?: Vector4;
  51121. backUVs?: Vector4;
  51122. }, scene: any): Mesh;
  51123. /**
  51124. * Creates a torus mesh
  51125. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51126. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51127. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51131. * @param name defines the name of the mesh
  51132. * @param options defines the options used to create the mesh
  51133. * @param scene defines the hosting scene
  51134. * @returns the torus mesh
  51135. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51136. */
  51137. static CreateTorus(name: string, options: {
  51138. diameter?: number;
  51139. thickness?: number;
  51140. tessellation?: number;
  51141. updatable?: boolean;
  51142. sideOrientation?: number;
  51143. frontUVs?: Vector4;
  51144. backUVs?: Vector4;
  51145. }, scene: any): Mesh;
  51146. /**
  51147. * Creates a torus knot mesh
  51148. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51149. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51150. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51151. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51155. * @param name defines the name of the mesh
  51156. * @param options defines the options used to create the mesh
  51157. * @param scene defines the hosting scene
  51158. * @returns the torus knot mesh
  51159. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51160. */
  51161. static CreateTorusKnot(name: string, options: {
  51162. radius?: number;
  51163. tube?: number;
  51164. radialSegments?: number;
  51165. tubularSegments?: number;
  51166. p?: number;
  51167. q?: number;
  51168. updatable?: boolean;
  51169. sideOrientation?: number;
  51170. frontUVs?: Vector4;
  51171. backUVs?: Vector4;
  51172. }, scene: any): Mesh;
  51173. /**
  51174. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51175. * * 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
  51176. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51177. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51178. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51179. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51180. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51181. * * 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
  51182. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51184. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51185. * @param name defines the name of the new line system
  51186. * @param options defines the options used to create the line system
  51187. * @param scene defines the hosting scene
  51188. * @returns a new line system mesh
  51189. */
  51190. static CreateLineSystem(name: string, options: {
  51191. lines: Vector3[][];
  51192. updatable?: boolean;
  51193. instance?: Nullable<LinesMesh>;
  51194. colors?: Nullable<Color4[][]>;
  51195. useVertexAlpha?: boolean;
  51196. }, scene: Nullable<Scene>): LinesMesh;
  51197. /**
  51198. * Creates a line mesh
  51199. * 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
  51200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51201. * * The parameter `points` is an array successive Vector3
  51202. * * 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
  51203. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51205. * * When updating an instance, remember that only point positions can change, not the number of points
  51206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51207. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51208. * @param name defines the name of the new line system
  51209. * @param options defines the options used to create the line system
  51210. * @param scene defines the hosting scene
  51211. * @returns a new line mesh
  51212. */
  51213. static CreateLines(name: string, options: {
  51214. points: Vector3[];
  51215. updatable?: boolean;
  51216. instance?: Nullable<LinesMesh>;
  51217. colors?: Color4[];
  51218. useVertexAlpha?: boolean;
  51219. }, scene?: Nullable<Scene>): LinesMesh;
  51220. /**
  51221. * Creates a dashed line mesh
  51222. * * 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
  51223. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51224. * * The parameter `points` is an array successive Vector3
  51225. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51226. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51227. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51228. * * 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
  51229. * * When updating an instance, remember that only point positions can change, not the number of points
  51230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51231. * @param name defines the name of the mesh
  51232. * @param options defines the options used to create the mesh
  51233. * @param scene defines the hosting scene
  51234. * @returns the dashed line mesh
  51235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51236. */
  51237. static CreateDashedLines(name: string, options: {
  51238. points: Vector3[];
  51239. dashSize?: number;
  51240. gapSize?: number;
  51241. dashNb?: number;
  51242. updatable?: boolean;
  51243. instance?: LinesMesh;
  51244. }, scene?: Nullable<Scene>): LinesMesh;
  51245. /**
  51246. * 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.
  51247. * * 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.
  51248. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51249. * * 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.
  51250. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51251. * * 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
  51252. * * 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
  51253. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51258. * @param name defines the name of the mesh
  51259. * @param options defines the options used to create the mesh
  51260. * @param scene defines the hosting scene
  51261. * @returns the extruded shape mesh
  51262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51264. */
  51265. static ExtrudeShape(name: string, options: {
  51266. shape: Vector3[];
  51267. path: Vector3[];
  51268. scale?: number;
  51269. rotation?: number;
  51270. cap?: number;
  51271. updatable?: boolean;
  51272. sideOrientation?: number;
  51273. frontUVs?: Vector4;
  51274. backUVs?: Vector4;
  51275. instance?: Mesh;
  51276. invertUV?: boolean;
  51277. }, scene?: Nullable<Scene>): Mesh;
  51278. /**
  51279. * Creates an custom extruded shape mesh.
  51280. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51281. * * 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.
  51282. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51283. * * 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
  51284. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51285. * * 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
  51286. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51287. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51288. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51289. * * 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
  51290. * * 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
  51291. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51296. * @param name defines the name of the mesh
  51297. * @param options defines the options used to create the mesh
  51298. * @param scene defines the hosting scene
  51299. * @returns the custom extruded shape mesh
  51300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51303. */
  51304. static ExtrudeShapeCustom(name: string, options: {
  51305. shape: Vector3[];
  51306. path: Vector3[];
  51307. scaleFunction?: any;
  51308. rotationFunction?: any;
  51309. ribbonCloseArray?: boolean;
  51310. ribbonClosePath?: boolean;
  51311. cap?: number;
  51312. updatable?: boolean;
  51313. sideOrientation?: number;
  51314. frontUVs?: Vector4;
  51315. backUVs?: Vector4;
  51316. instance?: Mesh;
  51317. invertUV?: boolean;
  51318. }, scene: Scene): Mesh;
  51319. /**
  51320. * Creates lathe mesh.
  51321. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51322. * * 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
  51323. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51324. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51325. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51326. * * 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
  51327. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51328. * * 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
  51329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51331. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51333. * @param name defines the name of the mesh
  51334. * @param options defines the options used to create the mesh
  51335. * @param scene defines the hosting scene
  51336. * @returns the lathe mesh
  51337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51338. */
  51339. static CreateLathe(name: string, options: {
  51340. shape: Vector3[];
  51341. radius?: number;
  51342. tessellation?: number;
  51343. clip?: number;
  51344. arc?: number;
  51345. closed?: boolean;
  51346. updatable?: boolean;
  51347. sideOrientation?: number;
  51348. frontUVs?: Vector4;
  51349. backUVs?: Vector4;
  51350. cap?: number;
  51351. invertUV?: boolean;
  51352. }, scene: Scene): Mesh;
  51353. /**
  51354. * Creates a plane mesh
  51355. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51356. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51357. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51361. * @param name defines the name of the mesh
  51362. * @param options defines the options used to create the mesh
  51363. * @param scene defines the hosting scene
  51364. * @returns the plane mesh
  51365. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51366. */
  51367. static CreatePlane(name: string, options: {
  51368. size?: number;
  51369. width?: number;
  51370. height?: number;
  51371. sideOrientation?: number;
  51372. frontUVs?: Vector4;
  51373. backUVs?: Vector4;
  51374. updatable?: boolean;
  51375. sourcePlane?: Plane;
  51376. }, scene: Scene): Mesh;
  51377. /**
  51378. * Creates a ground mesh
  51379. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51380. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51382. * @param name defines the name of the mesh
  51383. * @param options defines the options used to create the mesh
  51384. * @param scene defines the hosting scene
  51385. * @returns the ground mesh
  51386. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51387. */
  51388. static CreateGround(name: string, options: {
  51389. width?: number;
  51390. height?: number;
  51391. subdivisions?: number;
  51392. subdivisionsX?: number;
  51393. subdivisionsY?: number;
  51394. updatable?: boolean;
  51395. }, scene: any): Mesh;
  51396. /**
  51397. * Creates a tiled ground mesh
  51398. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51399. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51400. * * 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
  51401. * * 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
  51402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51403. * @param name defines the name of the mesh
  51404. * @param options defines the options used to create the mesh
  51405. * @param scene defines the hosting scene
  51406. * @returns the tiled ground mesh
  51407. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51408. */
  51409. static CreateTiledGround(name: string, options: {
  51410. xmin: number;
  51411. zmin: number;
  51412. xmax: number;
  51413. zmax: number;
  51414. subdivisions?: {
  51415. w: number;
  51416. h: number;
  51417. };
  51418. precision?: {
  51419. w: number;
  51420. h: number;
  51421. };
  51422. updatable?: boolean;
  51423. }, scene: Scene): Mesh;
  51424. /**
  51425. * Creates a ground mesh from a height map
  51426. * * The parameter `url` sets the URL of the height map image resource.
  51427. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51428. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51429. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51430. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51431. * * 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.
  51432. * * 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).
  51433. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51435. * @param name defines the name of the mesh
  51436. * @param url defines the url to the height map
  51437. * @param options defines the options used to create the mesh
  51438. * @param scene defines the hosting scene
  51439. * @returns the ground mesh
  51440. * @see https://doc.babylonjs.com/babylon101/height_map
  51441. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51442. */
  51443. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51444. width?: number;
  51445. height?: number;
  51446. subdivisions?: number;
  51447. minHeight?: number;
  51448. maxHeight?: number;
  51449. colorFilter?: Color3;
  51450. alphaFilter?: number;
  51451. updatable?: boolean;
  51452. onReady?: (mesh: GroundMesh) => void;
  51453. }, scene: Scene): GroundMesh;
  51454. /**
  51455. * Creates a polygon mesh
  51456. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51457. * * 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
  51458. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51461. * * Remember you can only change the shape positions, not their number when updating a polygon
  51462. * @param name defines the name of the mesh
  51463. * @param options defines the options used to create the mesh
  51464. * @param scene defines the hosting scene
  51465. * @param earcutInjection can be used to inject your own earcut reference
  51466. * @returns the polygon mesh
  51467. */
  51468. static CreatePolygon(name: string, options: {
  51469. shape: Vector3[];
  51470. holes?: Vector3[][];
  51471. depth?: number;
  51472. faceUV?: Vector4[];
  51473. faceColors?: Color4[];
  51474. updatable?: boolean;
  51475. sideOrientation?: number;
  51476. frontUVs?: Vector4;
  51477. backUVs?: Vector4;
  51478. }, scene: Scene, earcutInjection?: any): Mesh;
  51479. /**
  51480. * Creates an extruded polygon mesh, with depth in the Y direction.
  51481. * * 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)
  51482. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51483. * @param name defines the name of the mesh
  51484. * @param options defines the options used to create the mesh
  51485. * @param scene defines the hosting scene
  51486. * @param earcutInjection can be used to inject your own earcut reference
  51487. * @returns the polygon mesh
  51488. */
  51489. static ExtrudePolygon(name: string, options: {
  51490. shape: Vector3[];
  51491. holes?: Vector3[][];
  51492. depth?: number;
  51493. faceUV?: Vector4[];
  51494. faceColors?: Color4[];
  51495. updatable?: boolean;
  51496. sideOrientation?: number;
  51497. frontUVs?: Vector4;
  51498. backUVs?: Vector4;
  51499. }, scene: Scene, earcutInjection?: any): Mesh;
  51500. /**
  51501. * Creates a tube mesh.
  51502. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51503. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51504. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51505. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51506. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51507. * * 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)
  51508. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51509. * * 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
  51510. * * 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
  51511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51513. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51515. * @param name defines the name of the mesh
  51516. * @param options defines the options used to create the mesh
  51517. * @param scene defines the hosting scene
  51518. * @returns the tube mesh
  51519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51520. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51521. */
  51522. static CreateTube(name: string, options: {
  51523. path: Vector3[];
  51524. radius?: number;
  51525. tessellation?: number;
  51526. radiusFunction?: {
  51527. (i: number, distance: number): number;
  51528. };
  51529. cap?: number;
  51530. arc?: number;
  51531. updatable?: boolean;
  51532. sideOrientation?: number;
  51533. frontUVs?: Vector4;
  51534. backUVs?: Vector4;
  51535. instance?: Mesh;
  51536. invertUV?: boolean;
  51537. }, scene: Scene): Mesh;
  51538. /**
  51539. * Creates a polyhedron mesh
  51540. * * 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
  51541. * * The parameter `size` (positive float, default 1) sets the polygon size
  51542. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51543. * * 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`
  51544. * * 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
  51545. * * 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)`)
  51546. * * 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
  51547. * * 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
  51548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51551. * @param name defines the name of the mesh
  51552. * @param options defines the options used to create the mesh
  51553. * @param scene defines the hosting scene
  51554. * @returns the polyhedron mesh
  51555. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51556. */
  51557. static CreatePolyhedron(name: string, options: {
  51558. type?: number;
  51559. size?: number;
  51560. sizeX?: number;
  51561. sizeY?: number;
  51562. sizeZ?: number;
  51563. custom?: any;
  51564. faceUV?: Vector4[];
  51565. faceColors?: Color4[];
  51566. flat?: boolean;
  51567. updatable?: boolean;
  51568. sideOrientation?: number;
  51569. frontUVs?: Vector4;
  51570. backUVs?: Vector4;
  51571. }, scene: Scene): Mesh;
  51572. /**
  51573. * Creates a decal mesh.
  51574. * 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
  51575. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51576. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51577. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51578. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51579. * @param name defines the name of the mesh
  51580. * @param sourceMesh defines the mesh where the decal must be applied
  51581. * @param options defines the options used to create the mesh
  51582. * @param scene defines the hosting scene
  51583. * @returns the decal mesh
  51584. * @see https://doc.babylonjs.com/how_to/decals
  51585. */
  51586. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51587. position?: Vector3;
  51588. normal?: Vector3;
  51589. size?: Vector3;
  51590. angle?: number;
  51591. }): Mesh;
  51592. }
  51593. }
  51594. declare module "babylonjs/Meshes/meshSimplification" {
  51595. import { Mesh } from "babylonjs/Meshes/mesh";
  51596. /**
  51597. * A simplifier interface for future simplification implementations
  51598. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51599. */
  51600. export interface ISimplifier {
  51601. /**
  51602. * Simplification of a given mesh according to the given settings.
  51603. * Since this requires computation, it is assumed that the function runs async.
  51604. * @param settings The settings of the simplification, including quality and distance
  51605. * @param successCallback A callback that will be called after the mesh was simplified.
  51606. * @param errorCallback in case of an error, this callback will be called. optional.
  51607. */
  51608. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51609. }
  51610. /**
  51611. * Expected simplification settings.
  51612. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51613. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51614. */
  51615. export interface ISimplificationSettings {
  51616. /**
  51617. * Gets or sets the expected quality
  51618. */
  51619. quality: number;
  51620. /**
  51621. * Gets or sets the distance when this optimized version should be used
  51622. */
  51623. distance: number;
  51624. /**
  51625. * Gets an already optimized mesh
  51626. */
  51627. optimizeMesh?: boolean;
  51628. }
  51629. /**
  51630. * Class used to specify simplification options
  51631. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51632. */
  51633. export class SimplificationSettings implements ISimplificationSettings {
  51634. /** expected quality */
  51635. quality: number;
  51636. /** distance when this optimized version should be used */
  51637. distance: number;
  51638. /** already optimized mesh */
  51639. optimizeMesh?: boolean | undefined;
  51640. /**
  51641. * Creates a SimplificationSettings
  51642. * @param quality expected quality
  51643. * @param distance distance when this optimized version should be used
  51644. * @param optimizeMesh already optimized mesh
  51645. */
  51646. constructor(
  51647. /** expected quality */
  51648. quality: number,
  51649. /** distance when this optimized version should be used */
  51650. distance: number,
  51651. /** already optimized mesh */
  51652. optimizeMesh?: boolean | undefined);
  51653. }
  51654. /**
  51655. * Interface used to define a simplification task
  51656. */
  51657. export interface ISimplificationTask {
  51658. /**
  51659. * Array of settings
  51660. */
  51661. settings: Array<ISimplificationSettings>;
  51662. /**
  51663. * Simplification type
  51664. */
  51665. simplificationType: SimplificationType;
  51666. /**
  51667. * Mesh to simplify
  51668. */
  51669. mesh: Mesh;
  51670. /**
  51671. * Callback called on success
  51672. */
  51673. successCallback?: () => void;
  51674. /**
  51675. * Defines if parallel processing can be used
  51676. */
  51677. parallelProcessing: boolean;
  51678. }
  51679. /**
  51680. * Queue used to order the simplification tasks
  51681. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51682. */
  51683. export class SimplificationQueue {
  51684. private _simplificationArray;
  51685. /**
  51686. * Gets a boolean indicating that the process is still running
  51687. */
  51688. running: boolean;
  51689. /**
  51690. * Creates a new queue
  51691. */
  51692. constructor();
  51693. /**
  51694. * Adds a new simplification task
  51695. * @param task defines a task to add
  51696. */
  51697. addTask(task: ISimplificationTask): void;
  51698. /**
  51699. * Execute next task
  51700. */
  51701. executeNext(): void;
  51702. /**
  51703. * Execute a simplification task
  51704. * @param task defines the task to run
  51705. */
  51706. runSimplification(task: ISimplificationTask): void;
  51707. private getSimplifier;
  51708. }
  51709. /**
  51710. * The implemented types of simplification
  51711. * At the moment only Quadratic Error Decimation is implemented
  51712. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51713. */
  51714. export enum SimplificationType {
  51715. /** Quadratic error decimation */
  51716. QUADRATIC = 0
  51717. }
  51718. }
  51719. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51720. import { Scene } from "babylonjs/scene";
  51721. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51722. import { ISceneComponent } from "babylonjs/sceneComponent";
  51723. module "babylonjs/scene" {
  51724. interface Scene {
  51725. /** @hidden (Backing field) */
  51726. _simplificationQueue: SimplificationQueue;
  51727. /**
  51728. * Gets or sets the simplification queue attached to the scene
  51729. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51730. */
  51731. simplificationQueue: SimplificationQueue;
  51732. }
  51733. }
  51734. module "babylonjs/Meshes/mesh" {
  51735. interface Mesh {
  51736. /**
  51737. * Simplify the mesh according to the given array of settings.
  51738. * Function will return immediately and will simplify async
  51739. * @param settings a collection of simplification settings
  51740. * @param parallelProcessing should all levels calculate parallel or one after the other
  51741. * @param simplificationType the type of simplification to run
  51742. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51743. * @returns the current mesh
  51744. */
  51745. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51746. }
  51747. }
  51748. /**
  51749. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51750. * created in a scene
  51751. */
  51752. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51753. /**
  51754. * The component name helpfull to identify the component in the list of scene components.
  51755. */
  51756. readonly name: string;
  51757. /**
  51758. * The scene the component belongs to.
  51759. */
  51760. scene: Scene;
  51761. /**
  51762. * Creates a new instance of the component for the given scene
  51763. * @param scene Defines the scene to register the component in
  51764. */
  51765. constructor(scene: Scene);
  51766. /**
  51767. * Registers the component in a given scene
  51768. */
  51769. register(): void;
  51770. /**
  51771. * Rebuilds the elements related to this component in case of
  51772. * context lost for instance.
  51773. */
  51774. rebuild(): void;
  51775. /**
  51776. * Disposes the component and the associated ressources
  51777. */
  51778. dispose(): void;
  51779. private _beforeCameraUpdate;
  51780. }
  51781. }
  51782. declare module "babylonjs/Meshes/Builders/index" {
  51783. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51784. export * from "babylonjs/Meshes/Builders/discBuilder";
  51785. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51786. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51787. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51788. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51789. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51790. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51791. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51792. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51793. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51794. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51795. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51796. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51797. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51798. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51799. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51800. }
  51801. declare module "babylonjs/Meshes/index" {
  51802. export * from "babylonjs/Meshes/abstractMesh";
  51803. export * from "babylonjs/Meshes/buffer";
  51804. export * from "babylonjs/Meshes/Compression/index";
  51805. export * from "babylonjs/Meshes/csg";
  51806. export * from "babylonjs/Meshes/geometry";
  51807. export * from "babylonjs/Meshes/groundMesh";
  51808. export * from "babylonjs/Meshes/trailMesh";
  51809. export * from "babylonjs/Meshes/instancedMesh";
  51810. export * from "babylonjs/Meshes/linesMesh";
  51811. export * from "babylonjs/Meshes/mesh";
  51812. export * from "babylonjs/Meshes/mesh.vertexData";
  51813. export * from "babylonjs/Meshes/meshBuilder";
  51814. export * from "babylonjs/Meshes/meshSimplification";
  51815. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51816. export * from "babylonjs/Meshes/polygonMesh";
  51817. export * from "babylonjs/Meshes/subMesh";
  51818. export * from "babylonjs/Meshes/transformNode";
  51819. export * from "babylonjs/Meshes/Builders/index";
  51820. }
  51821. declare module "babylonjs/Morph/index" {
  51822. export * from "babylonjs/Morph/morphTarget";
  51823. export * from "babylonjs/Morph/morphTargetManager";
  51824. }
  51825. declare module "babylonjs/Offline/database" {
  51826. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51827. /**
  51828. * Class used to enable access to IndexedDB
  51829. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51830. */
  51831. export class Database implements IOfflineProvider {
  51832. private _callbackManifestChecked;
  51833. private _currentSceneUrl;
  51834. private _db;
  51835. private _enableSceneOffline;
  51836. private _enableTexturesOffline;
  51837. private _manifestVersionFound;
  51838. private _mustUpdateRessources;
  51839. private _hasReachedQuota;
  51840. private _isSupported;
  51841. private _idbFactory;
  51842. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51843. private static IsUASupportingBlobStorage;
  51844. /**
  51845. * Gets a boolean indicating if Database storate is enabled (off by default)
  51846. */
  51847. static IDBStorageEnabled: boolean;
  51848. /**
  51849. * Gets a boolean indicating if scene must be saved in the database
  51850. */
  51851. readonly enableSceneOffline: boolean;
  51852. /**
  51853. * Gets a boolean indicating if textures must be saved in the database
  51854. */
  51855. readonly enableTexturesOffline: boolean;
  51856. /**
  51857. * Creates a new Database
  51858. * @param urlToScene defines the url to load the scene
  51859. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51860. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51861. */
  51862. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51863. private static _ParseURL;
  51864. private static _ReturnFullUrlLocation;
  51865. private _checkManifestFile;
  51866. /**
  51867. * Open the database and make it available
  51868. * @param successCallback defines the callback to call on success
  51869. * @param errorCallback defines the callback to call on error
  51870. */
  51871. open(successCallback: () => void, errorCallback: () => void): void;
  51872. /**
  51873. * Loads an image from the database
  51874. * @param url defines the url to load from
  51875. * @param image defines the target DOM image
  51876. */
  51877. loadImage(url: string, image: HTMLImageElement): void;
  51878. private _loadImageFromDBAsync;
  51879. private _saveImageIntoDBAsync;
  51880. private _checkVersionFromDB;
  51881. private _loadVersionFromDBAsync;
  51882. private _saveVersionIntoDBAsync;
  51883. /**
  51884. * Loads a file from database
  51885. * @param url defines the URL to load from
  51886. * @param sceneLoaded defines a callback to call on success
  51887. * @param progressCallBack defines a callback to call when progress changed
  51888. * @param errorCallback defines a callback to call on error
  51889. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51890. */
  51891. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51892. private _loadFileAsync;
  51893. private _saveFileAsync;
  51894. /**
  51895. * Validates if xhr data is correct
  51896. * @param xhr defines the request to validate
  51897. * @param dataType defines the expected data type
  51898. * @returns true if data is correct
  51899. */
  51900. private static _ValidateXHRData;
  51901. }
  51902. }
  51903. declare module "babylonjs/Offline/index" {
  51904. export * from "babylonjs/Offline/database";
  51905. export * from "babylonjs/Offline/IOfflineProvider";
  51906. }
  51907. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51908. /** @hidden */
  51909. export var gpuUpdateParticlesPixelShader: {
  51910. name: string;
  51911. shader: string;
  51912. };
  51913. }
  51914. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51915. /** @hidden */
  51916. export var gpuUpdateParticlesVertexShader: {
  51917. name: string;
  51918. shader: string;
  51919. };
  51920. }
  51921. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51922. /** @hidden */
  51923. export var clipPlaneFragmentDeclaration2: {
  51924. name: string;
  51925. shader: string;
  51926. };
  51927. }
  51928. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51929. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51930. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51931. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51932. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51933. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51934. /** @hidden */
  51935. export var gpuRenderParticlesPixelShader: {
  51936. name: string;
  51937. shader: string;
  51938. };
  51939. }
  51940. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51941. /** @hidden */
  51942. export var clipPlaneVertexDeclaration2: {
  51943. name: string;
  51944. shader: string;
  51945. };
  51946. }
  51947. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51948. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51949. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51950. /** @hidden */
  51951. export var gpuRenderParticlesVertexShader: {
  51952. name: string;
  51953. shader: string;
  51954. };
  51955. }
  51956. declare module "babylonjs/Particles/gpuParticleSystem" {
  51957. import { Nullable } from "babylonjs/types";
  51958. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51959. import { Observable } from "babylonjs/Misc/observable";
  51960. import { Color4, Color3 } from "babylonjs/Maths/math";
  51961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51962. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51963. import { Scene, IDisposable } from "babylonjs/scene";
  51964. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51965. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51966. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51967. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51968. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51969. /**
  51970. * This represents a GPU particle system in Babylon
  51971. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51972. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51973. */
  51974. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51975. /**
  51976. * The layer mask we are rendering the particles through.
  51977. */
  51978. layerMask: number;
  51979. private _capacity;
  51980. private _activeCount;
  51981. private _currentActiveCount;
  51982. private _accumulatedCount;
  51983. private _renderEffect;
  51984. private _updateEffect;
  51985. private _buffer0;
  51986. private _buffer1;
  51987. private _spriteBuffer;
  51988. private _updateVAO;
  51989. private _renderVAO;
  51990. private _targetIndex;
  51991. private _sourceBuffer;
  51992. private _targetBuffer;
  51993. private _engine;
  51994. private _currentRenderId;
  51995. private _started;
  51996. private _stopped;
  51997. private _timeDelta;
  51998. private _randomTexture;
  51999. private _randomTexture2;
  52000. private _attributesStrideSize;
  52001. private _updateEffectOptions;
  52002. private _randomTextureSize;
  52003. private _actualFrame;
  52004. private readonly _rawTextureWidth;
  52005. /**
  52006. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52007. */
  52008. static readonly IsSupported: boolean;
  52009. /**
  52010. * An event triggered when the system is disposed.
  52011. */
  52012. onDisposeObservable: Observable<GPUParticleSystem>;
  52013. /**
  52014. * Gets the maximum number of particles active at the same time.
  52015. * @returns The max number of active particles.
  52016. */
  52017. getCapacity(): number;
  52018. /**
  52019. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52020. * to override the particles.
  52021. */
  52022. forceDepthWrite: boolean;
  52023. /**
  52024. * Gets or set the number of active particles
  52025. */
  52026. activeParticleCount: number;
  52027. private _preWarmDone;
  52028. /**
  52029. * Is this system ready to be used/rendered
  52030. * @return true if the system is ready
  52031. */
  52032. isReady(): boolean;
  52033. /**
  52034. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52035. * @returns True if it has been started, otherwise false.
  52036. */
  52037. isStarted(): boolean;
  52038. /**
  52039. * Starts the particle system and begins to emit
  52040. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52041. */
  52042. start(delay?: number): void;
  52043. /**
  52044. * Stops the particle system.
  52045. */
  52046. stop(): void;
  52047. /**
  52048. * Remove all active particles
  52049. */
  52050. reset(): void;
  52051. /**
  52052. * Returns the string "GPUParticleSystem"
  52053. * @returns a string containing the class name
  52054. */
  52055. getClassName(): string;
  52056. private _colorGradientsTexture;
  52057. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52058. /**
  52059. * Adds a new color gradient
  52060. * @param gradient defines the gradient to use (between 0 and 1)
  52061. * @param color1 defines the color to affect to the specified gradient
  52062. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52063. * @returns the current particle system
  52064. */
  52065. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52066. /**
  52067. * Remove a specific color gradient
  52068. * @param gradient defines the gradient to remove
  52069. * @returns the current particle system
  52070. */
  52071. removeColorGradient(gradient: number): GPUParticleSystem;
  52072. private _angularSpeedGradientsTexture;
  52073. private _sizeGradientsTexture;
  52074. private _velocityGradientsTexture;
  52075. private _limitVelocityGradientsTexture;
  52076. private _dragGradientsTexture;
  52077. private _addFactorGradient;
  52078. /**
  52079. * Adds a new size gradient
  52080. * @param gradient defines the gradient to use (between 0 and 1)
  52081. * @param factor defines the size factor to affect to the specified gradient
  52082. * @returns the current particle system
  52083. */
  52084. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52085. /**
  52086. * Remove a specific size gradient
  52087. * @param gradient defines the gradient to remove
  52088. * @returns the current particle system
  52089. */
  52090. removeSizeGradient(gradient: number): GPUParticleSystem;
  52091. /**
  52092. * Adds a new angular speed gradient
  52093. * @param gradient defines the gradient to use (between 0 and 1)
  52094. * @param factor defines the angular speed to affect to the specified gradient
  52095. * @returns the current particle system
  52096. */
  52097. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52098. /**
  52099. * Remove a specific angular speed gradient
  52100. * @param gradient defines the gradient to remove
  52101. * @returns the current particle system
  52102. */
  52103. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52104. /**
  52105. * Adds a new velocity gradient
  52106. * @param gradient defines the gradient to use (between 0 and 1)
  52107. * @param factor defines the velocity to affect to the specified gradient
  52108. * @returns the current particle system
  52109. */
  52110. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52111. /**
  52112. * Remove a specific velocity gradient
  52113. * @param gradient defines the gradient to remove
  52114. * @returns the current particle system
  52115. */
  52116. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52117. /**
  52118. * Adds a new limit velocity gradient
  52119. * @param gradient defines the gradient to use (between 0 and 1)
  52120. * @param factor defines the limit velocity value to affect to the specified gradient
  52121. * @returns the current particle system
  52122. */
  52123. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52124. /**
  52125. * Remove a specific limit velocity gradient
  52126. * @param gradient defines the gradient to remove
  52127. * @returns the current particle system
  52128. */
  52129. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52130. /**
  52131. * Adds a new drag gradient
  52132. * @param gradient defines the gradient to use (between 0 and 1)
  52133. * @param factor defines the drag value to affect to the specified gradient
  52134. * @returns the current particle system
  52135. */
  52136. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52137. /**
  52138. * Remove a specific drag gradient
  52139. * @param gradient defines the gradient to remove
  52140. * @returns the current particle system
  52141. */
  52142. removeDragGradient(gradient: number): GPUParticleSystem;
  52143. /**
  52144. * Not supported by GPUParticleSystem
  52145. * @param gradient defines the gradient to use (between 0 and 1)
  52146. * @param factor defines the emit rate value to affect to the specified gradient
  52147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52148. * @returns the current particle system
  52149. */
  52150. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52151. /**
  52152. * Not supported by GPUParticleSystem
  52153. * @param gradient defines the gradient to remove
  52154. * @returns the current particle system
  52155. */
  52156. removeEmitRateGradient(gradient: number): IParticleSystem;
  52157. /**
  52158. * Not supported by GPUParticleSystem
  52159. * @param gradient defines the gradient to use (between 0 and 1)
  52160. * @param factor defines the start size value to affect to the specified gradient
  52161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52162. * @returns the current particle system
  52163. */
  52164. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52165. /**
  52166. * Not supported by GPUParticleSystem
  52167. * @param gradient defines the gradient to remove
  52168. * @returns the current particle system
  52169. */
  52170. removeStartSizeGradient(gradient: number): IParticleSystem;
  52171. /**
  52172. * Not supported by GPUParticleSystem
  52173. * @param gradient defines the gradient to use (between 0 and 1)
  52174. * @param min defines the color remap minimal range
  52175. * @param max defines the color remap maximal range
  52176. * @returns the current particle system
  52177. */
  52178. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52179. /**
  52180. * Not supported by GPUParticleSystem
  52181. * @param gradient defines the gradient to remove
  52182. * @returns the current particle system
  52183. */
  52184. removeColorRemapGradient(): IParticleSystem;
  52185. /**
  52186. * Not supported by GPUParticleSystem
  52187. * @param gradient defines the gradient to use (between 0 and 1)
  52188. * @param min defines the alpha remap minimal range
  52189. * @param max defines the alpha remap maximal range
  52190. * @returns the current particle system
  52191. */
  52192. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52193. /**
  52194. * Not supported by GPUParticleSystem
  52195. * @param gradient defines the gradient to remove
  52196. * @returns the current particle system
  52197. */
  52198. removeAlphaRemapGradient(): IParticleSystem;
  52199. /**
  52200. * Not supported by GPUParticleSystem
  52201. * @param gradient defines the gradient to use (between 0 and 1)
  52202. * @param color defines the color to affect to the specified gradient
  52203. * @returns the current particle system
  52204. */
  52205. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52206. /**
  52207. * Not supported by GPUParticleSystem
  52208. * @param gradient defines the gradient to remove
  52209. * @returns the current particle system
  52210. */
  52211. removeRampGradient(): IParticleSystem;
  52212. /**
  52213. * Not supported by GPUParticleSystem
  52214. * @returns the list of ramp gradients
  52215. */
  52216. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52217. /**
  52218. * Not supported by GPUParticleSystem
  52219. * Gets or sets a boolean indicating that ramp gradients must be used
  52220. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52221. */
  52222. useRampGradients: boolean;
  52223. /**
  52224. * Not supported by GPUParticleSystem
  52225. * @param gradient defines the gradient to use (between 0 and 1)
  52226. * @param factor defines the life time factor to affect to the specified gradient
  52227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52228. * @returns the current particle system
  52229. */
  52230. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52231. /**
  52232. * Not supported by GPUParticleSystem
  52233. * @param gradient defines the gradient to remove
  52234. * @returns the current particle system
  52235. */
  52236. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52237. /**
  52238. * Instantiates a GPU particle system.
  52239. * 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.
  52240. * @param name The name of the particle system
  52241. * @param options The options used to create the system
  52242. * @param scene The scene the particle system belongs to
  52243. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52244. */
  52245. constructor(name: string, options: Partial<{
  52246. capacity: number;
  52247. randomTextureSize: number;
  52248. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52249. protected _reset(): void;
  52250. private _createUpdateVAO;
  52251. private _createRenderVAO;
  52252. private _initialize;
  52253. /** @hidden */
  52254. _recreateUpdateEffect(): void;
  52255. /** @hidden */
  52256. _recreateRenderEffect(): void;
  52257. /**
  52258. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52259. * @param preWarm defines if we are in the pre-warmimg phase
  52260. */
  52261. animate(preWarm?: boolean): void;
  52262. private _createFactorGradientTexture;
  52263. private _createSizeGradientTexture;
  52264. private _createAngularSpeedGradientTexture;
  52265. private _createVelocityGradientTexture;
  52266. private _createLimitVelocityGradientTexture;
  52267. private _createDragGradientTexture;
  52268. private _createColorGradientTexture;
  52269. /**
  52270. * Renders the particle system in its current state
  52271. * @param preWarm defines if the system should only update the particles but not render them
  52272. * @returns the current number of particles
  52273. */
  52274. render(preWarm?: boolean): number;
  52275. /**
  52276. * Rebuilds the particle system
  52277. */
  52278. rebuild(): void;
  52279. private _releaseBuffers;
  52280. private _releaseVAOs;
  52281. /**
  52282. * Disposes the particle system and free the associated resources
  52283. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52284. */
  52285. dispose(disposeTexture?: boolean): void;
  52286. /**
  52287. * Clones the particle system.
  52288. * @param name The name of the cloned object
  52289. * @param newEmitter The new emitter to use
  52290. * @returns the cloned particle system
  52291. */
  52292. clone(name: string, newEmitter: any): GPUParticleSystem;
  52293. /**
  52294. * Serializes the particle system to a JSON object.
  52295. * @returns the JSON object
  52296. */
  52297. serialize(): any;
  52298. /**
  52299. * Parses a JSON object to create a GPU particle system.
  52300. * @param parsedParticleSystem The JSON object to parse
  52301. * @param scene The scene to create the particle system in
  52302. * @param rootUrl The root url to use to load external dependencies like texture
  52303. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52304. * @returns the parsed GPU particle system
  52305. */
  52306. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52307. }
  52308. }
  52309. declare module "babylonjs/Particles/particleSystemSet" {
  52310. import { Nullable } from "babylonjs/types";
  52311. import { Color3 } from "babylonjs/Maths/math";
  52312. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52314. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52315. import { Scene, IDisposable } from "babylonjs/scene";
  52316. /**
  52317. * Represents a set of particle systems working together to create a specific effect
  52318. */
  52319. export class ParticleSystemSet implements IDisposable {
  52320. private _emitterCreationOptions;
  52321. private _emitterNode;
  52322. /**
  52323. * Gets the particle system list
  52324. */
  52325. systems: IParticleSystem[];
  52326. /**
  52327. * Gets the emitter node used with this set
  52328. */
  52329. readonly emitterNode: Nullable<TransformNode>;
  52330. /**
  52331. * Creates a new emitter mesh as a sphere
  52332. * @param options defines the options used to create the sphere
  52333. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52334. * @param scene defines the hosting scene
  52335. */
  52336. setEmitterAsSphere(options: {
  52337. diameter: number;
  52338. segments: number;
  52339. color: Color3;
  52340. }, renderingGroupId: number, scene: Scene): void;
  52341. /**
  52342. * Starts all particle systems of the set
  52343. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52344. */
  52345. start(emitter?: AbstractMesh): void;
  52346. /**
  52347. * Release all associated resources
  52348. */
  52349. dispose(): void;
  52350. /**
  52351. * Serialize the set into a JSON compatible object
  52352. * @returns a JSON compatible representation of the set
  52353. */
  52354. serialize(): any;
  52355. /**
  52356. * Parse a new ParticleSystemSet from a serialized source
  52357. * @param data defines a JSON compatible representation of the set
  52358. * @param scene defines the hosting scene
  52359. * @param gpu defines if we want GPU particles or CPU particles
  52360. * @returns a new ParticleSystemSet
  52361. */
  52362. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52363. }
  52364. }
  52365. declare module "babylonjs/Particles/particleHelper" {
  52366. import { Nullable } from "babylonjs/types";
  52367. import { Scene } from "babylonjs/scene";
  52368. import { Vector3 } from "babylonjs/Maths/math";
  52369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52370. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52371. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52372. /**
  52373. * This class is made for on one-liner static method to help creating particle system set.
  52374. */
  52375. export class ParticleHelper {
  52376. /**
  52377. * Gets or sets base Assets URL
  52378. */
  52379. static BaseAssetsUrl: string;
  52380. /**
  52381. * Create a default particle system that you can tweak
  52382. * @param emitter defines the emitter to use
  52383. * @param capacity defines the system capacity (default is 500 particles)
  52384. * @param scene defines the hosting scene
  52385. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52386. * @returns the new Particle system
  52387. */
  52388. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52389. /**
  52390. * This is the main static method (one-liner) of this helper to create different particle systems
  52391. * @param type This string represents the type to the particle system to create
  52392. * @param scene The scene where the particle system should live
  52393. * @param gpu If the system will use gpu
  52394. * @returns the ParticleSystemSet created
  52395. */
  52396. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52397. /**
  52398. * Static function used to export a particle system to a ParticleSystemSet variable.
  52399. * Please note that the emitter shape is not exported
  52400. * @param systems defines the particle systems to export
  52401. * @returns the created particle system set
  52402. */
  52403. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52404. }
  52405. }
  52406. declare module "babylonjs/Particles/particleSystemComponent" {
  52407. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52408. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52409. import "babylonjs/Shaders/particles.vertex";
  52410. module "babylonjs/Engines/engine" {
  52411. interface Engine {
  52412. /**
  52413. * Create an effect to use with particle systems.
  52414. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52415. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52416. * @param uniformsNames defines a list of attribute names
  52417. * @param samplers defines an array of string used to represent textures
  52418. * @param defines defines the string containing the defines to use to compile the shaders
  52419. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52420. * @param onCompiled defines a function to call when the effect creation is successful
  52421. * @param onError defines a function to call when the effect creation has failed
  52422. * @returns the new Effect
  52423. */
  52424. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52425. }
  52426. }
  52427. module "babylonjs/Meshes/mesh" {
  52428. interface Mesh {
  52429. /**
  52430. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52431. * @returns an array of IParticleSystem
  52432. */
  52433. getEmittedParticleSystems(): IParticleSystem[];
  52434. /**
  52435. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52436. * @returns an array of IParticleSystem
  52437. */
  52438. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52439. }
  52440. }
  52441. /**
  52442. * @hidden
  52443. */
  52444. export var _IDoNeedToBeInTheBuild: number;
  52445. }
  52446. declare module "babylonjs/Particles/index" {
  52447. export * from "babylonjs/Particles/baseParticleSystem";
  52448. export * from "babylonjs/Particles/EmitterTypes/index";
  52449. export * from "babylonjs/Particles/gpuParticleSystem";
  52450. export * from "babylonjs/Particles/IParticleSystem";
  52451. export * from "babylonjs/Particles/particle";
  52452. export * from "babylonjs/Particles/particleHelper";
  52453. export * from "babylonjs/Particles/particleSystem";
  52454. export * from "babylonjs/Particles/particleSystemComponent";
  52455. export * from "babylonjs/Particles/particleSystemSet";
  52456. export * from "babylonjs/Particles/solidParticle";
  52457. export * from "babylonjs/Particles/solidParticleSystem";
  52458. export * from "babylonjs/Particles/subEmitter";
  52459. }
  52460. declare module "babylonjs/Physics/physicsEngineComponent" {
  52461. import { Nullable } from "babylonjs/types";
  52462. import { Observable, Observer } from "babylonjs/Misc/observable";
  52463. import { Vector3 } from "babylonjs/Maths/math";
  52464. import { Mesh } from "babylonjs/Meshes/mesh";
  52465. import { ISceneComponent } from "babylonjs/sceneComponent";
  52466. import { Scene } from "babylonjs/scene";
  52467. import { Node } from "babylonjs/node";
  52468. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52469. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52470. module "babylonjs/scene" {
  52471. interface Scene {
  52472. /** @hidden (Backing field) */
  52473. _physicsEngine: Nullable<IPhysicsEngine>;
  52474. /**
  52475. * Gets the current physics engine
  52476. * @returns a IPhysicsEngine or null if none attached
  52477. */
  52478. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52479. /**
  52480. * Enables physics to the current scene
  52481. * @param gravity defines the scene's gravity for the physics engine
  52482. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52483. * @return a boolean indicating if the physics engine was initialized
  52484. */
  52485. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52486. /**
  52487. * Disables and disposes the physics engine associated with the scene
  52488. */
  52489. disablePhysicsEngine(): void;
  52490. /**
  52491. * Gets a boolean indicating if there is an active physics engine
  52492. * @returns a boolean indicating if there is an active physics engine
  52493. */
  52494. isPhysicsEnabled(): boolean;
  52495. /**
  52496. * Deletes a physics compound impostor
  52497. * @param compound defines the compound to delete
  52498. */
  52499. deleteCompoundImpostor(compound: any): void;
  52500. /**
  52501. * An event triggered when physic simulation is about to be run
  52502. */
  52503. onBeforePhysicsObservable: Observable<Scene>;
  52504. /**
  52505. * An event triggered when physic simulation has been done
  52506. */
  52507. onAfterPhysicsObservable: Observable<Scene>;
  52508. }
  52509. }
  52510. module "babylonjs/Meshes/abstractMesh" {
  52511. interface AbstractMesh {
  52512. /** @hidden */
  52513. _physicsImpostor: Nullable<PhysicsImpostor>;
  52514. /**
  52515. * Gets or sets impostor used for physic simulation
  52516. * @see http://doc.babylonjs.com/features/physics_engine
  52517. */
  52518. physicsImpostor: Nullable<PhysicsImpostor>;
  52519. /**
  52520. * Gets the current physics impostor
  52521. * @see http://doc.babylonjs.com/features/physics_engine
  52522. * @returns a physics impostor or null
  52523. */
  52524. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52525. /** Apply a physic impulse to the mesh
  52526. * @param force defines the force to apply
  52527. * @param contactPoint defines where to apply the force
  52528. * @returns the current mesh
  52529. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52530. */
  52531. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52532. /**
  52533. * Creates a physic joint between two meshes
  52534. * @param otherMesh defines the other mesh to use
  52535. * @param pivot1 defines the pivot to use on this mesh
  52536. * @param pivot2 defines the pivot to use on the other mesh
  52537. * @param options defines additional options (can be plugin dependent)
  52538. * @returns the current mesh
  52539. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52540. */
  52541. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52542. /** @hidden */
  52543. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52544. }
  52545. }
  52546. /**
  52547. * Defines the physics engine scene component responsible to manage a physics engine
  52548. */
  52549. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52550. /**
  52551. * The component name helpful to identify the component in the list of scene components.
  52552. */
  52553. readonly name: string;
  52554. /**
  52555. * The scene the component belongs to.
  52556. */
  52557. scene: Scene;
  52558. /**
  52559. * Creates a new instance of the component for the given scene
  52560. * @param scene Defines the scene to register the component in
  52561. */
  52562. constructor(scene: Scene);
  52563. /**
  52564. * Registers the component in a given scene
  52565. */
  52566. register(): void;
  52567. /**
  52568. * Rebuilds the elements related to this component in case of
  52569. * context lost for instance.
  52570. */
  52571. rebuild(): void;
  52572. /**
  52573. * Disposes the component and the associated ressources
  52574. */
  52575. dispose(): void;
  52576. }
  52577. }
  52578. declare module "babylonjs/Physics/physicsHelper" {
  52579. import { Nullable } from "babylonjs/types";
  52580. import { Vector3 } from "babylonjs/Maths/math";
  52581. import { Mesh } from "babylonjs/Meshes/mesh";
  52582. import { Scene } from "babylonjs/scene";
  52583. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52584. /**
  52585. * A helper for physics simulations
  52586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52587. */
  52588. export class PhysicsHelper {
  52589. private _scene;
  52590. private _physicsEngine;
  52591. /**
  52592. * Initializes the Physics helper
  52593. * @param scene Babylon.js scene
  52594. */
  52595. constructor(scene: Scene);
  52596. /**
  52597. * Applies a radial explosion impulse
  52598. * @param origin the origin of the explosion
  52599. * @param radiusOrEventOptions the radius or the options of radial explosion
  52600. * @param strength the explosion strength
  52601. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52602. * @returns A physics radial explosion event, or null
  52603. */
  52604. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52605. /**
  52606. * Applies a radial explosion force
  52607. * @param origin the origin of the explosion
  52608. * @param radiusOrEventOptions the radius or the options of radial explosion
  52609. * @param strength the explosion strength
  52610. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52611. * @returns A physics radial explosion event, or null
  52612. */
  52613. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52614. /**
  52615. * Creates a gravitational field
  52616. * @param origin the origin of the explosion
  52617. * @param radiusOrEventOptions the radius or the options of radial explosion
  52618. * @param strength the explosion strength
  52619. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52620. * @returns A physics gravitational field event, or null
  52621. */
  52622. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52623. /**
  52624. * Creates a physics updraft event
  52625. * @param origin the origin of the updraft
  52626. * @param radiusOrEventOptions the radius or the options of the updraft
  52627. * @param strength the strength of the updraft
  52628. * @param height the height of the updraft
  52629. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52630. * @returns A physics updraft event, or null
  52631. */
  52632. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52633. /**
  52634. * Creates a physics vortex event
  52635. * @param origin the of the vortex
  52636. * @param radiusOrEventOptions the radius or the options of the vortex
  52637. * @param strength the strength of the vortex
  52638. * @param height the height of the vortex
  52639. * @returns a Physics vortex event, or null
  52640. * A physics vortex event or null
  52641. */
  52642. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52643. }
  52644. /**
  52645. * Represents a physics radial explosion event
  52646. */
  52647. class PhysicsRadialExplosionEvent {
  52648. private _scene;
  52649. private _options;
  52650. private _sphere;
  52651. private _dataFetched;
  52652. /**
  52653. * Initializes a radial explosioin event
  52654. * @param _scene BabylonJS scene
  52655. * @param _options The options for the vortex event
  52656. */
  52657. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52658. /**
  52659. * Returns the data related to the radial explosion event (sphere).
  52660. * @returns The radial explosion event data
  52661. */
  52662. getData(): PhysicsRadialExplosionEventData;
  52663. /**
  52664. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52665. * @param impostor A physics imposter
  52666. * @param origin the origin of the explosion
  52667. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52668. */
  52669. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52670. /**
  52671. * Disposes the sphere.
  52672. * @param force Specifies if the sphere should be disposed by force
  52673. */
  52674. dispose(force?: boolean): void;
  52675. /*** Helpers ***/
  52676. private _prepareSphere;
  52677. private _intersectsWithSphere;
  52678. }
  52679. /**
  52680. * Represents a gravitational field event
  52681. */
  52682. class PhysicsGravitationalFieldEvent {
  52683. private _physicsHelper;
  52684. private _scene;
  52685. private _origin;
  52686. private _options;
  52687. private _tickCallback;
  52688. private _sphere;
  52689. private _dataFetched;
  52690. /**
  52691. * Initializes the physics gravitational field event
  52692. * @param _physicsHelper A physics helper
  52693. * @param _scene BabylonJS scene
  52694. * @param _origin The origin position of the gravitational field event
  52695. * @param _options The options for the vortex event
  52696. */
  52697. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52698. /**
  52699. * Returns the data related to the gravitational field event (sphere).
  52700. * @returns A gravitational field event
  52701. */
  52702. getData(): PhysicsGravitationalFieldEventData;
  52703. /**
  52704. * Enables the gravitational field.
  52705. */
  52706. enable(): void;
  52707. /**
  52708. * Disables the gravitational field.
  52709. */
  52710. disable(): void;
  52711. /**
  52712. * Disposes the sphere.
  52713. * @param force The force to dispose from the gravitational field event
  52714. */
  52715. dispose(force?: boolean): void;
  52716. private _tick;
  52717. }
  52718. /**
  52719. * Represents a physics updraft event
  52720. */
  52721. class PhysicsUpdraftEvent {
  52722. private _scene;
  52723. private _origin;
  52724. private _options;
  52725. private _physicsEngine;
  52726. private _originTop;
  52727. private _originDirection;
  52728. private _tickCallback;
  52729. private _cylinder;
  52730. private _cylinderPosition;
  52731. private _dataFetched;
  52732. /**
  52733. * Initializes the physics updraft event
  52734. * @param _scene BabylonJS scene
  52735. * @param _origin The origin position of the updraft
  52736. * @param _options The options for the updraft event
  52737. */
  52738. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52739. /**
  52740. * Returns the data related to the updraft event (cylinder).
  52741. * @returns A physics updraft event
  52742. */
  52743. getData(): PhysicsUpdraftEventData;
  52744. /**
  52745. * Enables the updraft.
  52746. */
  52747. enable(): void;
  52748. /**
  52749. * Disables the updraft.
  52750. */
  52751. disable(): void;
  52752. /**
  52753. * Disposes the cylinder.
  52754. * @param force Specifies if the updraft should be disposed by force
  52755. */
  52756. dispose(force?: boolean): void;
  52757. private getImpostorForceAndContactPoint;
  52758. private _tick;
  52759. /*** Helpers ***/
  52760. private _prepareCylinder;
  52761. private _intersectsWithCylinder;
  52762. }
  52763. /**
  52764. * Represents a physics vortex event
  52765. */
  52766. class PhysicsVortexEvent {
  52767. private _scene;
  52768. private _origin;
  52769. private _options;
  52770. private _physicsEngine;
  52771. private _originTop;
  52772. private _tickCallback;
  52773. private _cylinder;
  52774. private _cylinderPosition;
  52775. private _dataFetched;
  52776. /**
  52777. * Initializes the physics vortex event
  52778. * @param _scene The BabylonJS scene
  52779. * @param _origin The origin position of the vortex
  52780. * @param _options The options for the vortex event
  52781. */
  52782. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52783. /**
  52784. * Returns the data related to the vortex event (cylinder).
  52785. * @returns The physics vortex event data
  52786. */
  52787. getData(): PhysicsVortexEventData;
  52788. /**
  52789. * Enables the vortex.
  52790. */
  52791. enable(): void;
  52792. /**
  52793. * Disables the cortex.
  52794. */
  52795. disable(): void;
  52796. /**
  52797. * Disposes the sphere.
  52798. * @param force
  52799. */
  52800. dispose(force?: boolean): void;
  52801. private getImpostorForceAndContactPoint;
  52802. private _tick;
  52803. /*** Helpers ***/
  52804. private _prepareCylinder;
  52805. private _intersectsWithCylinder;
  52806. }
  52807. /**
  52808. * Options fot the radial explosion event
  52809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52810. */
  52811. export class PhysicsRadialExplosionEventOptions {
  52812. /**
  52813. * The radius of the sphere for the radial explosion.
  52814. */
  52815. radius: number;
  52816. /**
  52817. * The strenth of the explosion.
  52818. */
  52819. strength: number;
  52820. /**
  52821. * The strenght of the force in correspondence to the distance of the affected object
  52822. */
  52823. falloff: PhysicsRadialImpulseFalloff;
  52824. /**
  52825. * Sphere options for the radial explosion.
  52826. */
  52827. sphere: {
  52828. segments: number;
  52829. diameter: number;
  52830. };
  52831. }
  52832. /**
  52833. * Options fot the updraft event
  52834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52835. */
  52836. export class PhysicsUpdraftEventOptions {
  52837. /**
  52838. * The radius of the cylinder for the vortex
  52839. */
  52840. radius: number;
  52841. /**
  52842. * The strenth of the updraft.
  52843. */
  52844. strength: number;
  52845. /**
  52846. * The height of the cylinder for the updraft.
  52847. */
  52848. height: number;
  52849. /**
  52850. * The mode for the the updraft.
  52851. */
  52852. updraftMode: PhysicsUpdraftMode;
  52853. }
  52854. /**
  52855. * Options fot the vortex event
  52856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52857. */
  52858. export class PhysicsVortexEventOptions {
  52859. /**
  52860. * The radius of the cylinder for the vortex
  52861. */
  52862. radius: number;
  52863. /**
  52864. * The strenth of the vortex.
  52865. */
  52866. strength: number;
  52867. /**
  52868. * The height of the cylinder for the vortex.
  52869. */
  52870. height: number;
  52871. /**
  52872. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52873. */
  52874. centripetalForceThreshold: number;
  52875. /**
  52876. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52877. */
  52878. centripetalForceMultiplier: number;
  52879. /**
  52880. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52881. */
  52882. centrifugalForceMultiplier: number;
  52883. /**
  52884. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52885. */
  52886. updraftForceMultiplier: number;
  52887. }
  52888. /**
  52889. * The strenght of the force in correspondence to the distance of the affected object
  52890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52891. */
  52892. export enum PhysicsRadialImpulseFalloff {
  52893. /** Defines that impulse is constant in strength across it's whole radius */
  52894. Constant = 0,
  52895. /** Defines that impulse gets weaker if it's further from the origin */
  52896. Linear = 1
  52897. }
  52898. /**
  52899. * The strength of the force in correspondence to the distance of the affected object
  52900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52901. */
  52902. export enum PhysicsUpdraftMode {
  52903. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52904. Center = 0,
  52905. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52906. Perpendicular = 1
  52907. }
  52908. /**
  52909. * Interface for a physics force and contact point
  52910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52911. */
  52912. export interface PhysicsForceAndContactPoint {
  52913. /**
  52914. * The force applied at the contact point
  52915. */
  52916. force: Vector3;
  52917. /**
  52918. * The contact point
  52919. */
  52920. contactPoint: Vector3;
  52921. }
  52922. /**
  52923. * Interface for radial explosion event data
  52924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52925. */
  52926. export interface PhysicsRadialExplosionEventData {
  52927. /**
  52928. * A sphere used for the radial explosion event
  52929. */
  52930. sphere: Mesh;
  52931. }
  52932. /**
  52933. * Interface for gravitational field event data
  52934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52935. */
  52936. export interface PhysicsGravitationalFieldEventData {
  52937. /**
  52938. * A sphere mesh used for the gravitational field event
  52939. */
  52940. sphere: Mesh;
  52941. }
  52942. /**
  52943. * Interface for updraft event data
  52944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52945. */
  52946. export interface PhysicsUpdraftEventData {
  52947. /**
  52948. * A cylinder used for the updraft event
  52949. */
  52950. cylinder: Mesh;
  52951. }
  52952. /**
  52953. * Interface for vortex event data
  52954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52955. */
  52956. export interface PhysicsVortexEventData {
  52957. /**
  52958. * A cylinder used for the vortex event
  52959. */
  52960. cylinder: Mesh;
  52961. }
  52962. }
  52963. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52964. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52965. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52966. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52967. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52968. import { Nullable } from "babylonjs/types";
  52969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52970. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52971. /**
  52972. * AmmoJS Physics plugin
  52973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52974. * @see https://github.com/kripken/ammo.js/
  52975. */
  52976. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52977. private _useDeltaForWorldStep;
  52978. /**
  52979. * Reference to the Ammo library
  52980. */
  52981. bjsAMMO: any;
  52982. /**
  52983. * Created ammoJS world which physics bodies are added to
  52984. */
  52985. world: any;
  52986. /**
  52987. * Name of the plugin
  52988. */
  52989. name: string;
  52990. private _timeStep;
  52991. private _fixedTimeStep;
  52992. private _maxSteps;
  52993. private _tmpQuaternion;
  52994. private _tmpAmmoTransform;
  52995. private _tmpAmmoQuaternion;
  52996. private _tmpAmmoConcreteContactResultCallback;
  52997. private _collisionConfiguration;
  52998. private _dispatcher;
  52999. private _overlappingPairCache;
  53000. private _solver;
  53001. private _softBodySolver;
  53002. private _tmpAmmoVectorA;
  53003. private _tmpAmmoVectorB;
  53004. private _tmpAmmoVectorC;
  53005. private _tmpAmmoVectorD;
  53006. private _tmpContactCallbackResult;
  53007. private _tmpAmmoVectorRCA;
  53008. private _tmpAmmoVectorRCB;
  53009. private _raycastResult;
  53010. private static readonly DISABLE_COLLISION_FLAG;
  53011. private static readonly KINEMATIC_FLAG;
  53012. private static readonly DISABLE_DEACTIVATION_FLAG;
  53013. /**
  53014. * Initializes the ammoJS plugin
  53015. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53016. * @param ammoInjection can be used to inject your own ammo reference
  53017. */
  53018. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  53019. /**
  53020. * Sets the gravity of the physics world (m/(s^2))
  53021. * @param gravity Gravity to set
  53022. */
  53023. setGravity(gravity: Vector3): void;
  53024. /**
  53025. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53026. * @param timeStep timestep to use in seconds
  53027. */
  53028. setTimeStep(timeStep: number): void;
  53029. /**
  53030. * 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)
  53031. * @param fixedTimeStep fixedTimeStep to use in seconds
  53032. */
  53033. setFixedTimeStep(fixedTimeStep: number): void;
  53034. /**
  53035. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53036. * @param maxSteps the maximum number of steps by the physics engine per frame
  53037. */
  53038. setMaxSteps(maxSteps: number): void;
  53039. /**
  53040. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53041. * @returns the current timestep in seconds
  53042. */
  53043. getTimeStep(): number;
  53044. private _isImpostorInContact;
  53045. private _isImpostorPairInContact;
  53046. private _stepSimulation;
  53047. /**
  53048. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53049. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53050. * After the step the babylon meshes are set to the position of the physics imposters
  53051. * @param delta amount of time to step forward
  53052. * @param impostors array of imposters to update before/after the step
  53053. */
  53054. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53055. /**
  53056. * Update babylon mesh to match physics world object
  53057. * @param impostor imposter to match
  53058. */
  53059. private _afterSoftStep;
  53060. /**
  53061. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53062. * @param impostor imposter to match
  53063. */
  53064. private _ropeStep;
  53065. /**
  53066. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53067. * @param impostor imposter to match
  53068. */
  53069. private _softbodyOrClothStep;
  53070. private _tmpVector;
  53071. private _tmpMatrix;
  53072. /**
  53073. * Applies an impulse on the imposter
  53074. * @param impostor imposter to apply impulse to
  53075. * @param force amount of force to be applied to the imposter
  53076. * @param contactPoint the location to apply the impulse on the imposter
  53077. */
  53078. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53079. /**
  53080. * Applies a force on the imposter
  53081. * @param impostor imposter to apply force
  53082. * @param force amount of force to be applied to the imposter
  53083. * @param contactPoint the location to apply the force on the imposter
  53084. */
  53085. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53086. /**
  53087. * Creates a physics body using the plugin
  53088. * @param impostor the imposter to create the physics body on
  53089. */
  53090. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53091. /**
  53092. * Removes the physics body from the imposter and disposes of the body's memory
  53093. * @param impostor imposter to remove the physics body from
  53094. */
  53095. removePhysicsBody(impostor: PhysicsImpostor): void;
  53096. /**
  53097. * Generates a joint
  53098. * @param impostorJoint the imposter joint to create the joint with
  53099. */
  53100. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53101. /**
  53102. * Removes a joint
  53103. * @param impostorJoint the imposter joint to remove the joint from
  53104. */
  53105. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53106. private _addMeshVerts;
  53107. /**
  53108. * Initialise the soft body vertices to match its object's (mesh) vertices
  53109. * Softbody vertices (nodes) are in world space and to match this
  53110. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53111. * @param impostor to create the softbody for
  53112. */
  53113. private _softVertexData;
  53114. /**
  53115. * Create an impostor's soft body
  53116. * @param impostor to create the softbody for
  53117. */
  53118. private _createSoftbody;
  53119. /**
  53120. * Create cloth for an impostor
  53121. * @param impostor to create the softbody for
  53122. */
  53123. private _createCloth;
  53124. /**
  53125. * Create rope for an impostor
  53126. * @param impostor to create the softbody for
  53127. */
  53128. private _createRope;
  53129. private _addHullVerts;
  53130. private _createShape;
  53131. /**
  53132. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53133. * @param impostor imposter containing the physics body and babylon object
  53134. */
  53135. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53136. /**
  53137. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53138. * @param impostor imposter containing the physics body and babylon object
  53139. * @param newPosition new position
  53140. * @param newRotation new rotation
  53141. */
  53142. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53143. /**
  53144. * If this plugin is supported
  53145. * @returns true if its supported
  53146. */
  53147. isSupported(): boolean;
  53148. /**
  53149. * Sets the linear velocity of the physics body
  53150. * @param impostor imposter to set the velocity on
  53151. * @param velocity velocity to set
  53152. */
  53153. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53154. /**
  53155. * Sets the angular velocity of the physics body
  53156. * @param impostor imposter to set the velocity on
  53157. * @param velocity velocity to set
  53158. */
  53159. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53160. /**
  53161. * gets the linear velocity
  53162. * @param impostor imposter to get linear velocity from
  53163. * @returns linear velocity
  53164. */
  53165. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53166. /**
  53167. * gets the angular velocity
  53168. * @param impostor imposter to get angular velocity from
  53169. * @returns angular velocity
  53170. */
  53171. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53172. /**
  53173. * Sets the mass of physics body
  53174. * @param impostor imposter to set the mass on
  53175. * @param mass mass to set
  53176. */
  53177. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53178. /**
  53179. * Gets the mass of the physics body
  53180. * @param impostor imposter to get the mass from
  53181. * @returns mass
  53182. */
  53183. getBodyMass(impostor: PhysicsImpostor): number;
  53184. /**
  53185. * Gets friction of the impostor
  53186. * @param impostor impostor to get friction from
  53187. * @returns friction value
  53188. */
  53189. getBodyFriction(impostor: PhysicsImpostor): number;
  53190. /**
  53191. * Sets friction of the impostor
  53192. * @param impostor impostor to set friction on
  53193. * @param friction friction value
  53194. */
  53195. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53196. /**
  53197. * Gets restitution of the impostor
  53198. * @param impostor impostor to get restitution from
  53199. * @returns restitution value
  53200. */
  53201. getBodyRestitution(impostor: PhysicsImpostor): number;
  53202. /**
  53203. * Sets resitution of the impostor
  53204. * @param impostor impostor to set resitution on
  53205. * @param restitution resitution value
  53206. */
  53207. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53208. /**
  53209. * Gets pressure inside the impostor
  53210. * @param impostor impostor to get pressure from
  53211. * @returns pressure value
  53212. */
  53213. getBodyPressure(impostor: PhysicsImpostor): number;
  53214. /**
  53215. * Sets pressure inside a soft body impostor
  53216. * Cloth and rope must remain 0 pressure
  53217. * @param impostor impostor to set pressure on
  53218. * @param pressure pressure value
  53219. */
  53220. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53221. /**
  53222. * Gets stiffness of the impostor
  53223. * @param impostor impostor to get stiffness from
  53224. * @returns pressure value
  53225. */
  53226. getBodyStiffness(impostor: PhysicsImpostor): number;
  53227. /**
  53228. * Sets stiffness of the impostor
  53229. * @param impostor impostor to set stiffness on
  53230. * @param stiffness stiffness value from 0 to 1
  53231. */
  53232. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53233. /**
  53234. * Gets velocityIterations of the impostor
  53235. * @param impostor impostor to get velocity iterations from
  53236. * @returns velocityIterations value
  53237. */
  53238. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53239. /**
  53240. * Sets velocityIterations of the impostor
  53241. * @param impostor impostor to set velocity iterations on
  53242. * @param velocityIterations velocityIterations value
  53243. */
  53244. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53245. /**
  53246. * Gets positionIterations of the impostor
  53247. * @param impostor impostor to get position iterations from
  53248. * @returns positionIterations value
  53249. */
  53250. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53251. /**
  53252. * Sets positionIterations of the impostor
  53253. * @param impostor impostor to set position on
  53254. * @param positionIterations positionIterations value
  53255. */
  53256. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53257. /**
  53258. * Append an anchor to a cloth object
  53259. * @param impostor is the cloth impostor to add anchor to
  53260. * @param otherImpostor is the rigid impostor to anchor to
  53261. * @param width ratio across width from 0 to 1
  53262. * @param height ratio up height from 0 to 1
  53263. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53264. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53265. */
  53266. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53267. /**
  53268. * Append an hook to a rope object
  53269. * @param impostor is the rope impostor to add hook to
  53270. * @param otherImpostor is the rigid impostor to hook to
  53271. * @param length ratio along the rope from 0 to 1
  53272. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53273. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53274. */
  53275. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53276. /**
  53277. * Sleeps the physics body and stops it from being active
  53278. * @param impostor impostor to sleep
  53279. */
  53280. sleepBody(impostor: PhysicsImpostor): void;
  53281. /**
  53282. * Activates the physics body
  53283. * @param impostor impostor to activate
  53284. */
  53285. wakeUpBody(impostor: PhysicsImpostor): void;
  53286. /**
  53287. * Updates the distance parameters of the joint
  53288. * @param joint joint to update
  53289. * @param maxDistance maximum distance of the joint
  53290. * @param minDistance minimum distance of the joint
  53291. */
  53292. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53293. /**
  53294. * Sets a motor on the joint
  53295. * @param joint joint to set motor on
  53296. * @param speed speed of the motor
  53297. * @param maxForce maximum force of the motor
  53298. * @param motorIndex index of the motor
  53299. */
  53300. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53301. /**
  53302. * Sets the motors limit
  53303. * @param joint joint to set limit on
  53304. * @param upperLimit upper limit
  53305. * @param lowerLimit lower limit
  53306. */
  53307. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53308. /**
  53309. * Syncs the position and rotation of a mesh with the impostor
  53310. * @param mesh mesh to sync
  53311. * @param impostor impostor to update the mesh with
  53312. */
  53313. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53314. /**
  53315. * Gets the radius of the impostor
  53316. * @param impostor impostor to get radius from
  53317. * @returns the radius
  53318. */
  53319. getRadius(impostor: PhysicsImpostor): number;
  53320. /**
  53321. * Gets the box size of the impostor
  53322. * @param impostor impostor to get box size from
  53323. * @param result the resulting box size
  53324. */
  53325. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53326. /**
  53327. * Disposes of the impostor
  53328. */
  53329. dispose(): void;
  53330. /**
  53331. * Does a raycast in the physics world
  53332. * @param from when should the ray start?
  53333. * @param to when should the ray end?
  53334. * @returns PhysicsRaycastResult
  53335. */
  53336. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53337. }
  53338. }
  53339. declare module "babylonjs/Physics/Plugins/index" {
  53340. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53341. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53342. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53343. }
  53344. declare module "babylonjs/Physics/index" {
  53345. export * from "babylonjs/Physics/IPhysicsEngine";
  53346. export * from "babylonjs/Physics/physicsEngine";
  53347. export * from "babylonjs/Physics/physicsEngineComponent";
  53348. export * from "babylonjs/Physics/physicsHelper";
  53349. export * from "babylonjs/Physics/physicsImpostor";
  53350. export * from "babylonjs/Physics/physicsJoint";
  53351. export * from "babylonjs/Physics/Plugins/index";
  53352. }
  53353. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53354. /** @hidden */
  53355. export var blackAndWhitePixelShader: {
  53356. name: string;
  53357. shader: string;
  53358. };
  53359. }
  53360. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53361. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53362. import { Camera } from "babylonjs/Cameras/camera";
  53363. import { Engine } from "babylonjs/Engines/engine";
  53364. import "babylonjs/Shaders/blackAndWhite.fragment";
  53365. /**
  53366. * Post process used to render in black and white
  53367. */
  53368. export class BlackAndWhitePostProcess extends PostProcess {
  53369. /**
  53370. * Linear about to convert he result to black and white (default: 1)
  53371. */
  53372. degree: number;
  53373. /**
  53374. * Creates a black and white post process
  53375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53376. * @param name The name of the effect.
  53377. * @param options The required width/height ratio to downsize to before computing the render pass.
  53378. * @param camera The camera to apply the render pass to.
  53379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53380. * @param engine The engine which the post process will be applied. (default: current engine)
  53381. * @param reusable If the post process can be reused on the same frame. (default: false)
  53382. */
  53383. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53384. }
  53385. }
  53386. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53387. import { Nullable } from "babylonjs/types";
  53388. import { Camera } from "babylonjs/Cameras/camera";
  53389. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53390. import { Engine } from "babylonjs/Engines/engine";
  53391. /**
  53392. * This represents a set of one or more post processes in Babylon.
  53393. * A post process can be used to apply a shader to a texture after it is rendered.
  53394. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53395. */
  53396. export class PostProcessRenderEffect {
  53397. private _postProcesses;
  53398. private _getPostProcesses;
  53399. private _singleInstance;
  53400. private _cameras;
  53401. private _indicesForCamera;
  53402. /**
  53403. * Name of the effect
  53404. * @hidden
  53405. */
  53406. _name: string;
  53407. /**
  53408. * Instantiates a post process render effect.
  53409. * A post process can be used to apply a shader to a texture after it is rendered.
  53410. * @param engine The engine the effect is tied to
  53411. * @param name The name of the effect
  53412. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53413. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53414. */
  53415. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53416. /**
  53417. * Checks if all the post processes in the effect are supported.
  53418. */
  53419. readonly isSupported: boolean;
  53420. /**
  53421. * Updates the current state of the effect
  53422. * @hidden
  53423. */
  53424. _update(): void;
  53425. /**
  53426. * Attaches the effect on cameras
  53427. * @param cameras The camera to attach to.
  53428. * @hidden
  53429. */
  53430. _attachCameras(cameras: Camera): void;
  53431. /**
  53432. * Attaches the effect on cameras
  53433. * @param cameras The camera to attach to.
  53434. * @hidden
  53435. */
  53436. _attachCameras(cameras: Camera[]): void;
  53437. /**
  53438. * Detatches the effect on cameras
  53439. * @param cameras The camera to detatch from.
  53440. * @hidden
  53441. */
  53442. _detachCameras(cameras: Camera): void;
  53443. /**
  53444. * Detatches the effect on cameras
  53445. * @param cameras The camera to detatch from.
  53446. * @hidden
  53447. */
  53448. _detachCameras(cameras: Camera[]): void;
  53449. /**
  53450. * Enables the effect on given cameras
  53451. * @param cameras The camera to enable.
  53452. * @hidden
  53453. */
  53454. _enable(cameras: Camera): void;
  53455. /**
  53456. * Enables the effect on given cameras
  53457. * @param cameras The camera to enable.
  53458. * @hidden
  53459. */
  53460. _enable(cameras: Nullable<Camera[]>): void;
  53461. /**
  53462. * Disables the effect on the given cameras
  53463. * @param cameras The camera to disable.
  53464. * @hidden
  53465. */
  53466. _disable(cameras: Camera): void;
  53467. /**
  53468. * Disables the effect on the given cameras
  53469. * @param cameras The camera to disable.
  53470. * @hidden
  53471. */
  53472. _disable(cameras: Nullable<Camera[]>): void;
  53473. /**
  53474. * Gets a list of the post processes contained in the effect.
  53475. * @param camera The camera to get the post processes on.
  53476. * @returns The list of the post processes in the effect.
  53477. */
  53478. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53479. }
  53480. }
  53481. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53482. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53483. /** @hidden */
  53484. export var extractHighlightsPixelShader: {
  53485. name: string;
  53486. shader: string;
  53487. };
  53488. }
  53489. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53490. import { Nullable } from "babylonjs/types";
  53491. import { Camera } from "babylonjs/Cameras/camera";
  53492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53493. import { Engine } from "babylonjs/Engines/engine";
  53494. import "babylonjs/Shaders/extractHighlights.fragment";
  53495. /**
  53496. * 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.
  53497. */
  53498. export class ExtractHighlightsPostProcess extends PostProcess {
  53499. /**
  53500. * The luminance threshold, pixels below this value will be set to black.
  53501. */
  53502. threshold: number;
  53503. /** @hidden */
  53504. _exposure: number;
  53505. /**
  53506. * Post process which has the input texture to be used when performing highlight extraction
  53507. * @hidden
  53508. */
  53509. _inputPostProcess: Nullable<PostProcess>;
  53510. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53511. }
  53512. }
  53513. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53514. /** @hidden */
  53515. export var bloomMergePixelShader: {
  53516. name: string;
  53517. shader: string;
  53518. };
  53519. }
  53520. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53522. import { Nullable } from "babylonjs/types";
  53523. import { Engine } from "babylonjs/Engines/engine";
  53524. import { Camera } from "babylonjs/Cameras/camera";
  53525. import "babylonjs/Shaders/bloomMerge.fragment";
  53526. /**
  53527. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53528. */
  53529. export class BloomMergePostProcess extends PostProcess {
  53530. /** Weight of the bloom to be added to the original input. */
  53531. weight: number;
  53532. /**
  53533. * Creates a new instance of @see BloomMergePostProcess
  53534. * @param name The name of the effect.
  53535. * @param originalFromInput Post process which's input will be used for the merge.
  53536. * @param blurred Blurred highlights post process which's output will be used.
  53537. * @param weight Weight of the bloom to be added to the original input.
  53538. * @param options The required width/height ratio to downsize to before computing the render pass.
  53539. * @param camera The camera to apply the render pass to.
  53540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53541. * @param engine The engine which the post process will be applied. (default: current engine)
  53542. * @param reusable If the post process can be reused on the same frame. (default: false)
  53543. * @param textureType Type of textures used when performing the post process. (default: 0)
  53544. * @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)
  53545. */
  53546. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53547. /** Weight of the bloom to be added to the original input. */
  53548. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53549. }
  53550. }
  53551. declare module "babylonjs/PostProcesses/bloomEffect" {
  53552. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53553. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53554. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53555. import { Camera } from "babylonjs/Cameras/camera";
  53556. import { Scene } from "babylonjs/scene";
  53557. /**
  53558. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53559. */
  53560. export class BloomEffect extends PostProcessRenderEffect {
  53561. private bloomScale;
  53562. /**
  53563. * @hidden Internal
  53564. */
  53565. _effects: Array<PostProcess>;
  53566. /**
  53567. * @hidden Internal
  53568. */
  53569. _downscale: ExtractHighlightsPostProcess;
  53570. private _blurX;
  53571. private _blurY;
  53572. private _merge;
  53573. /**
  53574. * The luminance threshold to find bright areas of the image to bloom.
  53575. */
  53576. threshold: number;
  53577. /**
  53578. * The strength of the bloom.
  53579. */
  53580. weight: number;
  53581. /**
  53582. * Specifies the size of the bloom blur kernel, relative to the final output size
  53583. */
  53584. kernel: number;
  53585. /**
  53586. * Creates a new instance of @see BloomEffect
  53587. * @param scene The scene the effect belongs to.
  53588. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53589. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53590. * @param bloomWeight The the strength of bloom.
  53591. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53592. * @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)
  53593. */
  53594. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53595. /**
  53596. * Disposes each of the internal effects for a given camera.
  53597. * @param camera The camera to dispose the effect on.
  53598. */
  53599. disposeEffects(camera: Camera): void;
  53600. /**
  53601. * @hidden Internal
  53602. */
  53603. _updateEffects(): void;
  53604. /**
  53605. * Internal
  53606. * @returns if all the contained post processes are ready.
  53607. * @hidden
  53608. */
  53609. _isReady(): boolean;
  53610. }
  53611. }
  53612. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53613. /** @hidden */
  53614. export var chromaticAberrationPixelShader: {
  53615. name: string;
  53616. shader: string;
  53617. };
  53618. }
  53619. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53620. import { Vector2 } from "babylonjs/Maths/math";
  53621. import { Nullable } from "babylonjs/types";
  53622. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53623. import { Camera } from "babylonjs/Cameras/camera";
  53624. import { Engine } from "babylonjs/Engines/engine";
  53625. import "babylonjs/Shaders/chromaticAberration.fragment";
  53626. /**
  53627. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53628. */
  53629. export class ChromaticAberrationPostProcess extends PostProcess {
  53630. /**
  53631. * The amount of seperation of rgb channels (default: 30)
  53632. */
  53633. aberrationAmount: number;
  53634. /**
  53635. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53636. */
  53637. radialIntensity: number;
  53638. /**
  53639. * 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))
  53640. */
  53641. direction: Vector2;
  53642. /**
  53643. * 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))
  53644. */
  53645. centerPosition: Vector2;
  53646. /**
  53647. * Creates a new instance ChromaticAberrationPostProcess
  53648. * @param name The name of the effect.
  53649. * @param screenWidth The width of the screen to apply the effect on.
  53650. * @param screenHeight The height of the screen to apply the effect on.
  53651. * @param options The required width/height ratio to downsize to before computing the render pass.
  53652. * @param camera The camera to apply the render pass to.
  53653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53654. * @param engine The engine which the post process will be applied. (default: current engine)
  53655. * @param reusable If the post process can be reused on the same frame. (default: false)
  53656. * @param textureType Type of textures used when performing the post process. (default: 0)
  53657. * @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)
  53658. */
  53659. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53660. }
  53661. }
  53662. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53663. /** @hidden */
  53664. export var circleOfConfusionPixelShader: {
  53665. name: string;
  53666. shader: string;
  53667. };
  53668. }
  53669. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53670. import { Nullable } from "babylonjs/types";
  53671. import { Engine } from "babylonjs/Engines/engine";
  53672. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53673. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53674. import { Camera } from "babylonjs/Cameras/camera";
  53675. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53676. /**
  53677. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53678. */
  53679. export class CircleOfConfusionPostProcess extends PostProcess {
  53680. /**
  53681. * 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.
  53682. */
  53683. lensSize: number;
  53684. /**
  53685. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53686. */
  53687. fStop: number;
  53688. /**
  53689. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53690. */
  53691. focusDistance: number;
  53692. /**
  53693. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53694. */
  53695. focalLength: number;
  53696. private _depthTexture;
  53697. /**
  53698. * Creates a new instance CircleOfConfusionPostProcess
  53699. * @param name The name of the effect.
  53700. * @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.
  53701. * @param options The required width/height ratio to downsize to before computing the render pass.
  53702. * @param camera The camera to apply the render pass to.
  53703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53704. * @param engine The engine which the post process will be applied. (default: current engine)
  53705. * @param reusable If the post process can be reused on the same frame. (default: false)
  53706. * @param textureType Type of textures used when performing the post process. (default: 0)
  53707. * @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)
  53708. */
  53709. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53710. /**
  53711. * 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.
  53712. */
  53713. depthTexture: RenderTargetTexture;
  53714. }
  53715. }
  53716. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53717. /** @hidden */
  53718. export var colorCorrectionPixelShader: {
  53719. name: string;
  53720. shader: string;
  53721. };
  53722. }
  53723. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53725. import { Engine } from "babylonjs/Engines/engine";
  53726. import { Camera } from "babylonjs/Cameras/camera";
  53727. import "babylonjs/Shaders/colorCorrection.fragment";
  53728. /**
  53729. *
  53730. * This post-process allows the modification of rendered colors by using
  53731. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53732. *
  53733. * The object needs to be provided an url to a texture containing the color
  53734. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53735. * Use an image editing software to tweak the LUT to match your needs.
  53736. *
  53737. * For an example of a color LUT, see here:
  53738. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53739. * For explanations on color grading, see here:
  53740. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53741. *
  53742. */
  53743. export class ColorCorrectionPostProcess extends PostProcess {
  53744. private _colorTableTexture;
  53745. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53746. }
  53747. }
  53748. declare module "babylonjs/Shaders/convolution.fragment" {
  53749. /** @hidden */
  53750. export var convolutionPixelShader: {
  53751. name: string;
  53752. shader: string;
  53753. };
  53754. }
  53755. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53756. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53757. import { Nullable } from "babylonjs/types";
  53758. import { Camera } from "babylonjs/Cameras/camera";
  53759. import { Engine } from "babylonjs/Engines/engine";
  53760. import "babylonjs/Shaders/convolution.fragment";
  53761. /**
  53762. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53763. * input texture to perform effects such as edge detection or sharpening
  53764. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53765. */
  53766. export class ConvolutionPostProcess extends PostProcess {
  53767. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53768. kernel: number[];
  53769. /**
  53770. * Creates a new instance ConvolutionPostProcess
  53771. * @param name The name of the effect.
  53772. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53773. * @param options The required width/height ratio to downsize to before computing the render pass.
  53774. * @param camera The camera to apply the render pass to.
  53775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53776. * @param engine The engine which the post process will be applied. (default: current engine)
  53777. * @param reusable If the post process can be reused on the same frame. (default: false)
  53778. * @param textureType Type of textures used when performing the post process. (default: 0)
  53779. */
  53780. constructor(name: string,
  53781. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53782. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53783. /**
  53784. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53785. */
  53786. static EdgeDetect0Kernel: number[];
  53787. /**
  53788. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53789. */
  53790. static EdgeDetect1Kernel: number[];
  53791. /**
  53792. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53793. */
  53794. static EdgeDetect2Kernel: number[];
  53795. /**
  53796. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53797. */
  53798. static SharpenKernel: number[];
  53799. /**
  53800. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53801. */
  53802. static EmbossKernel: number[];
  53803. /**
  53804. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53805. */
  53806. static GaussianKernel: number[];
  53807. }
  53808. }
  53809. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53810. import { Nullable } from "babylonjs/types";
  53811. import { Vector2 } from "babylonjs/Maths/math";
  53812. import { Camera } from "babylonjs/Cameras/camera";
  53813. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53814. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53815. import { Engine } from "babylonjs/Engines/engine";
  53816. import { Scene } from "babylonjs/scene";
  53817. /**
  53818. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53819. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53820. * based on samples that have a large difference in distance than the center pixel.
  53821. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53822. */
  53823. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53824. direction: Vector2;
  53825. /**
  53826. * Creates a new instance CircleOfConfusionPostProcess
  53827. * @param name The name of the effect.
  53828. * @param scene The scene the effect belongs to.
  53829. * @param direction The direction the blur should be applied.
  53830. * @param kernel The size of the kernel used to blur.
  53831. * @param options The required width/height ratio to downsize to before computing the render pass.
  53832. * @param camera The camera to apply the render pass to.
  53833. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53834. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53836. * @param engine The engine which the post process will be applied. (default: current engine)
  53837. * @param reusable If the post process can be reused on the same frame. (default: false)
  53838. * @param textureType Type of textures used when performing the post process. (default: 0)
  53839. * @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)
  53840. */
  53841. 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);
  53842. }
  53843. }
  53844. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53845. /** @hidden */
  53846. export var depthOfFieldMergePixelShader: {
  53847. name: string;
  53848. shader: string;
  53849. };
  53850. }
  53851. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53852. import { Nullable } from "babylonjs/types";
  53853. import { Camera } from "babylonjs/Cameras/camera";
  53854. import { Effect } from "babylonjs/Materials/effect";
  53855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53856. import { Engine } from "babylonjs/Engines/engine";
  53857. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53858. /**
  53859. * Options to be set when merging outputs from the default pipeline.
  53860. */
  53861. export class DepthOfFieldMergePostProcessOptions {
  53862. /**
  53863. * The original image to merge on top of
  53864. */
  53865. originalFromInput: PostProcess;
  53866. /**
  53867. * Parameters to perform the merge of the depth of field effect
  53868. */
  53869. depthOfField?: {
  53870. circleOfConfusion: PostProcess;
  53871. blurSteps: Array<PostProcess>;
  53872. };
  53873. /**
  53874. * Parameters to perform the merge of bloom effect
  53875. */
  53876. bloom?: {
  53877. blurred: PostProcess;
  53878. weight: number;
  53879. };
  53880. }
  53881. /**
  53882. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53883. */
  53884. export class DepthOfFieldMergePostProcess extends PostProcess {
  53885. private blurSteps;
  53886. /**
  53887. * Creates a new instance of DepthOfFieldMergePostProcess
  53888. * @param name The name of the effect.
  53889. * @param originalFromInput Post process which's input will be used for the merge.
  53890. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53891. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53892. * @param options The required width/height ratio to downsize to before computing the render pass.
  53893. * @param camera The camera to apply the render pass to.
  53894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53895. * @param engine The engine which the post process will be applied. (default: current engine)
  53896. * @param reusable If the post process can be reused on the same frame. (default: false)
  53897. * @param textureType Type of textures used when performing the post process. (default: 0)
  53898. * @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)
  53899. */
  53900. 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);
  53901. /**
  53902. * Updates the effect with the current post process compile time values and recompiles the shader.
  53903. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53904. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53905. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53906. * @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
  53907. * @param onCompiled Called when the shader has been compiled.
  53908. * @param onError Called if there is an error when compiling a shader.
  53909. */
  53910. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53911. }
  53912. }
  53913. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53914. import { Nullable } from "babylonjs/types";
  53915. import { Camera } from "babylonjs/Cameras/camera";
  53916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53917. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53918. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53919. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53920. import { Scene } from "babylonjs/scene";
  53921. /**
  53922. * Specifies the level of max blur that should be applied when using the depth of field effect
  53923. */
  53924. export enum DepthOfFieldEffectBlurLevel {
  53925. /**
  53926. * Subtle blur
  53927. */
  53928. Low = 0,
  53929. /**
  53930. * Medium blur
  53931. */
  53932. Medium = 1,
  53933. /**
  53934. * Large blur
  53935. */
  53936. High = 2
  53937. }
  53938. /**
  53939. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53940. */
  53941. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53942. private _circleOfConfusion;
  53943. /**
  53944. * @hidden Internal, blurs from high to low
  53945. */
  53946. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53947. private _depthOfFieldBlurY;
  53948. private _dofMerge;
  53949. /**
  53950. * @hidden Internal post processes in depth of field effect
  53951. */
  53952. _effects: Array<PostProcess>;
  53953. /**
  53954. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53955. */
  53956. focalLength: number;
  53957. /**
  53958. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53959. */
  53960. fStop: number;
  53961. /**
  53962. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53963. */
  53964. focusDistance: number;
  53965. /**
  53966. * 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.
  53967. */
  53968. lensSize: number;
  53969. /**
  53970. * Creates a new instance DepthOfFieldEffect
  53971. * @param scene The scene the effect belongs to.
  53972. * @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.
  53973. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53974. * @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)
  53975. */
  53976. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53977. /**
  53978. * 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.
  53979. */
  53980. depthTexture: RenderTargetTexture;
  53981. /**
  53982. * Disposes each of the internal effects for a given camera.
  53983. * @param camera The camera to dispose the effect on.
  53984. */
  53985. disposeEffects(camera: Camera): void;
  53986. /**
  53987. * @hidden Internal
  53988. */
  53989. _updateEffects(): void;
  53990. /**
  53991. * Internal
  53992. * @returns if all the contained post processes are ready.
  53993. * @hidden
  53994. */
  53995. _isReady(): boolean;
  53996. }
  53997. }
  53998. declare module "babylonjs/Shaders/displayPass.fragment" {
  53999. /** @hidden */
  54000. export var displayPassPixelShader: {
  54001. name: string;
  54002. shader: string;
  54003. };
  54004. }
  54005. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54006. import { Nullable } from "babylonjs/types";
  54007. import { Camera } from "babylonjs/Cameras/camera";
  54008. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54009. import { Engine } from "babylonjs/Engines/engine";
  54010. import "babylonjs/Shaders/displayPass.fragment";
  54011. /**
  54012. * DisplayPassPostProcess which produces an output the same as it's input
  54013. */
  54014. export class DisplayPassPostProcess extends PostProcess {
  54015. /**
  54016. * Creates the DisplayPassPostProcess
  54017. * @param name The name of the effect.
  54018. * @param options The required width/height ratio to downsize to before computing the render pass.
  54019. * @param camera The camera to apply the render pass to.
  54020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54021. * @param engine The engine which the post process will be applied. (default: current engine)
  54022. * @param reusable If the post process can be reused on the same frame. (default: false)
  54023. */
  54024. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54025. }
  54026. }
  54027. declare module "babylonjs/Shaders/filter.fragment" {
  54028. /** @hidden */
  54029. export var filterPixelShader: {
  54030. name: string;
  54031. shader: string;
  54032. };
  54033. }
  54034. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54035. import { Nullable } from "babylonjs/types";
  54036. import { Matrix } from "babylonjs/Maths/math";
  54037. import { Camera } from "babylonjs/Cameras/camera";
  54038. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54039. import { Engine } from "babylonjs/Engines/engine";
  54040. import "babylonjs/Shaders/filter.fragment";
  54041. /**
  54042. * Applies a kernel filter to the image
  54043. */
  54044. export class FilterPostProcess extends PostProcess {
  54045. /** The matrix to be applied to the image */
  54046. kernelMatrix: Matrix;
  54047. /**
  54048. *
  54049. * @param name The name of the effect.
  54050. * @param kernelMatrix The matrix to be applied to the image
  54051. * @param options The required width/height ratio to downsize to before computing the render pass.
  54052. * @param camera The camera to apply the render pass to.
  54053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54054. * @param engine The engine which the post process will be applied. (default: current engine)
  54055. * @param reusable If the post process can be reused on the same frame. (default: false)
  54056. */
  54057. constructor(name: string,
  54058. /** The matrix to be applied to the image */
  54059. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54060. }
  54061. }
  54062. declare module "babylonjs/Shaders/fxaa.fragment" {
  54063. /** @hidden */
  54064. export var fxaaPixelShader: {
  54065. name: string;
  54066. shader: string;
  54067. };
  54068. }
  54069. declare module "babylonjs/Shaders/fxaa.vertex" {
  54070. /** @hidden */
  54071. export var fxaaVertexShader: {
  54072. name: string;
  54073. shader: string;
  54074. };
  54075. }
  54076. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54077. import { Nullable } from "babylonjs/types";
  54078. import { Camera } from "babylonjs/Cameras/camera";
  54079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54080. import { Engine } from "babylonjs/Engines/engine";
  54081. import "babylonjs/Shaders/fxaa.fragment";
  54082. import "babylonjs/Shaders/fxaa.vertex";
  54083. /**
  54084. * Fxaa post process
  54085. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54086. */
  54087. export class FxaaPostProcess extends PostProcess {
  54088. /** @hidden */
  54089. texelWidth: number;
  54090. /** @hidden */
  54091. texelHeight: number;
  54092. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54093. private _getDefines;
  54094. }
  54095. }
  54096. declare module "babylonjs/Shaders/grain.fragment" {
  54097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54098. /** @hidden */
  54099. export var grainPixelShader: {
  54100. name: string;
  54101. shader: string;
  54102. };
  54103. }
  54104. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54105. import { Nullable } from "babylonjs/types";
  54106. import { Camera } from "babylonjs/Cameras/camera";
  54107. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54108. import { Engine } from "babylonjs/Engines/engine";
  54109. import "babylonjs/Shaders/grain.fragment";
  54110. /**
  54111. * The GrainPostProcess adds noise to the image at mid luminance levels
  54112. */
  54113. export class GrainPostProcess extends PostProcess {
  54114. /**
  54115. * The intensity of the grain added (default: 30)
  54116. */
  54117. intensity: number;
  54118. /**
  54119. * If the grain should be randomized on every frame
  54120. */
  54121. animated: boolean;
  54122. /**
  54123. * Creates a new instance of @see GrainPostProcess
  54124. * @param name The name of the effect.
  54125. * @param options The required width/height ratio to downsize to before computing the render pass.
  54126. * @param camera The camera to apply the render pass to.
  54127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54128. * @param engine The engine which the post process will be applied. (default: current engine)
  54129. * @param reusable If the post process can be reused on the same frame. (default: false)
  54130. * @param textureType Type of textures used when performing the post process. (default: 0)
  54131. * @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)
  54132. */
  54133. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54134. }
  54135. }
  54136. declare module "babylonjs/Shaders/highlights.fragment" {
  54137. /** @hidden */
  54138. export var highlightsPixelShader: {
  54139. name: string;
  54140. shader: string;
  54141. };
  54142. }
  54143. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54144. import { Nullable } from "babylonjs/types";
  54145. import { Camera } from "babylonjs/Cameras/camera";
  54146. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54147. import { Engine } from "babylonjs/Engines/engine";
  54148. import "babylonjs/Shaders/highlights.fragment";
  54149. /**
  54150. * Extracts highlights from the image
  54151. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54152. */
  54153. export class HighlightsPostProcess extends PostProcess {
  54154. /**
  54155. * Extracts highlights from the image
  54156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54157. * @param name The name of the effect.
  54158. * @param options The required width/height ratio to downsize to before computing the render pass.
  54159. * @param camera The camera to apply the render pass to.
  54160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54161. * @param engine The engine which the post process will be applied. (default: current engine)
  54162. * @param reusable If the post process can be reused on the same frame. (default: false)
  54163. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54164. */
  54165. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54166. }
  54167. }
  54168. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54169. /** @hidden */
  54170. export var mrtFragmentDeclaration: {
  54171. name: string;
  54172. shader: string;
  54173. };
  54174. }
  54175. declare module "babylonjs/Shaders/geometry.fragment" {
  54176. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54177. /** @hidden */
  54178. export var geometryPixelShader: {
  54179. name: string;
  54180. shader: string;
  54181. };
  54182. }
  54183. declare module "babylonjs/Shaders/geometry.vertex" {
  54184. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54185. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54186. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54187. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54188. /** @hidden */
  54189. export var geometryVertexShader: {
  54190. name: string;
  54191. shader: string;
  54192. };
  54193. }
  54194. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54195. import { Matrix } from "babylonjs/Maths/math";
  54196. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54197. import { Mesh } from "babylonjs/Meshes/mesh";
  54198. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54199. import { Effect } from "babylonjs/Materials/effect";
  54200. import { Scene } from "babylonjs/scene";
  54201. import "babylonjs/Shaders/geometry.fragment";
  54202. import "babylonjs/Shaders/geometry.vertex";
  54203. /**
  54204. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54205. */
  54206. export class GeometryBufferRenderer {
  54207. /**
  54208. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54209. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54210. */
  54211. static readonly POSITION_TEXTURE_TYPE: number;
  54212. /**
  54213. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54214. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54215. */
  54216. static readonly VELOCITY_TEXTURE_TYPE: number;
  54217. /**
  54218. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54219. * in order to compute objects velocities when enableVelocity is set to "true"
  54220. * @hidden
  54221. */
  54222. _previousTransformationMatrices: {
  54223. [index: number]: Matrix;
  54224. };
  54225. private _scene;
  54226. private _multiRenderTarget;
  54227. private _ratio;
  54228. private _enablePosition;
  54229. private _enableVelocity;
  54230. private _positionIndex;
  54231. private _velocityIndex;
  54232. protected _effect: Effect;
  54233. protected _cachedDefines: string;
  54234. /**
  54235. * Set the render list (meshes to be rendered) used in the G buffer.
  54236. */
  54237. renderList: Mesh[];
  54238. /**
  54239. * Gets wether or not G buffer are supported by the running hardware.
  54240. * This requires draw buffer supports
  54241. */
  54242. readonly isSupported: boolean;
  54243. /**
  54244. * Returns the index of the given texture type in the G-Buffer textures array
  54245. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54246. * @returns the index of the given texture type in the G-Buffer textures array
  54247. */
  54248. getTextureIndex(textureType: number): number;
  54249. /**
  54250. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54251. */
  54252. /**
  54253. * Sets whether or not objects positions are enabled for the G buffer.
  54254. */
  54255. enablePosition: boolean;
  54256. /**
  54257. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54258. */
  54259. /**
  54260. * Sets wether or not objects velocities are enabled for the G buffer.
  54261. */
  54262. enableVelocity: boolean;
  54263. /**
  54264. * Gets the scene associated with the buffer.
  54265. */
  54266. readonly scene: Scene;
  54267. /**
  54268. * Gets the ratio used by the buffer during its creation.
  54269. * How big is the buffer related to the main canvas.
  54270. */
  54271. readonly ratio: number;
  54272. /** @hidden */
  54273. static _SceneComponentInitialization: (scene: Scene) => void;
  54274. /**
  54275. * Creates a new G Buffer for the scene
  54276. * @param scene The scene the buffer belongs to
  54277. * @param ratio How big is the buffer related to the main canvas.
  54278. */
  54279. constructor(scene: Scene, ratio?: number);
  54280. /**
  54281. * Checks wether everything is ready to render a submesh to the G buffer.
  54282. * @param subMesh the submesh to check readiness for
  54283. * @param useInstances is the mesh drawn using instance or not
  54284. * @returns true if ready otherwise false
  54285. */
  54286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54287. /**
  54288. * Gets the current underlying G Buffer.
  54289. * @returns the buffer
  54290. */
  54291. getGBuffer(): MultiRenderTarget;
  54292. /**
  54293. * Gets the number of samples used to render the buffer (anti aliasing).
  54294. */
  54295. /**
  54296. * Sets the number of samples used to render the buffer (anti aliasing).
  54297. */
  54298. samples: number;
  54299. /**
  54300. * Disposes the renderer and frees up associated resources.
  54301. */
  54302. dispose(): void;
  54303. protected _createRenderTargets(): void;
  54304. }
  54305. }
  54306. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54307. import { Nullable } from "babylonjs/types";
  54308. import { Scene } from "babylonjs/scene";
  54309. import { ISceneComponent } from "babylonjs/sceneComponent";
  54310. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54311. module "babylonjs/scene" {
  54312. interface Scene {
  54313. /** @hidden (Backing field) */
  54314. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54315. /**
  54316. * Gets or Sets the current geometry buffer associated to the scene.
  54317. */
  54318. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54319. /**
  54320. * Enables a GeometryBufferRender and associates it with the scene
  54321. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54322. * @returns the GeometryBufferRenderer
  54323. */
  54324. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54325. /**
  54326. * Disables the GeometryBufferRender associated with the scene
  54327. */
  54328. disableGeometryBufferRenderer(): void;
  54329. }
  54330. }
  54331. /**
  54332. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54333. * in several rendering techniques.
  54334. */
  54335. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54336. /**
  54337. * The component name helpful to identify the component in the list of scene components.
  54338. */
  54339. readonly name: string;
  54340. /**
  54341. * The scene the component belongs to.
  54342. */
  54343. scene: Scene;
  54344. /**
  54345. * Creates a new instance of the component for the given scene
  54346. * @param scene Defines the scene to register the component in
  54347. */
  54348. constructor(scene: Scene);
  54349. /**
  54350. * Registers the component in a given scene
  54351. */
  54352. register(): void;
  54353. /**
  54354. * Rebuilds the elements related to this component in case of
  54355. * context lost for instance.
  54356. */
  54357. rebuild(): void;
  54358. /**
  54359. * Disposes the component and the associated ressources
  54360. */
  54361. dispose(): void;
  54362. private _gatherRenderTargets;
  54363. }
  54364. }
  54365. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54366. /** @hidden */
  54367. export var motionBlurPixelShader: {
  54368. name: string;
  54369. shader: string;
  54370. };
  54371. }
  54372. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54373. import { Nullable } from "babylonjs/types";
  54374. import { Camera } from "babylonjs/Cameras/camera";
  54375. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54376. import { Scene } from "babylonjs/scene";
  54377. import "babylonjs/Animations/animatable";
  54378. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54379. import "babylonjs/Shaders/motionBlur.fragment";
  54380. import { Engine } from "babylonjs/Engines/engine";
  54381. /**
  54382. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54383. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54384. * As an example, all you have to do is to create the post-process:
  54385. * var mb = new BABYLON.MotionBlurPostProcess(
  54386. * 'mb', // The name of the effect.
  54387. * scene, // The scene containing the objects to blur according to their velocity.
  54388. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54389. * camera // The camera to apply the render pass to.
  54390. * );
  54391. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54392. */
  54393. export class MotionBlurPostProcess extends PostProcess {
  54394. /**
  54395. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54396. */
  54397. motionStrength: number;
  54398. /**
  54399. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54400. */
  54401. /**
  54402. * Sets the number of iterations to be used for motion blur quality
  54403. */
  54404. motionBlurSamples: number;
  54405. private _motionBlurSamples;
  54406. private _geometryBufferRenderer;
  54407. /**
  54408. * Creates a new instance MotionBlurPostProcess
  54409. * @param name The name of the effect.
  54410. * @param scene The scene containing the objects to blur according to their velocity.
  54411. * @param options The required width/height ratio to downsize to before computing the render pass.
  54412. * @param camera The camera to apply the render pass to.
  54413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54414. * @param engine The engine which the post process will be applied. (default: current engine)
  54415. * @param reusable If the post process can be reused on the same frame. (default: false)
  54416. * @param textureType Type of textures used when performing the post process. (default: 0)
  54417. * @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)
  54418. */
  54419. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54420. /**
  54421. * Disposes the post process.
  54422. * @param camera The camera to dispose the post process on.
  54423. */
  54424. dispose(camera?: Camera): void;
  54425. }
  54426. }
  54427. declare module "babylonjs/Shaders/refraction.fragment" {
  54428. /** @hidden */
  54429. export var refractionPixelShader: {
  54430. name: string;
  54431. shader: string;
  54432. };
  54433. }
  54434. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54435. import { Color3 } from "babylonjs/Maths/math";
  54436. import { Camera } from "babylonjs/Cameras/camera";
  54437. import { Texture } from "babylonjs/Materials/Textures/texture";
  54438. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54439. import { Engine } from "babylonjs/Engines/engine";
  54440. import "babylonjs/Shaders/refraction.fragment";
  54441. /**
  54442. * Post process which applies a refractin texture
  54443. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54444. */
  54445. export class RefractionPostProcess extends PostProcess {
  54446. /** the base color of the refraction (used to taint the rendering) */
  54447. color: Color3;
  54448. /** simulated refraction depth */
  54449. depth: number;
  54450. /** the coefficient of the base color (0 to remove base color tainting) */
  54451. colorLevel: number;
  54452. private _refTexture;
  54453. private _ownRefractionTexture;
  54454. /**
  54455. * Gets or sets the refraction texture
  54456. * Please note that you are responsible for disposing the texture if you set it manually
  54457. */
  54458. refractionTexture: Texture;
  54459. /**
  54460. * Initializes the RefractionPostProcess
  54461. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54462. * @param name The name of the effect.
  54463. * @param refractionTextureUrl Url of the refraction texture to use
  54464. * @param color the base color of the refraction (used to taint the rendering)
  54465. * @param depth simulated refraction depth
  54466. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54467. * @param camera The camera to apply the render pass to.
  54468. * @param options The required width/height ratio to downsize to before computing the render pass.
  54469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54470. * @param engine The engine which the post process will be applied. (default: current engine)
  54471. * @param reusable If the post process can be reused on the same frame. (default: false)
  54472. */
  54473. constructor(name: string, refractionTextureUrl: string,
  54474. /** the base color of the refraction (used to taint the rendering) */
  54475. color: Color3,
  54476. /** simulated refraction depth */
  54477. depth: number,
  54478. /** the coefficient of the base color (0 to remove base color tainting) */
  54479. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54480. /**
  54481. * Disposes of the post process
  54482. * @param camera Camera to dispose post process on
  54483. */
  54484. dispose(camera: Camera): void;
  54485. }
  54486. }
  54487. declare module "babylonjs/Shaders/sharpen.fragment" {
  54488. /** @hidden */
  54489. export var sharpenPixelShader: {
  54490. name: string;
  54491. shader: string;
  54492. };
  54493. }
  54494. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54495. import { Nullable } from "babylonjs/types";
  54496. import { Camera } from "babylonjs/Cameras/camera";
  54497. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54498. import "babylonjs/Shaders/sharpen.fragment";
  54499. import { Engine } from "babylonjs/Engines/engine";
  54500. /**
  54501. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54502. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54503. */
  54504. export class SharpenPostProcess extends PostProcess {
  54505. /**
  54506. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54507. */
  54508. colorAmount: number;
  54509. /**
  54510. * How much sharpness should be applied (default: 0.3)
  54511. */
  54512. edgeAmount: number;
  54513. /**
  54514. * Creates a new instance ConvolutionPostProcess
  54515. * @param name The name of the effect.
  54516. * @param options The required width/height ratio to downsize to before computing the render pass.
  54517. * @param camera The camera to apply the render pass to.
  54518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54519. * @param engine The engine which the post process will be applied. (default: current engine)
  54520. * @param reusable If the post process can be reused on the same frame. (default: false)
  54521. * @param textureType Type of textures used when performing the post process. (default: 0)
  54522. * @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)
  54523. */
  54524. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54525. }
  54526. }
  54527. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54528. import { Nullable } from "babylonjs/types";
  54529. import { Camera } from "babylonjs/Cameras/camera";
  54530. import { Engine } from "babylonjs/Engines/engine";
  54531. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54532. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54533. /**
  54534. * PostProcessRenderPipeline
  54535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54536. */
  54537. export class PostProcessRenderPipeline {
  54538. private engine;
  54539. private _renderEffects;
  54540. private _renderEffectsForIsolatedPass;
  54541. /**
  54542. * List of inspectable custom properties (used by the Inspector)
  54543. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54544. */
  54545. inspectableCustomProperties: IInspectable[];
  54546. /**
  54547. * @hidden
  54548. */
  54549. protected _cameras: Camera[];
  54550. /** @hidden */
  54551. _name: string;
  54552. /**
  54553. * Gets pipeline name
  54554. */
  54555. readonly name: string;
  54556. /**
  54557. * Initializes a PostProcessRenderPipeline
  54558. * @param engine engine to add the pipeline to
  54559. * @param name name of the pipeline
  54560. */
  54561. constructor(engine: Engine, name: string);
  54562. /**
  54563. * Gets the class name
  54564. * @returns "PostProcessRenderPipeline"
  54565. */
  54566. getClassName(): string;
  54567. /**
  54568. * If all the render effects in the pipeline are supported
  54569. */
  54570. readonly isSupported: boolean;
  54571. /**
  54572. * Adds an effect to the pipeline
  54573. * @param renderEffect the effect to add
  54574. */
  54575. addEffect(renderEffect: PostProcessRenderEffect): void;
  54576. /** @hidden */
  54577. _rebuild(): void;
  54578. /** @hidden */
  54579. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54580. /** @hidden */
  54581. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54582. /** @hidden */
  54583. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54584. /** @hidden */
  54585. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54586. /** @hidden */
  54587. _attachCameras(cameras: Camera, unique: boolean): void;
  54588. /** @hidden */
  54589. _attachCameras(cameras: Camera[], unique: boolean): void;
  54590. /** @hidden */
  54591. _detachCameras(cameras: Camera): void;
  54592. /** @hidden */
  54593. _detachCameras(cameras: Nullable<Camera[]>): void;
  54594. /** @hidden */
  54595. _update(): void;
  54596. /** @hidden */
  54597. _reset(): void;
  54598. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54599. /**
  54600. * Disposes of the pipeline
  54601. */
  54602. dispose(): void;
  54603. }
  54604. }
  54605. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54606. import { Camera } from "babylonjs/Cameras/camera";
  54607. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54608. /**
  54609. * PostProcessRenderPipelineManager class
  54610. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54611. */
  54612. export class PostProcessRenderPipelineManager {
  54613. private _renderPipelines;
  54614. /**
  54615. * Initializes a PostProcessRenderPipelineManager
  54616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54617. */
  54618. constructor();
  54619. /**
  54620. * Gets the list of supported render pipelines
  54621. */
  54622. readonly supportedPipelines: PostProcessRenderPipeline[];
  54623. /**
  54624. * Adds a pipeline to the manager
  54625. * @param renderPipeline The pipeline to add
  54626. */
  54627. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54628. /**
  54629. * Attaches a camera to the pipeline
  54630. * @param renderPipelineName The name of the pipeline to attach to
  54631. * @param cameras the camera to attach
  54632. * @param unique if the camera can be attached multiple times to the pipeline
  54633. */
  54634. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54635. /**
  54636. * Detaches a camera from the pipeline
  54637. * @param renderPipelineName The name of the pipeline to detach from
  54638. * @param cameras the camera to detach
  54639. */
  54640. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54641. /**
  54642. * Enables an effect by name on a pipeline
  54643. * @param renderPipelineName the name of the pipeline to enable the effect in
  54644. * @param renderEffectName the name of the effect to enable
  54645. * @param cameras the cameras that the effect should be enabled on
  54646. */
  54647. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54648. /**
  54649. * Disables an effect by name on a pipeline
  54650. * @param renderPipelineName the name of the pipeline to disable the effect in
  54651. * @param renderEffectName the name of the effect to disable
  54652. * @param cameras the cameras that the effect should be disabled on
  54653. */
  54654. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54655. /**
  54656. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54657. */
  54658. update(): void;
  54659. /** @hidden */
  54660. _rebuild(): void;
  54661. /**
  54662. * Disposes of the manager and pipelines
  54663. */
  54664. dispose(): void;
  54665. }
  54666. }
  54667. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54668. import { ISceneComponent } from "babylonjs/sceneComponent";
  54669. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54670. import { Scene } from "babylonjs/scene";
  54671. module "babylonjs/scene" {
  54672. interface Scene {
  54673. /** @hidden (Backing field) */
  54674. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54675. /**
  54676. * Gets the postprocess render pipeline manager
  54677. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54678. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54679. */
  54680. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54681. }
  54682. }
  54683. /**
  54684. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54685. */
  54686. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54687. /**
  54688. * The component name helpfull to identify the component in the list of scene components.
  54689. */
  54690. readonly name: string;
  54691. /**
  54692. * The scene the component belongs to.
  54693. */
  54694. scene: Scene;
  54695. /**
  54696. * Creates a new instance of the component for the given scene
  54697. * @param scene Defines the scene to register the component in
  54698. */
  54699. constructor(scene: Scene);
  54700. /**
  54701. * Registers the component in a given scene
  54702. */
  54703. register(): void;
  54704. /**
  54705. * Rebuilds the elements related to this component in case of
  54706. * context lost for instance.
  54707. */
  54708. rebuild(): void;
  54709. /**
  54710. * Disposes the component and the associated ressources
  54711. */
  54712. dispose(): void;
  54713. private _gatherRenderTargets;
  54714. }
  54715. }
  54716. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54717. import { IAnimatable } from "babylonjs/Misc/tools";
  54718. import { Camera } from "babylonjs/Cameras/camera";
  54719. import { IDisposable } from "babylonjs/scene";
  54720. import { Scene } from "babylonjs/scene";
  54721. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54722. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54723. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54724. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54725. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54726. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54727. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54728. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54729. import { Animation } from "babylonjs/Animations/animation";
  54730. /**
  54731. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54732. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54733. */
  54734. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54735. private _scene;
  54736. private _camerasToBeAttached;
  54737. /**
  54738. * ID of the sharpen post process,
  54739. */
  54740. private readonly SharpenPostProcessId;
  54741. /**
  54742. * @ignore
  54743. * ID of the image processing post process;
  54744. */
  54745. readonly ImageProcessingPostProcessId: string;
  54746. /**
  54747. * @ignore
  54748. * ID of the Fast Approximate Anti-Aliasing post process;
  54749. */
  54750. readonly FxaaPostProcessId: string;
  54751. /**
  54752. * ID of the chromatic aberration post process,
  54753. */
  54754. private readonly ChromaticAberrationPostProcessId;
  54755. /**
  54756. * ID of the grain post process
  54757. */
  54758. private readonly GrainPostProcessId;
  54759. /**
  54760. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54761. */
  54762. sharpen: SharpenPostProcess;
  54763. private _sharpenEffect;
  54764. private bloom;
  54765. /**
  54766. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54767. */
  54768. depthOfField: DepthOfFieldEffect;
  54769. /**
  54770. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54771. */
  54772. fxaa: FxaaPostProcess;
  54773. /**
  54774. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54775. */
  54776. imageProcessing: ImageProcessingPostProcess;
  54777. /**
  54778. * Chromatic aberration post process which will shift rgb colors in the image
  54779. */
  54780. chromaticAberration: ChromaticAberrationPostProcess;
  54781. private _chromaticAberrationEffect;
  54782. /**
  54783. * Grain post process which add noise to the image
  54784. */
  54785. grain: GrainPostProcess;
  54786. private _grainEffect;
  54787. /**
  54788. * Glow post process which adds a glow to emissive areas of the image
  54789. */
  54790. private _glowLayer;
  54791. /**
  54792. * Animations which can be used to tweak settings over a period of time
  54793. */
  54794. animations: Animation[];
  54795. private _imageProcessingConfigurationObserver;
  54796. private _sharpenEnabled;
  54797. private _bloomEnabled;
  54798. private _depthOfFieldEnabled;
  54799. private _depthOfFieldBlurLevel;
  54800. private _fxaaEnabled;
  54801. private _imageProcessingEnabled;
  54802. private _defaultPipelineTextureType;
  54803. private _bloomScale;
  54804. private _chromaticAberrationEnabled;
  54805. private _grainEnabled;
  54806. private _buildAllowed;
  54807. /**
  54808. * Gets active scene
  54809. */
  54810. readonly scene: Scene;
  54811. /**
  54812. * Enable or disable the sharpen process from the pipeline
  54813. */
  54814. sharpenEnabled: boolean;
  54815. private _resizeObserver;
  54816. private _hardwareScaleLevel;
  54817. private _bloomKernel;
  54818. /**
  54819. * Specifies the size of the bloom blur kernel, relative to the final output size
  54820. */
  54821. bloomKernel: number;
  54822. /**
  54823. * Specifies the weight of the bloom in the final rendering
  54824. */
  54825. private _bloomWeight;
  54826. /**
  54827. * Specifies the luma threshold for the area that will be blurred by the bloom
  54828. */
  54829. private _bloomThreshold;
  54830. private _hdr;
  54831. /**
  54832. * The strength of the bloom.
  54833. */
  54834. bloomWeight: number;
  54835. /**
  54836. * The strength of the bloom.
  54837. */
  54838. bloomThreshold: number;
  54839. /**
  54840. * The scale of the bloom, lower value will provide better performance.
  54841. */
  54842. bloomScale: number;
  54843. /**
  54844. * Enable or disable the bloom from the pipeline
  54845. */
  54846. bloomEnabled: boolean;
  54847. private _rebuildBloom;
  54848. /**
  54849. * If the depth of field is enabled.
  54850. */
  54851. depthOfFieldEnabled: boolean;
  54852. /**
  54853. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54854. */
  54855. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54856. /**
  54857. * If the anti aliasing is enabled.
  54858. */
  54859. fxaaEnabled: boolean;
  54860. private _samples;
  54861. /**
  54862. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54863. */
  54864. samples: number;
  54865. /**
  54866. * If image processing is enabled.
  54867. */
  54868. imageProcessingEnabled: boolean;
  54869. /**
  54870. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54871. */
  54872. glowLayerEnabled: boolean;
  54873. /**
  54874. * Enable or disable the chromaticAberration process from the pipeline
  54875. */
  54876. chromaticAberrationEnabled: boolean;
  54877. /**
  54878. * Enable or disable the grain process from the pipeline
  54879. */
  54880. grainEnabled: boolean;
  54881. /**
  54882. * @constructor
  54883. * @param name - The rendering pipeline name (default: "")
  54884. * @param hdr - If high dynamic range textures should be used (default: true)
  54885. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54886. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54887. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54888. */
  54889. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54890. /**
  54891. * Get the class name
  54892. * @returns "DefaultRenderingPipeline"
  54893. */
  54894. getClassName(): string;
  54895. /**
  54896. * Force the compilation of the entire pipeline.
  54897. */
  54898. prepare(): void;
  54899. private _hasCleared;
  54900. private _prevPostProcess;
  54901. private _prevPrevPostProcess;
  54902. private _setAutoClearAndTextureSharing;
  54903. private _depthOfFieldSceneObserver;
  54904. private _buildPipeline;
  54905. private _disposePostProcesses;
  54906. /**
  54907. * Adds a camera to the pipeline
  54908. * @param camera the camera to be added
  54909. */
  54910. addCamera(camera: Camera): void;
  54911. /**
  54912. * Removes a camera from the pipeline
  54913. * @param camera the camera to remove
  54914. */
  54915. removeCamera(camera: Camera): void;
  54916. /**
  54917. * Dispose of the pipeline and stop all post processes
  54918. */
  54919. dispose(): void;
  54920. /**
  54921. * Serialize the rendering pipeline (Used when exporting)
  54922. * @returns the serialized object
  54923. */
  54924. serialize(): any;
  54925. /**
  54926. * Parse the serialized pipeline
  54927. * @param source Source pipeline.
  54928. * @param scene The scene to load the pipeline to.
  54929. * @param rootUrl The URL of the serialized pipeline.
  54930. * @returns An instantiated pipeline from the serialized object.
  54931. */
  54932. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54933. }
  54934. }
  54935. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54936. /** @hidden */
  54937. export var lensHighlightsPixelShader: {
  54938. name: string;
  54939. shader: string;
  54940. };
  54941. }
  54942. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54943. /** @hidden */
  54944. export var depthOfFieldPixelShader: {
  54945. name: string;
  54946. shader: string;
  54947. };
  54948. }
  54949. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54950. import { Camera } from "babylonjs/Cameras/camera";
  54951. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54952. import { Scene } from "babylonjs/scene";
  54953. import "babylonjs/Shaders/chromaticAberration.fragment";
  54954. import "babylonjs/Shaders/lensHighlights.fragment";
  54955. import "babylonjs/Shaders/depthOfField.fragment";
  54956. /**
  54957. * BABYLON.JS Chromatic Aberration GLSL Shader
  54958. * Author: Olivier Guyot
  54959. * Separates very slightly R, G and B colors on the edges of the screen
  54960. * Inspired by Francois Tarlier & Martins Upitis
  54961. */
  54962. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54963. /**
  54964. * @ignore
  54965. * The chromatic aberration PostProcess id in the pipeline
  54966. */
  54967. LensChromaticAberrationEffect: string;
  54968. /**
  54969. * @ignore
  54970. * The highlights enhancing PostProcess id in the pipeline
  54971. */
  54972. HighlightsEnhancingEffect: string;
  54973. /**
  54974. * @ignore
  54975. * The depth-of-field PostProcess id in the pipeline
  54976. */
  54977. LensDepthOfFieldEffect: string;
  54978. private _scene;
  54979. private _depthTexture;
  54980. private _grainTexture;
  54981. private _chromaticAberrationPostProcess;
  54982. private _highlightsPostProcess;
  54983. private _depthOfFieldPostProcess;
  54984. private _edgeBlur;
  54985. private _grainAmount;
  54986. private _chromaticAberration;
  54987. private _distortion;
  54988. private _highlightsGain;
  54989. private _highlightsThreshold;
  54990. private _dofDistance;
  54991. private _dofAperture;
  54992. private _dofDarken;
  54993. private _dofPentagon;
  54994. private _blurNoise;
  54995. /**
  54996. * @constructor
  54997. *
  54998. * Effect parameters are as follow:
  54999. * {
  55000. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55001. * edge_blur: number; // from 0 to x (1 for realism)
  55002. * distortion: number; // from 0 to x (1 for realism)
  55003. * grain_amount: number; // from 0 to 1
  55004. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55005. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55006. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55007. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55008. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55009. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55010. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55011. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55012. * }
  55013. * Note: if an effect parameter is unset, effect is disabled
  55014. *
  55015. * @param name The rendering pipeline name
  55016. * @param parameters - An object containing all parameters (see above)
  55017. * @param scene The scene linked to this pipeline
  55018. * @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)
  55019. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55020. */
  55021. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55022. /**
  55023. * Get the class name
  55024. * @returns "LensRenderingPipeline"
  55025. */
  55026. getClassName(): string;
  55027. /**
  55028. * Gets associated scene
  55029. */
  55030. readonly scene: Scene;
  55031. /**
  55032. * Gets or sets the edge blur
  55033. */
  55034. edgeBlur: number;
  55035. /**
  55036. * Gets or sets the grain amount
  55037. */
  55038. grainAmount: number;
  55039. /**
  55040. * Gets or sets the chromatic aberration amount
  55041. */
  55042. chromaticAberration: number;
  55043. /**
  55044. * Gets or sets the depth of field aperture
  55045. */
  55046. dofAperture: number;
  55047. /**
  55048. * Gets or sets the edge distortion
  55049. */
  55050. edgeDistortion: number;
  55051. /**
  55052. * Gets or sets the depth of field distortion
  55053. */
  55054. dofDistortion: number;
  55055. /**
  55056. * Gets or sets the darken out of focus amount
  55057. */
  55058. darkenOutOfFocus: number;
  55059. /**
  55060. * Gets or sets a boolean indicating if blur noise is enabled
  55061. */
  55062. blurNoise: boolean;
  55063. /**
  55064. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55065. */
  55066. pentagonBokeh: boolean;
  55067. /**
  55068. * Gets or sets the highlight grain amount
  55069. */
  55070. highlightsGain: number;
  55071. /**
  55072. * Gets or sets the highlight threshold
  55073. */
  55074. highlightsThreshold: number;
  55075. /**
  55076. * Sets the amount of blur at the edges
  55077. * @param amount blur amount
  55078. */
  55079. setEdgeBlur(amount: number): void;
  55080. /**
  55081. * Sets edge blur to 0
  55082. */
  55083. disableEdgeBlur(): void;
  55084. /**
  55085. * Sets the amout of grain
  55086. * @param amount Amount of grain
  55087. */
  55088. setGrainAmount(amount: number): void;
  55089. /**
  55090. * Set grain amount to 0
  55091. */
  55092. disableGrain(): void;
  55093. /**
  55094. * Sets the chromatic aberration amount
  55095. * @param amount amount of chromatic aberration
  55096. */
  55097. setChromaticAberration(amount: number): void;
  55098. /**
  55099. * Sets chromatic aberration amount to 0
  55100. */
  55101. disableChromaticAberration(): void;
  55102. /**
  55103. * Sets the EdgeDistortion amount
  55104. * @param amount amount of EdgeDistortion
  55105. */
  55106. setEdgeDistortion(amount: number): void;
  55107. /**
  55108. * Sets edge distortion to 0
  55109. */
  55110. disableEdgeDistortion(): void;
  55111. /**
  55112. * Sets the FocusDistance amount
  55113. * @param amount amount of FocusDistance
  55114. */
  55115. setFocusDistance(amount: number): void;
  55116. /**
  55117. * Disables depth of field
  55118. */
  55119. disableDepthOfField(): void;
  55120. /**
  55121. * Sets the Aperture amount
  55122. * @param amount amount of Aperture
  55123. */
  55124. setAperture(amount: number): void;
  55125. /**
  55126. * Sets the DarkenOutOfFocus amount
  55127. * @param amount amount of DarkenOutOfFocus
  55128. */
  55129. setDarkenOutOfFocus(amount: number): void;
  55130. private _pentagonBokehIsEnabled;
  55131. /**
  55132. * Creates a pentagon bokeh effect
  55133. */
  55134. enablePentagonBokeh(): void;
  55135. /**
  55136. * Disables the pentagon bokeh effect
  55137. */
  55138. disablePentagonBokeh(): void;
  55139. /**
  55140. * Enables noise blur
  55141. */
  55142. enableNoiseBlur(): void;
  55143. /**
  55144. * Disables noise blur
  55145. */
  55146. disableNoiseBlur(): void;
  55147. /**
  55148. * Sets the HighlightsGain amount
  55149. * @param amount amount of HighlightsGain
  55150. */
  55151. setHighlightsGain(amount: number): void;
  55152. /**
  55153. * Sets the HighlightsThreshold amount
  55154. * @param amount amount of HighlightsThreshold
  55155. */
  55156. setHighlightsThreshold(amount: number): void;
  55157. /**
  55158. * Disables highlights
  55159. */
  55160. disableHighlights(): void;
  55161. /**
  55162. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55163. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55164. */
  55165. dispose(disableDepthRender?: boolean): void;
  55166. private _createChromaticAberrationPostProcess;
  55167. private _createHighlightsPostProcess;
  55168. private _createDepthOfFieldPostProcess;
  55169. private _createGrainTexture;
  55170. }
  55171. }
  55172. declare module "babylonjs/Shaders/ssao2.fragment" {
  55173. /** @hidden */
  55174. export var ssao2PixelShader: {
  55175. name: string;
  55176. shader: string;
  55177. };
  55178. }
  55179. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55180. /** @hidden */
  55181. export var ssaoCombinePixelShader: {
  55182. name: string;
  55183. shader: string;
  55184. };
  55185. }
  55186. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55187. import { Camera } from "babylonjs/Cameras/camera";
  55188. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55189. import { Scene } from "babylonjs/scene";
  55190. import "babylonjs/Shaders/ssao2.fragment";
  55191. import "babylonjs/Shaders/ssaoCombine.fragment";
  55192. /**
  55193. * Render pipeline to produce ssao effect
  55194. */
  55195. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55196. /**
  55197. * @ignore
  55198. * The PassPostProcess id in the pipeline that contains the original scene color
  55199. */
  55200. SSAOOriginalSceneColorEffect: string;
  55201. /**
  55202. * @ignore
  55203. * The SSAO PostProcess id in the pipeline
  55204. */
  55205. SSAORenderEffect: string;
  55206. /**
  55207. * @ignore
  55208. * The horizontal blur PostProcess id in the pipeline
  55209. */
  55210. SSAOBlurHRenderEffect: string;
  55211. /**
  55212. * @ignore
  55213. * The vertical blur PostProcess id in the pipeline
  55214. */
  55215. SSAOBlurVRenderEffect: string;
  55216. /**
  55217. * @ignore
  55218. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55219. */
  55220. SSAOCombineRenderEffect: string;
  55221. /**
  55222. * The output strength of the SSAO post-process. Default value is 1.0.
  55223. */
  55224. totalStrength: number;
  55225. /**
  55226. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55227. */
  55228. maxZ: number;
  55229. /**
  55230. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55231. */
  55232. minZAspect: number;
  55233. private _samples;
  55234. /**
  55235. * Number of samples used for the SSAO calculations. Default value is 8
  55236. */
  55237. samples: number;
  55238. private _textureSamples;
  55239. /**
  55240. * Number of samples to use for antialiasing
  55241. */
  55242. textureSamples: number;
  55243. /**
  55244. * Ratio object used for SSAO ratio and blur ratio
  55245. */
  55246. private _ratio;
  55247. /**
  55248. * Dynamically generated sphere sampler.
  55249. */
  55250. private _sampleSphere;
  55251. /**
  55252. * Blur filter offsets
  55253. */
  55254. private _samplerOffsets;
  55255. private _expensiveBlur;
  55256. /**
  55257. * If bilateral blur should be used
  55258. */
  55259. expensiveBlur: boolean;
  55260. /**
  55261. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55262. */
  55263. radius: number;
  55264. /**
  55265. * The base color of the SSAO post-process
  55266. * The final result is "base + ssao" between [0, 1]
  55267. */
  55268. base: number;
  55269. /**
  55270. * Support test.
  55271. */
  55272. static readonly IsSupported: boolean;
  55273. private _scene;
  55274. private _depthTexture;
  55275. private _normalTexture;
  55276. private _randomTexture;
  55277. private _originalColorPostProcess;
  55278. private _ssaoPostProcess;
  55279. private _blurHPostProcess;
  55280. private _blurVPostProcess;
  55281. private _ssaoCombinePostProcess;
  55282. private _firstUpdate;
  55283. /**
  55284. * Gets active scene
  55285. */
  55286. readonly scene: Scene;
  55287. /**
  55288. * @constructor
  55289. * @param name The rendering pipeline name
  55290. * @param scene The scene linked to this pipeline
  55291. * @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 }
  55292. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55293. */
  55294. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55295. /**
  55296. * Get the class name
  55297. * @returns "SSAO2RenderingPipeline"
  55298. */
  55299. getClassName(): string;
  55300. /**
  55301. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55302. */
  55303. dispose(disableGeometryBufferRenderer?: boolean): void;
  55304. private _createBlurPostProcess;
  55305. /** @hidden */
  55306. _rebuild(): void;
  55307. private _bits;
  55308. private _radicalInverse_VdC;
  55309. private _hammersley;
  55310. private _hemisphereSample_uniform;
  55311. private _generateHemisphere;
  55312. private _createSSAOPostProcess;
  55313. private _createSSAOCombinePostProcess;
  55314. private _createRandomTexture;
  55315. /**
  55316. * Serialize the rendering pipeline (Used when exporting)
  55317. * @returns the serialized object
  55318. */
  55319. serialize(): any;
  55320. /**
  55321. * Parse the serialized pipeline
  55322. * @param source Source pipeline.
  55323. * @param scene The scene to load the pipeline to.
  55324. * @param rootUrl The URL of the serialized pipeline.
  55325. * @returns An instantiated pipeline from the serialized object.
  55326. */
  55327. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55328. }
  55329. }
  55330. declare module "babylonjs/Shaders/ssao.fragment" {
  55331. /** @hidden */
  55332. export var ssaoPixelShader: {
  55333. name: string;
  55334. shader: string;
  55335. };
  55336. }
  55337. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55338. import { Camera } from "babylonjs/Cameras/camera";
  55339. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55340. import { Scene } from "babylonjs/scene";
  55341. import "babylonjs/Shaders/ssao.fragment";
  55342. import "babylonjs/Shaders/ssaoCombine.fragment";
  55343. /**
  55344. * Render pipeline to produce ssao effect
  55345. */
  55346. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55347. /**
  55348. * @ignore
  55349. * The PassPostProcess id in the pipeline that contains the original scene color
  55350. */
  55351. SSAOOriginalSceneColorEffect: string;
  55352. /**
  55353. * @ignore
  55354. * The SSAO PostProcess id in the pipeline
  55355. */
  55356. SSAORenderEffect: string;
  55357. /**
  55358. * @ignore
  55359. * The horizontal blur PostProcess id in the pipeline
  55360. */
  55361. SSAOBlurHRenderEffect: string;
  55362. /**
  55363. * @ignore
  55364. * The vertical blur PostProcess id in the pipeline
  55365. */
  55366. SSAOBlurVRenderEffect: string;
  55367. /**
  55368. * @ignore
  55369. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55370. */
  55371. SSAOCombineRenderEffect: string;
  55372. /**
  55373. * The output strength of the SSAO post-process. Default value is 1.0.
  55374. */
  55375. totalStrength: number;
  55376. /**
  55377. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55378. */
  55379. radius: number;
  55380. /**
  55381. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55382. * Must not be equal to fallOff and superior to fallOff.
  55383. * Default value is 0.0075
  55384. */
  55385. area: number;
  55386. /**
  55387. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55388. * Must not be equal to area and inferior to area.
  55389. * Default value is 0.000001
  55390. */
  55391. fallOff: number;
  55392. /**
  55393. * The base color of the SSAO post-process
  55394. * The final result is "base + ssao" between [0, 1]
  55395. */
  55396. base: number;
  55397. private _scene;
  55398. private _depthTexture;
  55399. private _randomTexture;
  55400. private _originalColorPostProcess;
  55401. private _ssaoPostProcess;
  55402. private _blurHPostProcess;
  55403. private _blurVPostProcess;
  55404. private _ssaoCombinePostProcess;
  55405. private _firstUpdate;
  55406. /**
  55407. * Gets active scene
  55408. */
  55409. readonly scene: Scene;
  55410. /**
  55411. * @constructor
  55412. * @param name - The rendering pipeline name
  55413. * @param scene - The scene linked to this pipeline
  55414. * @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 }
  55415. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55416. */
  55417. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55418. /**
  55419. * Get the class name
  55420. * @returns "SSAORenderingPipeline"
  55421. */
  55422. getClassName(): string;
  55423. /**
  55424. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55425. */
  55426. dispose(disableDepthRender?: boolean): void;
  55427. private _createBlurPostProcess;
  55428. /** @hidden */
  55429. _rebuild(): void;
  55430. private _createSSAOPostProcess;
  55431. private _createSSAOCombinePostProcess;
  55432. private _createRandomTexture;
  55433. }
  55434. }
  55435. declare module "babylonjs/Shaders/standard.fragment" {
  55436. /** @hidden */
  55437. export var standardPixelShader: {
  55438. name: string;
  55439. shader: string;
  55440. };
  55441. }
  55442. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55443. import { Nullable } from "babylonjs/types";
  55444. import { IAnimatable } from "babylonjs/Misc/tools";
  55445. import { Camera } from "babylonjs/Cameras/camera";
  55446. import { Texture } from "babylonjs/Materials/Textures/texture";
  55447. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55448. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55449. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55450. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55451. import { IDisposable } from "babylonjs/scene";
  55452. import { SpotLight } from "babylonjs/Lights/spotLight";
  55453. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55454. import { Scene } from "babylonjs/scene";
  55455. import { Animation } from "babylonjs/Animations/animation";
  55456. import "babylonjs/Shaders/standard.fragment";
  55457. /**
  55458. * Standard rendering pipeline
  55459. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55460. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55461. */
  55462. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55463. /**
  55464. * Public members
  55465. */
  55466. /**
  55467. * Post-process which contains the original scene color before the pipeline applies all the effects
  55468. */
  55469. originalPostProcess: Nullable<PostProcess>;
  55470. /**
  55471. * Post-process used to down scale an image x4
  55472. */
  55473. downSampleX4PostProcess: Nullable<PostProcess>;
  55474. /**
  55475. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55476. */
  55477. brightPassPostProcess: Nullable<PostProcess>;
  55478. /**
  55479. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55480. */
  55481. blurHPostProcesses: PostProcess[];
  55482. /**
  55483. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55484. */
  55485. blurVPostProcesses: PostProcess[];
  55486. /**
  55487. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55488. */
  55489. textureAdderPostProcess: Nullable<PostProcess>;
  55490. /**
  55491. * Post-process used to create volumetric lighting effect
  55492. */
  55493. volumetricLightPostProcess: Nullable<PostProcess>;
  55494. /**
  55495. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55496. */
  55497. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55498. /**
  55499. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55500. */
  55501. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55502. /**
  55503. * Post-process used to merge the volumetric light effect and the real scene color
  55504. */
  55505. volumetricLightMergePostProces: Nullable<PostProcess>;
  55506. /**
  55507. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55508. */
  55509. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55510. /**
  55511. * Base post-process used to calculate the average luminance of the final image for HDR
  55512. */
  55513. luminancePostProcess: Nullable<PostProcess>;
  55514. /**
  55515. * Post-processes used to create down sample post-processes in order to get
  55516. * the average luminance of the final image for HDR
  55517. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55518. */
  55519. luminanceDownSamplePostProcesses: PostProcess[];
  55520. /**
  55521. * Post-process used to create a HDR effect (light adaptation)
  55522. */
  55523. hdrPostProcess: Nullable<PostProcess>;
  55524. /**
  55525. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55526. */
  55527. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55528. /**
  55529. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55530. */
  55531. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55532. /**
  55533. * Post-process used to merge the final HDR post-process and the real scene color
  55534. */
  55535. hdrFinalPostProcess: Nullable<PostProcess>;
  55536. /**
  55537. * Post-process used to create a lens flare effect
  55538. */
  55539. lensFlarePostProcess: Nullable<PostProcess>;
  55540. /**
  55541. * Post-process that merges the result of the lens flare post-process and the real scene color
  55542. */
  55543. lensFlareComposePostProcess: Nullable<PostProcess>;
  55544. /**
  55545. * Post-process used to create a motion blur effect
  55546. */
  55547. motionBlurPostProcess: Nullable<PostProcess>;
  55548. /**
  55549. * Post-process used to create a depth of field effect
  55550. */
  55551. depthOfFieldPostProcess: Nullable<PostProcess>;
  55552. /**
  55553. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55554. */
  55555. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55556. /**
  55557. * Represents the brightness threshold in order to configure the illuminated surfaces
  55558. */
  55559. brightThreshold: number;
  55560. /**
  55561. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55562. */
  55563. blurWidth: number;
  55564. /**
  55565. * Sets if the blur for highlighted surfaces must be only horizontal
  55566. */
  55567. horizontalBlur: boolean;
  55568. /**
  55569. * Sets the overall exposure used by the pipeline
  55570. */
  55571. exposure: number;
  55572. /**
  55573. * Texture used typically to simulate "dirty" on camera lens
  55574. */
  55575. lensTexture: Nullable<Texture>;
  55576. /**
  55577. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55578. */
  55579. volumetricLightCoefficient: number;
  55580. /**
  55581. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55582. */
  55583. volumetricLightPower: number;
  55584. /**
  55585. * Used the set the blur intensity to smooth the volumetric lights
  55586. */
  55587. volumetricLightBlurScale: number;
  55588. /**
  55589. * Light (spot or directional) used to generate the volumetric lights rays
  55590. * The source light must have a shadow generate so the pipeline can get its
  55591. * depth map
  55592. */
  55593. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55594. /**
  55595. * For eye adaptation, represents the minimum luminance the eye can see
  55596. */
  55597. hdrMinimumLuminance: number;
  55598. /**
  55599. * For eye adaptation, represents the decrease luminance speed
  55600. */
  55601. hdrDecreaseRate: number;
  55602. /**
  55603. * For eye adaptation, represents the increase luminance speed
  55604. */
  55605. hdrIncreaseRate: number;
  55606. /**
  55607. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55608. */
  55609. lensColorTexture: Nullable<Texture>;
  55610. /**
  55611. * The overall strengh for the lens flare effect
  55612. */
  55613. lensFlareStrength: number;
  55614. /**
  55615. * Dispersion coefficient for lens flare ghosts
  55616. */
  55617. lensFlareGhostDispersal: number;
  55618. /**
  55619. * Main lens flare halo width
  55620. */
  55621. lensFlareHaloWidth: number;
  55622. /**
  55623. * Based on the lens distortion effect, defines how much the lens flare result
  55624. * is distorted
  55625. */
  55626. lensFlareDistortionStrength: number;
  55627. /**
  55628. * Lens star texture must be used to simulate rays on the flares and is available
  55629. * in the documentation
  55630. */
  55631. lensStarTexture: Nullable<Texture>;
  55632. /**
  55633. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55634. * flare effect by taking account of the dirt texture
  55635. */
  55636. lensFlareDirtTexture: Nullable<Texture>;
  55637. /**
  55638. * Represents the focal length for the depth of field effect
  55639. */
  55640. depthOfFieldDistance: number;
  55641. /**
  55642. * Represents the blur intensity for the blurred part of the depth of field effect
  55643. */
  55644. depthOfFieldBlurWidth: number;
  55645. /**
  55646. * For motion blur, defines how much the image is blurred by the movement
  55647. */
  55648. motionStrength: number;
  55649. /**
  55650. * List of animations for the pipeline (IAnimatable implementation)
  55651. */
  55652. animations: Animation[];
  55653. /**
  55654. * Private members
  55655. */
  55656. private _scene;
  55657. private _currentDepthOfFieldSource;
  55658. private _basePostProcess;
  55659. private _hdrCurrentLuminance;
  55660. private _floatTextureType;
  55661. private _ratio;
  55662. private _bloomEnabled;
  55663. private _depthOfFieldEnabled;
  55664. private _vlsEnabled;
  55665. private _lensFlareEnabled;
  55666. private _hdrEnabled;
  55667. private _motionBlurEnabled;
  55668. private _fxaaEnabled;
  55669. private _motionBlurSamples;
  55670. private _volumetricLightStepsCount;
  55671. private _samples;
  55672. /**
  55673. * @ignore
  55674. * Specifies if the bloom pipeline is enabled
  55675. */
  55676. BloomEnabled: boolean;
  55677. /**
  55678. * @ignore
  55679. * Specifies if the depth of field pipeline is enabed
  55680. */
  55681. DepthOfFieldEnabled: boolean;
  55682. /**
  55683. * @ignore
  55684. * Specifies if the lens flare pipeline is enabed
  55685. */
  55686. LensFlareEnabled: boolean;
  55687. /**
  55688. * @ignore
  55689. * Specifies if the HDR pipeline is enabled
  55690. */
  55691. HDREnabled: boolean;
  55692. /**
  55693. * @ignore
  55694. * Specifies if the volumetric lights scattering effect is enabled
  55695. */
  55696. VLSEnabled: boolean;
  55697. /**
  55698. * @ignore
  55699. * Specifies if the motion blur effect is enabled
  55700. */
  55701. MotionBlurEnabled: boolean;
  55702. /**
  55703. * Specifies if anti-aliasing is enabled
  55704. */
  55705. fxaaEnabled: boolean;
  55706. /**
  55707. * Specifies the number of steps used to calculate the volumetric lights
  55708. * Typically in interval [50, 200]
  55709. */
  55710. volumetricLightStepsCount: number;
  55711. /**
  55712. * Specifies the number of samples used for the motion blur effect
  55713. * Typically in interval [16, 64]
  55714. */
  55715. motionBlurSamples: number;
  55716. /**
  55717. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55718. */
  55719. samples: number;
  55720. /**
  55721. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55722. * @constructor
  55723. * @param name The rendering pipeline name
  55724. * @param scene The scene linked to this pipeline
  55725. * @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)
  55726. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55727. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55728. */
  55729. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55730. private _buildPipeline;
  55731. private _createDownSampleX4PostProcess;
  55732. private _createBrightPassPostProcess;
  55733. private _createBlurPostProcesses;
  55734. private _createTextureAdderPostProcess;
  55735. private _createVolumetricLightPostProcess;
  55736. private _createLuminancePostProcesses;
  55737. private _createHdrPostProcess;
  55738. private _createLensFlarePostProcess;
  55739. private _createDepthOfFieldPostProcess;
  55740. private _createMotionBlurPostProcess;
  55741. private _getDepthTexture;
  55742. private _disposePostProcesses;
  55743. /**
  55744. * Dispose of the pipeline and stop all post processes
  55745. */
  55746. dispose(): void;
  55747. /**
  55748. * Serialize the rendering pipeline (Used when exporting)
  55749. * @returns the serialized object
  55750. */
  55751. serialize(): any;
  55752. /**
  55753. * Parse the serialized pipeline
  55754. * @param source Source pipeline.
  55755. * @param scene The scene to load the pipeline to.
  55756. * @param rootUrl The URL of the serialized pipeline.
  55757. * @returns An instantiated pipeline from the serialized object.
  55758. */
  55759. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55760. /**
  55761. * Luminance steps
  55762. */
  55763. static LuminanceSteps: number;
  55764. }
  55765. }
  55766. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55767. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55768. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55769. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55770. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55771. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55772. }
  55773. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55774. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55775. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55776. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55777. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55778. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55779. }
  55780. declare module "babylonjs/Shaders/tonemap.fragment" {
  55781. /** @hidden */
  55782. export var tonemapPixelShader: {
  55783. name: string;
  55784. shader: string;
  55785. };
  55786. }
  55787. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55788. import { Camera } from "babylonjs/Cameras/camera";
  55789. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55790. import "babylonjs/Shaders/tonemap.fragment";
  55791. import { Engine } from "babylonjs/Engines/engine";
  55792. /** Defines operator used for tonemapping */
  55793. export enum TonemappingOperator {
  55794. /** Hable */
  55795. Hable = 0,
  55796. /** Reinhard */
  55797. Reinhard = 1,
  55798. /** HejiDawson */
  55799. HejiDawson = 2,
  55800. /** Photographic */
  55801. Photographic = 3
  55802. }
  55803. /**
  55804. * Defines a post process to apply tone mapping
  55805. */
  55806. export class TonemapPostProcess extends PostProcess {
  55807. private _operator;
  55808. /** Defines the required exposure adjustement */
  55809. exposureAdjustment: number;
  55810. /**
  55811. * Creates a new TonemapPostProcess
  55812. * @param name defines the name of the postprocess
  55813. * @param _operator defines the operator to use
  55814. * @param exposureAdjustment defines the required exposure adjustement
  55815. * @param camera defines the camera to use (can be null)
  55816. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55817. * @param engine defines the hosting engine (can be ignore if camera is set)
  55818. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55819. */
  55820. constructor(name: string, _operator: TonemappingOperator,
  55821. /** Defines the required exposure adjustement */
  55822. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55823. }
  55824. }
  55825. declare module "babylonjs/Shaders/depth.vertex" {
  55826. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55827. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55828. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55829. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55830. /** @hidden */
  55831. export var depthVertexShader: {
  55832. name: string;
  55833. shader: string;
  55834. };
  55835. }
  55836. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55837. /** @hidden */
  55838. export var volumetricLightScatteringPixelShader: {
  55839. name: string;
  55840. shader: string;
  55841. };
  55842. }
  55843. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55844. /** @hidden */
  55845. export var volumetricLightScatteringPassPixelShader: {
  55846. name: string;
  55847. shader: string;
  55848. };
  55849. }
  55850. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55851. import { Vector3 } from "babylonjs/Maths/math";
  55852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55853. import { Mesh } from "babylonjs/Meshes/mesh";
  55854. import { Camera } from "babylonjs/Cameras/camera";
  55855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55856. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55857. import { Scene } from "babylonjs/scene";
  55858. import "babylonjs/Meshes/Builders/planeBuilder";
  55859. import "babylonjs/Shaders/depth.vertex";
  55860. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55861. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55862. import { Engine } from "babylonjs/Engines/engine";
  55863. /**
  55864. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55865. */
  55866. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55867. private _volumetricLightScatteringPass;
  55868. private _volumetricLightScatteringRTT;
  55869. private _viewPort;
  55870. private _screenCoordinates;
  55871. private _cachedDefines;
  55872. /**
  55873. * If not undefined, the mesh position is computed from the attached node position
  55874. */
  55875. attachedNode: {
  55876. position: Vector3;
  55877. };
  55878. /**
  55879. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55880. */
  55881. customMeshPosition: Vector3;
  55882. /**
  55883. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55884. */
  55885. useCustomMeshPosition: boolean;
  55886. /**
  55887. * If the post-process should inverse the light scattering direction
  55888. */
  55889. invert: boolean;
  55890. /**
  55891. * The internal mesh used by the post-process
  55892. */
  55893. mesh: Mesh;
  55894. /**
  55895. * @hidden
  55896. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55897. */
  55898. useDiffuseColor: boolean;
  55899. /**
  55900. * Array containing the excluded meshes not rendered in the internal pass
  55901. */
  55902. excludedMeshes: AbstractMesh[];
  55903. /**
  55904. * Controls the overall intensity of the post-process
  55905. */
  55906. exposure: number;
  55907. /**
  55908. * Dissipates each sample's contribution in range [0, 1]
  55909. */
  55910. decay: number;
  55911. /**
  55912. * Controls the overall intensity of each sample
  55913. */
  55914. weight: number;
  55915. /**
  55916. * Controls the density of each sample
  55917. */
  55918. density: number;
  55919. /**
  55920. * @constructor
  55921. * @param name The post-process name
  55922. * @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)
  55923. * @param camera The camera that the post-process will be attached to
  55924. * @param mesh The mesh used to create the light scattering
  55925. * @param samples The post-process quality, default 100
  55926. * @param samplingModeThe post-process filtering mode
  55927. * @param engine The babylon engine
  55928. * @param reusable If the post-process is reusable
  55929. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55930. */
  55931. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55932. /**
  55933. * Returns the string "VolumetricLightScatteringPostProcess"
  55934. * @returns "VolumetricLightScatteringPostProcess"
  55935. */
  55936. getClassName(): string;
  55937. private _isReady;
  55938. /**
  55939. * Sets the new light position for light scattering effect
  55940. * @param position The new custom light position
  55941. */
  55942. setCustomMeshPosition(position: Vector3): void;
  55943. /**
  55944. * Returns the light position for light scattering effect
  55945. * @return Vector3 The custom light position
  55946. */
  55947. getCustomMeshPosition(): Vector3;
  55948. /**
  55949. * Disposes the internal assets and detaches the post-process from the camera
  55950. */
  55951. dispose(camera: Camera): void;
  55952. /**
  55953. * Returns the render target texture used by the post-process
  55954. * @return the render target texture used by the post-process
  55955. */
  55956. getPass(): RenderTargetTexture;
  55957. private _meshExcluded;
  55958. private _createPass;
  55959. private _updateMeshScreenCoordinates;
  55960. /**
  55961. * Creates a default mesh for the Volumeric Light Scattering post-process
  55962. * @param name The mesh name
  55963. * @param scene The scene where to create the mesh
  55964. * @return the default mesh
  55965. */
  55966. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55967. }
  55968. }
  55969. declare module "babylonjs/PostProcesses/index" {
  55970. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55971. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55972. export * from "babylonjs/PostProcesses/bloomEffect";
  55973. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55974. export * from "babylonjs/PostProcesses/blurPostProcess";
  55975. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55976. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55977. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55978. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55979. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55980. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55981. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55982. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55983. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55984. export * from "babylonjs/PostProcesses/filterPostProcess";
  55985. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55986. export * from "babylonjs/PostProcesses/grainPostProcess";
  55987. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55988. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55989. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55990. export * from "babylonjs/PostProcesses/passPostProcess";
  55991. export * from "babylonjs/PostProcesses/postProcess";
  55992. export * from "babylonjs/PostProcesses/postProcessManager";
  55993. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55994. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55995. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55996. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55997. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55998. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55999. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56000. }
  56001. declare module "babylonjs/Probes/index" {
  56002. export * from "babylonjs/Probes/reflectionProbe";
  56003. }
  56004. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56005. import { Scene } from "babylonjs/scene";
  56006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56007. import { Color3 } from "babylonjs/Maths/math";
  56008. import { SmartArray } from "babylonjs/Misc/smartArray";
  56009. import { ISceneComponent } from "babylonjs/sceneComponent";
  56010. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56011. import "babylonjs/Meshes/Builders/boxBuilder";
  56012. import "babylonjs/Shaders/color.fragment";
  56013. import "babylonjs/Shaders/color.vertex";
  56014. module "babylonjs/scene" {
  56015. interface Scene {
  56016. /** @hidden (Backing field) */
  56017. _boundingBoxRenderer: BoundingBoxRenderer;
  56018. /** @hidden (Backing field) */
  56019. _forceShowBoundingBoxes: boolean;
  56020. /**
  56021. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56022. */
  56023. forceShowBoundingBoxes: boolean;
  56024. /**
  56025. * Gets the bounding box renderer associated with the scene
  56026. * @returns a BoundingBoxRenderer
  56027. */
  56028. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56029. }
  56030. }
  56031. module "babylonjs/Meshes/abstractMesh" {
  56032. interface AbstractMesh {
  56033. /** @hidden (Backing field) */
  56034. _showBoundingBox: boolean;
  56035. /**
  56036. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56037. */
  56038. showBoundingBox: boolean;
  56039. }
  56040. }
  56041. /**
  56042. * Component responsible of rendering the bounding box of the meshes in a scene.
  56043. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56044. */
  56045. export class BoundingBoxRenderer implements ISceneComponent {
  56046. /**
  56047. * The component name helpfull to identify the component in the list of scene components.
  56048. */
  56049. readonly name: string;
  56050. /**
  56051. * The scene the component belongs to.
  56052. */
  56053. scene: Scene;
  56054. /**
  56055. * Color of the bounding box lines placed in front of an object
  56056. */
  56057. frontColor: Color3;
  56058. /**
  56059. * Color of the bounding box lines placed behind an object
  56060. */
  56061. backColor: Color3;
  56062. /**
  56063. * Defines if the renderer should show the back lines or not
  56064. */
  56065. showBackLines: boolean;
  56066. /**
  56067. * @hidden
  56068. */
  56069. renderList: SmartArray<BoundingBox>;
  56070. private _colorShader;
  56071. private _vertexBuffers;
  56072. private _indexBuffer;
  56073. /**
  56074. * Instantiates a new bounding box renderer in a scene.
  56075. * @param scene the scene the renderer renders in
  56076. */
  56077. constructor(scene: Scene);
  56078. /**
  56079. * Registers the component in a given scene
  56080. */
  56081. register(): void;
  56082. private _evaluateSubMesh;
  56083. private _activeMesh;
  56084. private _prepareRessources;
  56085. private _createIndexBuffer;
  56086. /**
  56087. * Rebuilds the elements related to this component in case of
  56088. * context lost for instance.
  56089. */
  56090. rebuild(): void;
  56091. /**
  56092. * @hidden
  56093. */
  56094. reset(): void;
  56095. /**
  56096. * Render the bounding boxes of a specific rendering group
  56097. * @param renderingGroupId defines the rendering group to render
  56098. */
  56099. render(renderingGroupId: number): void;
  56100. /**
  56101. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56102. * @param mesh Define the mesh to render the occlusion bounding box for
  56103. */
  56104. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56105. /**
  56106. * Dispose and release the resources attached to this renderer.
  56107. */
  56108. dispose(): void;
  56109. }
  56110. }
  56111. declare module "babylonjs/Shaders/depth.fragment" {
  56112. /** @hidden */
  56113. export var depthPixelShader: {
  56114. name: string;
  56115. shader: string;
  56116. };
  56117. }
  56118. declare module "babylonjs/Rendering/depthRenderer" {
  56119. import { Nullable } from "babylonjs/types";
  56120. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56121. import { Scene } from "babylonjs/scene";
  56122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56123. import { Camera } from "babylonjs/Cameras/camera";
  56124. import "babylonjs/Shaders/depth.fragment";
  56125. import "babylonjs/Shaders/depth.vertex";
  56126. /**
  56127. * This represents a depth renderer in Babylon.
  56128. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56129. */
  56130. export class DepthRenderer {
  56131. private _scene;
  56132. private _depthMap;
  56133. private _effect;
  56134. private _cachedDefines;
  56135. private _camera;
  56136. /**
  56137. * Specifiess that the depth renderer will only be used within
  56138. * the camera it is created for.
  56139. * This can help forcing its rendering during the camera processing.
  56140. */
  56141. useOnlyInActiveCamera: boolean;
  56142. /** @hidden */
  56143. static _SceneComponentInitialization: (scene: Scene) => void;
  56144. /**
  56145. * Instantiates a depth renderer
  56146. * @param scene The scene the renderer belongs to
  56147. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56148. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56149. */
  56150. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56151. /**
  56152. * Creates the depth rendering effect and checks if the effect is ready.
  56153. * @param subMesh The submesh to be used to render the depth map of
  56154. * @param useInstances If multiple world instances should be used
  56155. * @returns if the depth renderer is ready to render the depth map
  56156. */
  56157. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56158. /**
  56159. * Gets the texture which the depth map will be written to.
  56160. * @returns The depth map texture
  56161. */
  56162. getDepthMap(): RenderTargetTexture;
  56163. /**
  56164. * Disposes of the depth renderer.
  56165. */
  56166. dispose(): void;
  56167. }
  56168. }
  56169. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56170. import { Nullable } from "babylonjs/types";
  56171. import { Scene } from "babylonjs/scene";
  56172. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56173. import { Camera } from "babylonjs/Cameras/camera";
  56174. import { ISceneComponent } from "babylonjs/sceneComponent";
  56175. module "babylonjs/scene" {
  56176. interface Scene {
  56177. /** @hidden (Backing field) */
  56178. _depthRenderer: {
  56179. [id: string]: DepthRenderer;
  56180. };
  56181. /**
  56182. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56183. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56184. * @returns the created depth renderer
  56185. */
  56186. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56187. /**
  56188. * Disables a depth renderer for a given camera
  56189. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56190. */
  56191. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56192. }
  56193. }
  56194. /**
  56195. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56196. * in several rendering techniques.
  56197. */
  56198. export class DepthRendererSceneComponent implements ISceneComponent {
  56199. /**
  56200. * The component name helpfull to identify the component in the list of scene components.
  56201. */
  56202. readonly name: string;
  56203. /**
  56204. * The scene the component belongs to.
  56205. */
  56206. scene: Scene;
  56207. /**
  56208. * Creates a new instance of the component for the given scene
  56209. * @param scene Defines the scene to register the component in
  56210. */
  56211. constructor(scene: Scene);
  56212. /**
  56213. * Registers the component in a given scene
  56214. */
  56215. register(): void;
  56216. /**
  56217. * Rebuilds the elements related to this component in case of
  56218. * context lost for instance.
  56219. */
  56220. rebuild(): void;
  56221. /**
  56222. * Disposes the component and the associated ressources
  56223. */
  56224. dispose(): void;
  56225. private _gatherRenderTargets;
  56226. private _gatherActiveCameraRenderTargets;
  56227. }
  56228. }
  56229. declare module "babylonjs/Shaders/outline.fragment" {
  56230. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56231. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56232. /** @hidden */
  56233. export var outlinePixelShader: {
  56234. name: string;
  56235. shader: string;
  56236. };
  56237. }
  56238. declare module "babylonjs/Shaders/outline.vertex" {
  56239. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56240. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56241. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56242. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56243. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56244. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56245. /** @hidden */
  56246. export var outlineVertexShader: {
  56247. name: string;
  56248. shader: string;
  56249. };
  56250. }
  56251. declare module "babylonjs/Rendering/outlineRenderer" {
  56252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56253. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56254. import { Scene } from "babylonjs/scene";
  56255. import { ISceneComponent } from "babylonjs/sceneComponent";
  56256. import "babylonjs/Shaders/outline.fragment";
  56257. import "babylonjs/Shaders/outline.vertex";
  56258. module "babylonjs/scene" {
  56259. interface Scene {
  56260. /** @hidden */
  56261. _outlineRenderer: OutlineRenderer;
  56262. /**
  56263. * Gets the outline renderer associated with the scene
  56264. * @returns a OutlineRenderer
  56265. */
  56266. getOutlineRenderer(): OutlineRenderer;
  56267. }
  56268. }
  56269. module "babylonjs/Meshes/abstractMesh" {
  56270. interface AbstractMesh {
  56271. /** @hidden (Backing field) */
  56272. _renderOutline: boolean;
  56273. /**
  56274. * Gets or sets a boolean indicating if the outline must be rendered as well
  56275. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56276. */
  56277. renderOutline: boolean;
  56278. /** @hidden (Backing field) */
  56279. _renderOverlay: boolean;
  56280. /**
  56281. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56282. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56283. */
  56284. renderOverlay: boolean;
  56285. }
  56286. }
  56287. /**
  56288. * This class is responsible to draw bothe outline/overlay of meshes.
  56289. * It should not be used directly but through the available method on mesh.
  56290. */
  56291. export class OutlineRenderer implements ISceneComponent {
  56292. /**
  56293. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56294. */
  56295. private static _StencilReference;
  56296. /**
  56297. * The name of the component. Each component must have a unique name.
  56298. */
  56299. name: string;
  56300. /**
  56301. * The scene the component belongs to.
  56302. */
  56303. scene: Scene;
  56304. /**
  56305. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56306. */
  56307. zOffset: number;
  56308. private _engine;
  56309. private _effect;
  56310. private _cachedDefines;
  56311. private _savedDepthWrite;
  56312. /**
  56313. * Instantiates a new outline renderer. (There could be only one per scene).
  56314. * @param scene Defines the scene it belongs to
  56315. */
  56316. constructor(scene: Scene);
  56317. /**
  56318. * Register the component to one instance of a scene.
  56319. */
  56320. register(): void;
  56321. /**
  56322. * Rebuilds the elements related to this component in case of
  56323. * context lost for instance.
  56324. */
  56325. rebuild(): void;
  56326. /**
  56327. * Disposes the component and the associated ressources.
  56328. */
  56329. dispose(): void;
  56330. /**
  56331. * Renders the outline in the canvas.
  56332. * @param subMesh Defines the sumesh to render
  56333. * @param batch Defines the batch of meshes in case of instances
  56334. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56335. */
  56336. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56337. /**
  56338. * Returns whether or not the outline renderer is ready for a given submesh.
  56339. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56340. * @param subMesh Defines the submesh to check readyness for
  56341. * @param useInstances Defines wheter wee are trying to render instances or not
  56342. * @returns true if ready otherwise false
  56343. */
  56344. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56345. private _beforeRenderingMesh;
  56346. private _afterRenderingMesh;
  56347. }
  56348. }
  56349. declare module "babylonjs/Rendering/index" {
  56350. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56351. export * from "babylonjs/Rendering/depthRenderer";
  56352. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56353. export * from "babylonjs/Rendering/edgesRenderer";
  56354. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56355. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56356. export * from "babylonjs/Rendering/outlineRenderer";
  56357. export * from "babylonjs/Rendering/renderingGroup";
  56358. export * from "babylonjs/Rendering/renderingManager";
  56359. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56360. }
  56361. declare module "babylonjs/Sprites/index" {
  56362. export * from "babylonjs/Sprites/sprite";
  56363. export * from "babylonjs/Sprites/spriteManager";
  56364. export * from "babylonjs/Sprites/spriteSceneComponent";
  56365. }
  56366. declare module "babylonjs/Misc/assetsManager" {
  56367. import { Scene } from "babylonjs/scene";
  56368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56369. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56370. import { Skeleton } from "babylonjs/Bones/skeleton";
  56371. import { Observable } from "babylonjs/Misc/observable";
  56372. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56373. import { Texture } from "babylonjs/Materials/Textures/texture";
  56374. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56375. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56376. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56377. /**
  56378. * Defines the list of states available for a task inside a AssetsManager
  56379. */
  56380. export enum AssetTaskState {
  56381. /**
  56382. * Initialization
  56383. */
  56384. INIT = 0,
  56385. /**
  56386. * Running
  56387. */
  56388. RUNNING = 1,
  56389. /**
  56390. * Done
  56391. */
  56392. DONE = 2,
  56393. /**
  56394. * Error
  56395. */
  56396. ERROR = 3
  56397. }
  56398. /**
  56399. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56400. */
  56401. export abstract class AbstractAssetTask {
  56402. /**
  56403. * Task name
  56404. */ name: string;
  56405. /**
  56406. * Callback called when the task is successful
  56407. */
  56408. onSuccess: (task: any) => void;
  56409. /**
  56410. * Callback called when the task is not successful
  56411. */
  56412. onError: (task: any, message?: string, exception?: any) => void;
  56413. /**
  56414. * Creates a new AssetsManager
  56415. * @param name defines the name of the task
  56416. */
  56417. constructor(
  56418. /**
  56419. * Task name
  56420. */ name: string);
  56421. private _isCompleted;
  56422. private _taskState;
  56423. private _errorObject;
  56424. /**
  56425. * Get if the task is completed
  56426. */
  56427. readonly isCompleted: boolean;
  56428. /**
  56429. * Gets the current state of the task
  56430. */
  56431. readonly taskState: AssetTaskState;
  56432. /**
  56433. * Gets the current error object (if task is in error)
  56434. */
  56435. readonly errorObject: {
  56436. message?: string;
  56437. exception?: any;
  56438. };
  56439. /**
  56440. * Internal only
  56441. * @hidden
  56442. */
  56443. _setErrorObject(message?: string, exception?: any): void;
  56444. /**
  56445. * Execute the current task
  56446. * @param scene defines the scene where you want your assets to be loaded
  56447. * @param onSuccess is a callback called when the task is successfully executed
  56448. * @param onError is a callback called if an error occurs
  56449. */
  56450. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56451. /**
  56452. * Execute the current task
  56453. * @param scene defines the scene where you want your assets to be loaded
  56454. * @param onSuccess is a callback called when the task is successfully executed
  56455. * @param onError is a callback called if an error occurs
  56456. */
  56457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56458. /**
  56459. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56460. * This can be used with failed tasks that have the reason for failure fixed.
  56461. */
  56462. reset(): void;
  56463. private onErrorCallback;
  56464. private onDoneCallback;
  56465. }
  56466. /**
  56467. * Define the interface used by progress events raised during assets loading
  56468. */
  56469. export interface IAssetsProgressEvent {
  56470. /**
  56471. * Defines the number of remaining tasks to process
  56472. */
  56473. remainingCount: number;
  56474. /**
  56475. * Defines the total number of tasks
  56476. */
  56477. totalCount: number;
  56478. /**
  56479. * Defines the task that was just processed
  56480. */
  56481. task: AbstractAssetTask;
  56482. }
  56483. /**
  56484. * Class used to share progress information about assets loading
  56485. */
  56486. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56487. /**
  56488. * Defines the number of remaining tasks to process
  56489. */
  56490. remainingCount: number;
  56491. /**
  56492. * Defines the total number of tasks
  56493. */
  56494. totalCount: number;
  56495. /**
  56496. * Defines the task that was just processed
  56497. */
  56498. task: AbstractAssetTask;
  56499. /**
  56500. * Creates a AssetsProgressEvent
  56501. * @param remainingCount defines the number of remaining tasks to process
  56502. * @param totalCount defines the total number of tasks
  56503. * @param task defines the task that was just processed
  56504. */
  56505. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56506. }
  56507. /**
  56508. * Define a task used by AssetsManager to load meshes
  56509. */
  56510. export class MeshAssetTask extends AbstractAssetTask {
  56511. /**
  56512. * Defines the name of the task
  56513. */
  56514. name: string;
  56515. /**
  56516. * Defines the list of mesh's names you want to load
  56517. */
  56518. meshesNames: any;
  56519. /**
  56520. * Defines the root url to use as a base to load your meshes and associated resources
  56521. */
  56522. rootUrl: string;
  56523. /**
  56524. * Defines the filename of the scene to load from
  56525. */
  56526. sceneFilename: string;
  56527. /**
  56528. * Gets the list of loaded meshes
  56529. */
  56530. loadedMeshes: Array<AbstractMesh>;
  56531. /**
  56532. * Gets the list of loaded particle systems
  56533. */
  56534. loadedParticleSystems: Array<IParticleSystem>;
  56535. /**
  56536. * Gets the list of loaded skeletons
  56537. */
  56538. loadedSkeletons: Array<Skeleton>;
  56539. /**
  56540. * Gets the list of loaded animation groups
  56541. */
  56542. loadedAnimationGroups: Array<AnimationGroup>;
  56543. /**
  56544. * Callback called when the task is successful
  56545. */
  56546. onSuccess: (task: MeshAssetTask) => void;
  56547. /**
  56548. * Callback called when the task is successful
  56549. */
  56550. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56551. /**
  56552. * Creates a new MeshAssetTask
  56553. * @param name defines the name of the task
  56554. * @param meshesNames defines the list of mesh's names you want to load
  56555. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56556. * @param sceneFilename defines the filename of the scene to load from
  56557. */
  56558. constructor(
  56559. /**
  56560. * Defines the name of the task
  56561. */
  56562. name: string,
  56563. /**
  56564. * Defines the list of mesh's names you want to load
  56565. */
  56566. meshesNames: any,
  56567. /**
  56568. * Defines the root url to use as a base to load your meshes and associated resources
  56569. */
  56570. rootUrl: string,
  56571. /**
  56572. * Defines the filename of the scene to load from
  56573. */
  56574. sceneFilename: string);
  56575. /**
  56576. * Execute the current task
  56577. * @param scene defines the scene where you want your assets to be loaded
  56578. * @param onSuccess is a callback called when the task is successfully executed
  56579. * @param onError is a callback called if an error occurs
  56580. */
  56581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56582. }
  56583. /**
  56584. * Define a task used by AssetsManager to load text content
  56585. */
  56586. export class TextFileAssetTask extends AbstractAssetTask {
  56587. /**
  56588. * Defines the name of the task
  56589. */
  56590. name: string;
  56591. /**
  56592. * Defines the location of the file to load
  56593. */
  56594. url: string;
  56595. /**
  56596. * Gets the loaded text string
  56597. */
  56598. text: string;
  56599. /**
  56600. * Callback called when the task is successful
  56601. */
  56602. onSuccess: (task: TextFileAssetTask) => void;
  56603. /**
  56604. * Callback called when the task is successful
  56605. */
  56606. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56607. /**
  56608. * Creates a new TextFileAssetTask object
  56609. * @param name defines the name of the task
  56610. * @param url defines the location of the file to load
  56611. */
  56612. constructor(
  56613. /**
  56614. * Defines the name of the task
  56615. */
  56616. name: string,
  56617. /**
  56618. * Defines the location of the file to load
  56619. */
  56620. url: string);
  56621. /**
  56622. * Execute the current task
  56623. * @param scene defines the scene where you want your assets to be loaded
  56624. * @param onSuccess is a callback called when the task is successfully executed
  56625. * @param onError is a callback called if an error occurs
  56626. */
  56627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56628. }
  56629. /**
  56630. * Define a task used by AssetsManager to load binary data
  56631. */
  56632. export class BinaryFileAssetTask extends AbstractAssetTask {
  56633. /**
  56634. * Defines the name of the task
  56635. */
  56636. name: string;
  56637. /**
  56638. * Defines the location of the file to load
  56639. */
  56640. url: string;
  56641. /**
  56642. * Gets the lodaded data (as an array buffer)
  56643. */
  56644. data: ArrayBuffer;
  56645. /**
  56646. * Callback called when the task is successful
  56647. */
  56648. onSuccess: (task: BinaryFileAssetTask) => void;
  56649. /**
  56650. * Callback called when the task is successful
  56651. */
  56652. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56653. /**
  56654. * Creates a new BinaryFileAssetTask object
  56655. * @param name defines the name of the new task
  56656. * @param url defines the location of the file to load
  56657. */
  56658. constructor(
  56659. /**
  56660. * Defines the name of the task
  56661. */
  56662. name: string,
  56663. /**
  56664. * Defines the location of the file to load
  56665. */
  56666. url: string);
  56667. /**
  56668. * Execute the current task
  56669. * @param scene defines the scene where you want your assets to be loaded
  56670. * @param onSuccess is a callback called when the task is successfully executed
  56671. * @param onError is a callback called if an error occurs
  56672. */
  56673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56674. }
  56675. /**
  56676. * Define a task used by AssetsManager to load images
  56677. */
  56678. export class ImageAssetTask extends AbstractAssetTask {
  56679. /**
  56680. * Defines the name of the task
  56681. */
  56682. name: string;
  56683. /**
  56684. * Defines the location of the image to load
  56685. */
  56686. url: string;
  56687. /**
  56688. * Gets the loaded images
  56689. */
  56690. image: HTMLImageElement;
  56691. /**
  56692. * Callback called when the task is successful
  56693. */
  56694. onSuccess: (task: ImageAssetTask) => void;
  56695. /**
  56696. * Callback called when the task is successful
  56697. */
  56698. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56699. /**
  56700. * Creates a new ImageAssetTask
  56701. * @param name defines the name of the task
  56702. * @param url defines the location of the image to load
  56703. */
  56704. constructor(
  56705. /**
  56706. * Defines the name of the task
  56707. */
  56708. name: string,
  56709. /**
  56710. * Defines the location of the image to load
  56711. */
  56712. url: string);
  56713. /**
  56714. * Execute the current task
  56715. * @param scene defines the scene where you want your assets to be loaded
  56716. * @param onSuccess is a callback called when the task is successfully executed
  56717. * @param onError is a callback called if an error occurs
  56718. */
  56719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56720. }
  56721. /**
  56722. * Defines the interface used by texture loading tasks
  56723. */
  56724. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56725. /**
  56726. * Gets the loaded texture
  56727. */
  56728. texture: TEX;
  56729. }
  56730. /**
  56731. * Define a task used by AssetsManager to load 2D textures
  56732. */
  56733. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56734. /**
  56735. * Defines the name of the task
  56736. */
  56737. name: string;
  56738. /**
  56739. * Defines the location of the file to load
  56740. */
  56741. url: string;
  56742. /**
  56743. * Defines if mipmap should not be generated (default is false)
  56744. */
  56745. noMipmap?: boolean | undefined;
  56746. /**
  56747. * Defines if texture must be inverted on Y axis (default is false)
  56748. */
  56749. invertY?: boolean | undefined;
  56750. /**
  56751. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56752. */
  56753. samplingMode: number;
  56754. /**
  56755. * Gets the loaded texture
  56756. */
  56757. texture: Texture;
  56758. /**
  56759. * Callback called when the task is successful
  56760. */
  56761. onSuccess: (task: TextureAssetTask) => void;
  56762. /**
  56763. * Callback called when the task is successful
  56764. */
  56765. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56766. /**
  56767. * Creates a new TextureAssetTask object
  56768. * @param name defines the name of the task
  56769. * @param url defines the location of the file to load
  56770. * @param noMipmap defines if mipmap should not be generated (default is false)
  56771. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56772. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56773. */
  56774. constructor(
  56775. /**
  56776. * Defines the name of the task
  56777. */
  56778. name: string,
  56779. /**
  56780. * Defines the location of the file to load
  56781. */
  56782. url: string,
  56783. /**
  56784. * Defines if mipmap should not be generated (default is false)
  56785. */
  56786. noMipmap?: boolean | undefined,
  56787. /**
  56788. * Defines if texture must be inverted on Y axis (default is false)
  56789. */
  56790. invertY?: boolean | undefined,
  56791. /**
  56792. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56793. */
  56794. samplingMode?: number);
  56795. /**
  56796. * Execute the current task
  56797. * @param scene defines the scene where you want your assets to be loaded
  56798. * @param onSuccess is a callback called when the task is successfully executed
  56799. * @param onError is a callback called if an error occurs
  56800. */
  56801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56802. }
  56803. /**
  56804. * Define a task used by AssetsManager to load cube textures
  56805. */
  56806. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56807. /**
  56808. * Defines the name of the task
  56809. */
  56810. name: string;
  56811. /**
  56812. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56813. */
  56814. url: string;
  56815. /**
  56816. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56817. */
  56818. extensions?: string[] | undefined;
  56819. /**
  56820. * Defines if mipmaps should not be generated (default is false)
  56821. */
  56822. noMipmap?: boolean | undefined;
  56823. /**
  56824. * Defines the explicit list of files (undefined by default)
  56825. */
  56826. files?: string[] | undefined;
  56827. /**
  56828. * Gets the loaded texture
  56829. */
  56830. texture: CubeTexture;
  56831. /**
  56832. * Callback called when the task is successful
  56833. */
  56834. onSuccess: (task: CubeTextureAssetTask) => void;
  56835. /**
  56836. * Callback called when the task is successful
  56837. */
  56838. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56839. /**
  56840. * Creates a new CubeTextureAssetTask
  56841. * @param name defines the name of the task
  56842. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56843. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56844. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56845. * @param files defines the explicit list of files (undefined by default)
  56846. */
  56847. constructor(
  56848. /**
  56849. * Defines the name of the task
  56850. */
  56851. name: string,
  56852. /**
  56853. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56854. */
  56855. url: string,
  56856. /**
  56857. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56858. */
  56859. extensions?: string[] | undefined,
  56860. /**
  56861. * Defines if mipmaps should not be generated (default is false)
  56862. */
  56863. noMipmap?: boolean | undefined,
  56864. /**
  56865. * Defines the explicit list of files (undefined by default)
  56866. */
  56867. files?: string[] | undefined);
  56868. /**
  56869. * Execute the current task
  56870. * @param scene defines the scene where you want your assets to be loaded
  56871. * @param onSuccess is a callback called when the task is successfully executed
  56872. * @param onError is a callback called if an error occurs
  56873. */
  56874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56875. }
  56876. /**
  56877. * Define a task used by AssetsManager to load HDR cube textures
  56878. */
  56879. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56880. /**
  56881. * Defines the name of the task
  56882. */
  56883. name: string;
  56884. /**
  56885. * Defines the location of the file to load
  56886. */
  56887. url: string;
  56888. /**
  56889. * Defines the desired size (the more it increases the longer the generation will be)
  56890. */
  56891. size: number;
  56892. /**
  56893. * Defines if mipmaps should not be generated (default is false)
  56894. */
  56895. noMipmap: boolean;
  56896. /**
  56897. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56898. */
  56899. generateHarmonics: boolean;
  56900. /**
  56901. * 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)
  56902. */
  56903. gammaSpace: boolean;
  56904. /**
  56905. * Internal Use Only
  56906. */
  56907. reserved: boolean;
  56908. /**
  56909. * Gets the loaded texture
  56910. */
  56911. texture: HDRCubeTexture;
  56912. /**
  56913. * Callback called when the task is successful
  56914. */
  56915. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56916. /**
  56917. * Callback called when the task is successful
  56918. */
  56919. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56920. /**
  56921. * Creates a new HDRCubeTextureAssetTask object
  56922. * @param name defines the name of the task
  56923. * @param url defines the location of the file to load
  56924. * @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.
  56925. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56926. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56927. * @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)
  56928. * @param reserved Internal use only
  56929. */
  56930. constructor(
  56931. /**
  56932. * Defines the name of the task
  56933. */
  56934. name: string,
  56935. /**
  56936. * Defines the location of the file to load
  56937. */
  56938. url: string,
  56939. /**
  56940. * Defines the desired size (the more it increases the longer the generation will be)
  56941. */
  56942. size: number,
  56943. /**
  56944. * Defines if mipmaps should not be generated (default is false)
  56945. */
  56946. noMipmap?: boolean,
  56947. /**
  56948. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56949. */
  56950. generateHarmonics?: boolean,
  56951. /**
  56952. * 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)
  56953. */
  56954. gammaSpace?: boolean,
  56955. /**
  56956. * Internal Use Only
  56957. */
  56958. reserved?: boolean);
  56959. /**
  56960. * Execute the current task
  56961. * @param scene defines the scene where you want your assets to be loaded
  56962. * @param onSuccess is a callback called when the task is successfully executed
  56963. * @param onError is a callback called if an error occurs
  56964. */
  56965. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56966. }
  56967. /**
  56968. * This class can be used to easily import assets into a scene
  56969. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56970. */
  56971. export class AssetsManager {
  56972. private _scene;
  56973. private _isLoading;
  56974. protected _tasks: AbstractAssetTask[];
  56975. protected _waitingTasksCount: number;
  56976. protected _totalTasksCount: number;
  56977. /**
  56978. * Callback called when all tasks are processed
  56979. */
  56980. onFinish: (tasks: AbstractAssetTask[]) => void;
  56981. /**
  56982. * Callback called when a task is successful
  56983. */
  56984. onTaskSuccess: (task: AbstractAssetTask) => void;
  56985. /**
  56986. * Callback called when a task had an error
  56987. */
  56988. onTaskError: (task: AbstractAssetTask) => void;
  56989. /**
  56990. * Callback called when a task is done (whatever the result is)
  56991. */
  56992. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56993. /**
  56994. * Observable called when all tasks are processed
  56995. */
  56996. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56997. /**
  56998. * Observable called when a task had an error
  56999. */
  57000. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57001. /**
  57002. * Observable called when all tasks were executed
  57003. */
  57004. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57005. /**
  57006. * Observable called when a task is done (whatever the result is)
  57007. */
  57008. onProgressObservable: Observable<IAssetsProgressEvent>;
  57009. /**
  57010. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57011. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57012. */
  57013. useDefaultLoadingScreen: boolean;
  57014. /**
  57015. * Creates a new AssetsManager
  57016. * @param scene defines the scene to work on
  57017. */
  57018. constructor(scene: Scene);
  57019. /**
  57020. * Add a MeshAssetTask to the list of active tasks
  57021. * @param taskName defines the name of the new task
  57022. * @param meshesNames defines the name of meshes to load
  57023. * @param rootUrl defines the root url to use to locate files
  57024. * @param sceneFilename defines the filename of the scene file
  57025. * @returns a new MeshAssetTask object
  57026. */
  57027. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57028. /**
  57029. * Add a TextFileAssetTask to the list of active tasks
  57030. * @param taskName defines the name of the new task
  57031. * @param url defines the url of the file to load
  57032. * @returns a new TextFileAssetTask object
  57033. */
  57034. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57035. /**
  57036. * Add a BinaryFileAssetTask to the list of active tasks
  57037. * @param taskName defines the name of the new task
  57038. * @param url defines the url of the file to load
  57039. * @returns a new BinaryFileAssetTask object
  57040. */
  57041. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57042. /**
  57043. * Add a ImageAssetTask to the list of active tasks
  57044. * @param taskName defines the name of the new task
  57045. * @param url defines the url of the file to load
  57046. * @returns a new ImageAssetTask object
  57047. */
  57048. addImageTask(taskName: string, url: string): ImageAssetTask;
  57049. /**
  57050. * Add a TextureAssetTask to the list of active tasks
  57051. * @param taskName defines the name of the new task
  57052. * @param url defines the url of the file to load
  57053. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57054. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57055. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57056. * @returns a new TextureAssetTask object
  57057. */
  57058. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57059. /**
  57060. * Add a CubeTextureAssetTask to the list of active tasks
  57061. * @param taskName defines the name of the new task
  57062. * @param url defines the url of the file to load
  57063. * @param extensions defines the extension to use to load the cube map (can be null)
  57064. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57065. * @param files defines the list of files to load (can be null)
  57066. * @returns a new CubeTextureAssetTask object
  57067. */
  57068. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57069. /**
  57070. *
  57071. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57072. * @param taskName defines the name of the new task
  57073. * @param url defines the url of the file to load
  57074. * @param size defines the size you want for the cubemap (can be null)
  57075. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57076. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57077. * @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)
  57078. * @param reserved Internal use only
  57079. * @returns a new HDRCubeTextureAssetTask object
  57080. */
  57081. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57082. /**
  57083. * Remove a task from the assets manager.
  57084. * @param task the task to remove
  57085. */
  57086. removeTask(task: AbstractAssetTask): void;
  57087. private _decreaseWaitingTasksCount;
  57088. private _runTask;
  57089. /**
  57090. * Reset the AssetsManager and remove all tasks
  57091. * @return the current instance of the AssetsManager
  57092. */
  57093. reset(): AssetsManager;
  57094. /**
  57095. * Start the loading process
  57096. * @return the current instance of the AssetsManager
  57097. */
  57098. load(): AssetsManager;
  57099. /**
  57100. * Start the loading process as an async operation
  57101. * @return a promise returning the list of failed tasks
  57102. */
  57103. loadAsync(): Promise<void>;
  57104. }
  57105. }
  57106. declare module "babylonjs/Misc/deferred" {
  57107. /**
  57108. * Wrapper class for promise with external resolve and reject.
  57109. */
  57110. export class Deferred<T> {
  57111. /**
  57112. * The promise associated with this deferred object.
  57113. */
  57114. readonly promise: Promise<T>;
  57115. private _resolve;
  57116. private _reject;
  57117. /**
  57118. * The resolve method of the promise associated with this deferred object.
  57119. */
  57120. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57121. /**
  57122. * The reject method of the promise associated with this deferred object.
  57123. */
  57124. readonly reject: (reason?: any) => void;
  57125. /**
  57126. * Constructor for this deferred object.
  57127. */
  57128. constructor();
  57129. }
  57130. }
  57131. declare module "babylonjs/Misc/meshExploder" {
  57132. import { Mesh } from "babylonjs/Meshes/mesh";
  57133. /**
  57134. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57135. */
  57136. export class MeshExploder {
  57137. private _centerMesh;
  57138. private _meshes;
  57139. private _meshesOrigins;
  57140. private _toCenterVectors;
  57141. private _scaledDirection;
  57142. private _newPosition;
  57143. private _centerPosition;
  57144. /**
  57145. * Explodes meshes from a center mesh.
  57146. * @param meshes The meshes to explode.
  57147. * @param centerMesh The mesh to be center of explosion.
  57148. */
  57149. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57150. private _setCenterMesh;
  57151. /**
  57152. * Get class name
  57153. * @returns "MeshExploder"
  57154. */
  57155. getClassName(): string;
  57156. /**
  57157. * "Exploded meshes"
  57158. * @returns Array of meshes with the centerMesh at index 0.
  57159. */
  57160. getMeshes(): Array<Mesh>;
  57161. /**
  57162. * Explodes meshes giving a specific direction
  57163. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57164. */
  57165. explode(direction?: number): void;
  57166. }
  57167. }
  57168. declare module "babylonjs/Misc/filesInput" {
  57169. import { Engine } from "babylonjs/Engines/engine";
  57170. import { Scene } from "babylonjs/scene";
  57171. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57172. /**
  57173. * Class used to help managing file picking and drag'n'drop
  57174. */
  57175. export class FilesInput {
  57176. /**
  57177. * List of files ready to be loaded
  57178. */
  57179. static readonly FilesToLoad: {
  57180. [key: string]: File;
  57181. };
  57182. /**
  57183. * Callback called when a file is processed
  57184. */
  57185. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57186. private _engine;
  57187. private _currentScene;
  57188. private _sceneLoadedCallback;
  57189. private _progressCallback;
  57190. private _additionalRenderLoopLogicCallback;
  57191. private _textureLoadingCallback;
  57192. private _startingProcessingFilesCallback;
  57193. private _onReloadCallback;
  57194. private _errorCallback;
  57195. private _elementToMonitor;
  57196. private _sceneFileToLoad;
  57197. private _filesToLoad;
  57198. /**
  57199. * Creates a new FilesInput
  57200. * @param engine defines the rendering engine
  57201. * @param scene defines the hosting scene
  57202. * @param sceneLoadedCallback callback called when scene is loaded
  57203. * @param progressCallback callback called to track progress
  57204. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57205. * @param textureLoadingCallback callback called when a texture is loading
  57206. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57207. * @param onReloadCallback callback called when a reload is requested
  57208. * @param errorCallback callback call if an error occurs
  57209. */
  57210. 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);
  57211. private _dragEnterHandler;
  57212. private _dragOverHandler;
  57213. private _dropHandler;
  57214. /**
  57215. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57216. * @param elementToMonitor defines the DOM element to track
  57217. */
  57218. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57219. /**
  57220. * Release all associated resources
  57221. */
  57222. dispose(): void;
  57223. private renderFunction;
  57224. private drag;
  57225. private drop;
  57226. private _traverseFolder;
  57227. private _processFiles;
  57228. /**
  57229. * Load files from a drop event
  57230. * @param event defines the drop event to use as source
  57231. */
  57232. loadFiles(event: any): void;
  57233. private _processReload;
  57234. /**
  57235. * Reload the current scene from the loaded files
  57236. */
  57237. reload(): void;
  57238. }
  57239. }
  57240. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57241. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57242. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57243. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57244. }
  57245. declare module "babylonjs/Misc/sceneOptimizer" {
  57246. import { Scene, IDisposable } from "babylonjs/scene";
  57247. import { Observable } from "babylonjs/Misc/observable";
  57248. /**
  57249. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57250. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57251. */
  57252. export class SceneOptimization {
  57253. /**
  57254. * Defines the priority of this optimization (0 by default which means first in the list)
  57255. */
  57256. priority: number;
  57257. /**
  57258. * Gets a string describing the action executed by the current optimization
  57259. * @returns description string
  57260. */
  57261. getDescription(): string;
  57262. /**
  57263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57264. * @param scene defines the current scene where to apply this optimization
  57265. * @param optimizer defines the current optimizer
  57266. * @returns true if everything that can be done was applied
  57267. */
  57268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57269. /**
  57270. * Creates the SceneOptimization object
  57271. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57272. * @param desc defines the description associated with the optimization
  57273. */
  57274. constructor(
  57275. /**
  57276. * Defines the priority of this optimization (0 by default which means first in the list)
  57277. */
  57278. priority?: number);
  57279. }
  57280. /**
  57281. * Defines an optimization used to reduce the size of render target textures
  57282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57283. */
  57284. export class TextureOptimization extends SceneOptimization {
  57285. /**
  57286. * Defines the priority of this optimization (0 by default which means first in the list)
  57287. */
  57288. priority: number;
  57289. /**
  57290. * 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
  57291. */
  57292. maximumSize: number;
  57293. /**
  57294. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57295. */
  57296. step: number;
  57297. /**
  57298. * Gets a string describing the action executed by the current optimization
  57299. * @returns description string
  57300. */
  57301. getDescription(): string;
  57302. /**
  57303. * Creates the TextureOptimization object
  57304. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57305. * @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
  57306. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57307. */
  57308. constructor(
  57309. /**
  57310. * Defines the priority of this optimization (0 by default which means first in the list)
  57311. */
  57312. priority?: number,
  57313. /**
  57314. * 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
  57315. */
  57316. maximumSize?: number,
  57317. /**
  57318. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57319. */
  57320. step?: number);
  57321. /**
  57322. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57323. * @param scene defines the current scene where to apply this optimization
  57324. * @param optimizer defines the current optimizer
  57325. * @returns true if everything that can be done was applied
  57326. */
  57327. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57328. }
  57329. /**
  57330. * Defines an optimization used to increase or decrease the rendering resolution
  57331. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57332. */
  57333. export class HardwareScalingOptimization extends SceneOptimization {
  57334. /**
  57335. * Defines the priority of this optimization (0 by default which means first in the list)
  57336. */
  57337. priority: number;
  57338. /**
  57339. * Defines the maximum scale to use (2 by default)
  57340. */
  57341. maximumScale: number;
  57342. /**
  57343. * Defines the step to use between two passes (0.5 by default)
  57344. */
  57345. step: number;
  57346. private _currentScale;
  57347. private _directionOffset;
  57348. /**
  57349. * Gets a string describing the action executed by the current optimization
  57350. * @return description string
  57351. */
  57352. getDescription(): string;
  57353. /**
  57354. * Creates the HardwareScalingOptimization object
  57355. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57356. * @param maximumScale defines the maximum scale to use (2 by default)
  57357. * @param step defines the step to use between two passes (0.5 by default)
  57358. */
  57359. constructor(
  57360. /**
  57361. * Defines the priority of this optimization (0 by default which means first in the list)
  57362. */
  57363. priority?: number,
  57364. /**
  57365. * Defines the maximum scale to use (2 by default)
  57366. */
  57367. maximumScale?: number,
  57368. /**
  57369. * Defines the step to use between two passes (0.5 by default)
  57370. */
  57371. step?: number);
  57372. /**
  57373. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57374. * @param scene defines the current scene where to apply this optimization
  57375. * @param optimizer defines the current optimizer
  57376. * @returns true if everything that can be done was applied
  57377. */
  57378. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57379. }
  57380. /**
  57381. * Defines an optimization used to remove shadows
  57382. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57383. */
  57384. export class ShadowsOptimization extends SceneOptimization {
  57385. /**
  57386. * Gets a string describing the action executed by the current optimization
  57387. * @return description string
  57388. */
  57389. getDescription(): string;
  57390. /**
  57391. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57392. * @param scene defines the current scene where to apply this optimization
  57393. * @param optimizer defines the current optimizer
  57394. * @returns true if everything that can be done was applied
  57395. */
  57396. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57397. }
  57398. /**
  57399. * Defines an optimization used to turn post-processes off
  57400. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57401. */
  57402. export class PostProcessesOptimization extends SceneOptimization {
  57403. /**
  57404. * Gets a string describing the action executed by the current optimization
  57405. * @return description string
  57406. */
  57407. getDescription(): string;
  57408. /**
  57409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57410. * @param scene defines the current scene where to apply this optimization
  57411. * @param optimizer defines the current optimizer
  57412. * @returns true if everything that can be done was applied
  57413. */
  57414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57415. }
  57416. /**
  57417. * Defines an optimization used to turn lens flares off
  57418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57419. */
  57420. export class LensFlaresOptimization extends SceneOptimization {
  57421. /**
  57422. * Gets a string describing the action executed by the current optimization
  57423. * @return description string
  57424. */
  57425. getDescription(): string;
  57426. /**
  57427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57428. * @param scene defines the current scene where to apply this optimization
  57429. * @param optimizer defines the current optimizer
  57430. * @returns true if everything that can be done was applied
  57431. */
  57432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57433. }
  57434. /**
  57435. * Defines an optimization based on user defined callback.
  57436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57437. */
  57438. export class CustomOptimization extends SceneOptimization {
  57439. /**
  57440. * Callback called to apply the custom optimization.
  57441. */
  57442. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57443. /**
  57444. * Callback called to get custom description
  57445. */
  57446. onGetDescription: () => string;
  57447. /**
  57448. * Gets a string describing the action executed by the current optimization
  57449. * @returns description string
  57450. */
  57451. getDescription(): string;
  57452. /**
  57453. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57454. * @param scene defines the current scene where to apply this optimization
  57455. * @param optimizer defines the current optimizer
  57456. * @returns true if everything that can be done was applied
  57457. */
  57458. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57459. }
  57460. /**
  57461. * Defines an optimization used to turn particles off
  57462. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57463. */
  57464. export class ParticlesOptimization extends SceneOptimization {
  57465. /**
  57466. * Gets a string describing the action executed by the current optimization
  57467. * @return description string
  57468. */
  57469. getDescription(): string;
  57470. /**
  57471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57472. * @param scene defines the current scene where to apply this optimization
  57473. * @param optimizer defines the current optimizer
  57474. * @returns true if everything that can be done was applied
  57475. */
  57476. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57477. }
  57478. /**
  57479. * Defines an optimization used to turn render targets off
  57480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57481. */
  57482. export class RenderTargetsOptimization extends SceneOptimization {
  57483. /**
  57484. * Gets a string describing the action executed by the current optimization
  57485. * @return description string
  57486. */
  57487. getDescription(): string;
  57488. /**
  57489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57490. * @param scene defines the current scene where to apply this optimization
  57491. * @param optimizer defines the current optimizer
  57492. * @returns true if everything that can be done was applied
  57493. */
  57494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57495. }
  57496. /**
  57497. * Defines an optimization used to merge meshes with compatible materials
  57498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57499. */
  57500. export class MergeMeshesOptimization extends SceneOptimization {
  57501. private static _UpdateSelectionTree;
  57502. /**
  57503. * Gets or sets a boolean which defines if optimization octree has to be updated
  57504. */
  57505. /**
  57506. * Gets or sets a boolean which defines if optimization octree has to be updated
  57507. */
  57508. static UpdateSelectionTree: boolean;
  57509. /**
  57510. * Gets a string describing the action executed by the current optimization
  57511. * @return description string
  57512. */
  57513. getDescription(): string;
  57514. private _canBeMerged;
  57515. /**
  57516. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57517. * @param scene defines the current scene where to apply this optimization
  57518. * @param optimizer defines the current optimizer
  57519. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57520. * @returns true if everything that can be done was applied
  57521. */
  57522. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57523. }
  57524. /**
  57525. * Defines a list of options used by SceneOptimizer
  57526. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57527. */
  57528. export class SceneOptimizerOptions {
  57529. /**
  57530. * Defines the target frame rate to reach (60 by default)
  57531. */
  57532. targetFrameRate: number;
  57533. /**
  57534. * Defines the interval between two checkes (2000ms by default)
  57535. */
  57536. trackerDuration: number;
  57537. /**
  57538. * Gets the list of optimizations to apply
  57539. */
  57540. optimizations: SceneOptimization[];
  57541. /**
  57542. * Creates a new list of options used by SceneOptimizer
  57543. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57544. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57545. */
  57546. constructor(
  57547. /**
  57548. * Defines the target frame rate to reach (60 by default)
  57549. */
  57550. targetFrameRate?: number,
  57551. /**
  57552. * Defines the interval between two checkes (2000ms by default)
  57553. */
  57554. trackerDuration?: number);
  57555. /**
  57556. * Add a new optimization
  57557. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57558. * @returns the current SceneOptimizerOptions
  57559. */
  57560. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57561. /**
  57562. * Add a new custom optimization
  57563. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57564. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57565. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57566. * @returns the current SceneOptimizerOptions
  57567. */
  57568. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57569. /**
  57570. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57571. * @param targetFrameRate defines the target frame rate (60 by default)
  57572. * @returns a SceneOptimizerOptions object
  57573. */
  57574. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57575. /**
  57576. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57577. * @param targetFrameRate defines the target frame rate (60 by default)
  57578. * @returns a SceneOptimizerOptions object
  57579. */
  57580. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57581. /**
  57582. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57583. * @param targetFrameRate defines the target frame rate (60 by default)
  57584. * @returns a SceneOptimizerOptions object
  57585. */
  57586. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57587. }
  57588. /**
  57589. * Class used to run optimizations in order to reach a target frame rate
  57590. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57591. */
  57592. export class SceneOptimizer implements IDisposable {
  57593. private _isRunning;
  57594. private _options;
  57595. private _scene;
  57596. private _currentPriorityLevel;
  57597. private _targetFrameRate;
  57598. private _trackerDuration;
  57599. private _currentFrameRate;
  57600. private _sceneDisposeObserver;
  57601. private _improvementMode;
  57602. /**
  57603. * Defines an observable called when the optimizer reaches the target frame rate
  57604. */
  57605. onSuccessObservable: Observable<SceneOptimizer>;
  57606. /**
  57607. * Defines an observable called when the optimizer enables an optimization
  57608. */
  57609. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57610. /**
  57611. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57612. */
  57613. onFailureObservable: Observable<SceneOptimizer>;
  57614. /**
  57615. * Gets a boolean indicating if the optimizer is in improvement mode
  57616. */
  57617. readonly isInImprovementMode: boolean;
  57618. /**
  57619. * Gets the current priority level (0 at start)
  57620. */
  57621. readonly currentPriorityLevel: number;
  57622. /**
  57623. * Gets the current frame rate checked by the SceneOptimizer
  57624. */
  57625. readonly currentFrameRate: number;
  57626. /**
  57627. * Gets or sets the current target frame rate (60 by default)
  57628. */
  57629. /**
  57630. * Gets or sets the current target frame rate (60 by default)
  57631. */
  57632. targetFrameRate: number;
  57633. /**
  57634. * Gets or sets the current interval between two checks (every 2000ms by default)
  57635. */
  57636. /**
  57637. * Gets or sets the current interval between two checks (every 2000ms by default)
  57638. */
  57639. trackerDuration: number;
  57640. /**
  57641. * Gets the list of active optimizations
  57642. */
  57643. readonly optimizations: SceneOptimization[];
  57644. /**
  57645. * Creates a new SceneOptimizer
  57646. * @param scene defines the scene to work on
  57647. * @param options defines the options to use with the SceneOptimizer
  57648. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57649. * @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)
  57650. */
  57651. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57652. /**
  57653. * Stops the current optimizer
  57654. */
  57655. stop(): void;
  57656. /**
  57657. * Reset the optimizer to initial step (current priority level = 0)
  57658. */
  57659. reset(): void;
  57660. /**
  57661. * Start the optimizer. By default it will try to reach a specific framerate
  57662. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57663. */
  57664. start(): void;
  57665. private _checkCurrentState;
  57666. /**
  57667. * Release all resources
  57668. */
  57669. dispose(): void;
  57670. /**
  57671. * Helper function to create a SceneOptimizer with one single line of code
  57672. * @param scene defines the scene to work on
  57673. * @param options defines the options to use with the SceneOptimizer
  57674. * @param onSuccess defines a callback to call on success
  57675. * @param onFailure defines a callback to call on failure
  57676. * @returns the new SceneOptimizer object
  57677. */
  57678. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57679. }
  57680. }
  57681. declare module "babylonjs/Misc/sceneSerializer" {
  57682. import { Scene } from "babylonjs/scene";
  57683. /**
  57684. * Class used to serialize a scene into a string
  57685. */
  57686. export class SceneSerializer {
  57687. /**
  57688. * Clear cache used by a previous serialization
  57689. */
  57690. static ClearCache(): void;
  57691. /**
  57692. * Serialize a scene into a JSON compatible object
  57693. * @param scene defines the scene to serialize
  57694. * @returns a JSON compatible object
  57695. */
  57696. static Serialize(scene: Scene): any;
  57697. /**
  57698. * Serialize a mesh into a JSON compatible object
  57699. * @param toSerialize defines the mesh to serialize
  57700. * @param withParents defines if parents must be serialized as well
  57701. * @param withChildren defines if children must be serialized as well
  57702. * @returns a JSON compatible object
  57703. */
  57704. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57705. }
  57706. }
  57707. declare module "babylonjs/Misc/videoRecorder" {
  57708. import { Nullable } from "babylonjs/types";
  57709. import { Engine } from "babylonjs/Engines/engine";
  57710. /**
  57711. * This represents the different options avilable for the video capture.
  57712. */
  57713. export interface VideoRecorderOptions {
  57714. /** Defines the mime type of the video */
  57715. mimeType: string;
  57716. /** Defines the video the video should be recorded at */
  57717. fps: number;
  57718. /** Defines the chunk size for the recording data */
  57719. recordChunckSize: number;
  57720. /** The audio tracks to attach to the record */
  57721. audioTracks?: MediaStreamTrack[];
  57722. }
  57723. /**
  57724. * This can helps recording videos from BabylonJS.
  57725. * This is based on the available WebRTC functionalities of the browser.
  57726. *
  57727. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57728. */
  57729. export class VideoRecorder {
  57730. private static readonly _defaultOptions;
  57731. /**
  57732. * Returns wehther or not the VideoRecorder is available in your browser.
  57733. * @param engine Defines the Babylon Engine to check the support for
  57734. * @returns true if supported otherwise false
  57735. */
  57736. static IsSupported(engine: Engine): boolean;
  57737. private readonly _options;
  57738. private _canvas;
  57739. private _mediaRecorder;
  57740. private _recordedChunks;
  57741. private _fileName;
  57742. private _resolve;
  57743. private _reject;
  57744. /**
  57745. * True wether a recording is already in progress.
  57746. */
  57747. readonly isRecording: boolean;
  57748. /**
  57749. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57750. * a video file.
  57751. * @param engine Defines the BabylonJS Engine you wish to record
  57752. * @param options Defines options that can be used to customized the capture
  57753. */
  57754. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57755. /**
  57756. * Stops the current recording before the default capture timeout passed in the startRecording
  57757. * functions.
  57758. */
  57759. stopRecording(): void;
  57760. /**
  57761. * Starts recording the canvas for a max duration specified in parameters.
  57762. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  57763. * @param maxDuration Defines the maximum recording time in seconds.
  57764. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57765. * @return a promise callback at the end of the recording with the video data in Blob.
  57766. */
  57767. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57768. /**
  57769. * Releases internal resources used during the recording.
  57770. */
  57771. dispose(): void;
  57772. private _handleDataAvailable;
  57773. private _handleError;
  57774. private _handleStop;
  57775. }
  57776. }
  57777. declare module "babylonjs/Misc/workerPool" {
  57778. import { IDisposable } from "babylonjs/scene";
  57779. /**
  57780. * Helper class to push actions to a pool of workers.
  57781. */
  57782. export class WorkerPool implements IDisposable {
  57783. private _workerInfos;
  57784. private _pendingActions;
  57785. /**
  57786. * Constructor
  57787. * @param workers Array of workers to use for actions
  57788. */
  57789. constructor(workers: Array<Worker>);
  57790. /**
  57791. * Terminates all workers and clears any pending actions.
  57792. */
  57793. dispose(): void;
  57794. /**
  57795. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57796. * pended until a worker has completed its action.
  57797. * @param action The action to perform. Call onComplete when the action is complete.
  57798. */
  57799. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57800. private _execute;
  57801. }
  57802. }
  57803. declare module "babylonjs/Misc/screenshotTools" {
  57804. import { Camera } from "babylonjs/Cameras/camera";
  57805. import { Engine } from "babylonjs/Engines/engine";
  57806. /**
  57807. * Class containing a set of static utilities functions for screenshots
  57808. */
  57809. export class ScreenshotTools {
  57810. /**
  57811. * Captures a screenshot of the current rendering
  57812. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57813. * @param engine defines the rendering engine
  57814. * @param camera defines the source camera
  57815. * @param size This parameter can be set to a single number or to an object with the
  57816. * following (optional) properties: precision, width, height. If a single number is passed,
  57817. * it will be used for both width and height. If an object is passed, the screenshot size
  57818. * will be derived from the parameters. The precision property is a multiplier allowing
  57819. * rendering at a higher or lower resolution
  57820. * @param successCallback defines the callback receives a single parameter which contains the
  57821. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57822. * src parameter of an <img> to display it
  57823. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57824. * Check your browser for supported MIME types
  57825. */
  57826. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57827. /**
  57828. * Generates an image screenshot from the specified camera.
  57829. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57830. * @param engine The engine to use for rendering
  57831. * @param camera The camera to use for rendering
  57832. * @param size This parameter can be set to a single number or to an object with the
  57833. * following (optional) properties: precision, width, height. If a single number is passed,
  57834. * it will be used for both width and height. If an object is passed, the screenshot size
  57835. * will be derived from the parameters. The precision property is a multiplier allowing
  57836. * rendering at a higher or lower resolution
  57837. * @param successCallback The callback receives a single parameter which contains the
  57838. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57839. * src parameter of an <img> to display it
  57840. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57841. * Check your browser for supported MIME types
  57842. * @param samples Texture samples (default: 1)
  57843. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57844. * @param fileName A name for for the downloaded file.
  57845. */
  57846. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57847. }
  57848. }
  57849. declare module "babylonjs/Misc/index" {
  57850. export * from "babylonjs/Misc/andOrNotEvaluator";
  57851. export * from "babylonjs/Misc/assetsManager";
  57852. export * from "babylonjs/Misc/dds";
  57853. export * from "babylonjs/Misc/decorators";
  57854. export * from "babylonjs/Misc/deferred";
  57855. export * from "babylonjs/Misc/environmentTextureTools";
  57856. export * from "babylonjs/Misc/meshExploder";
  57857. export * from "babylonjs/Misc/filesInput";
  57858. export * from "babylonjs/Misc/HighDynamicRange/index";
  57859. export * from "babylonjs/Misc/khronosTextureContainer";
  57860. export * from "babylonjs/Misc/observable";
  57861. export * from "babylonjs/Misc/performanceMonitor";
  57862. export * from "babylonjs/Misc/promise";
  57863. export * from "babylonjs/Misc/sceneOptimizer";
  57864. export * from "babylonjs/Misc/sceneSerializer";
  57865. export * from "babylonjs/Misc/smartArray";
  57866. export * from "babylonjs/Misc/stringDictionary";
  57867. export * from "babylonjs/Misc/tags";
  57868. export * from "babylonjs/Misc/textureTools";
  57869. export * from "babylonjs/Misc/tga";
  57870. export * from "babylonjs/Misc/tools";
  57871. export * from "babylonjs/Misc/videoRecorder";
  57872. export * from "babylonjs/Misc/virtualJoystick";
  57873. export * from "babylonjs/Misc/workerPool";
  57874. export * from "babylonjs/Misc/logger";
  57875. export * from "babylonjs/Misc/typeStore";
  57876. export * from "babylonjs/Misc/filesInputStore";
  57877. export * from "babylonjs/Misc/deepCopier";
  57878. export * from "babylonjs/Misc/pivotTools";
  57879. export * from "babylonjs/Misc/precisionDate";
  57880. export * from "babylonjs/Misc/screenshotTools";
  57881. export * from "babylonjs/Misc/typeStore";
  57882. export * from "babylonjs/Misc/webRequest";
  57883. export * from "babylonjs/Misc/iInspectable";
  57884. }
  57885. declare module "babylonjs/index" {
  57886. export * from "babylonjs/abstractScene";
  57887. export * from "babylonjs/Actions/index";
  57888. export * from "babylonjs/Animations/index";
  57889. export * from "babylonjs/assetContainer";
  57890. export * from "babylonjs/Audio/index";
  57891. export * from "babylonjs/Behaviors/index";
  57892. export * from "babylonjs/Bones/index";
  57893. export * from "babylonjs/Cameras/index";
  57894. export * from "babylonjs/Collisions/index";
  57895. export * from "babylonjs/Culling/index";
  57896. export * from "babylonjs/Debug/index";
  57897. export * from "babylonjs/Engines/index";
  57898. export * from "babylonjs/Events/index";
  57899. export * from "babylonjs/Gamepads/index";
  57900. export * from "babylonjs/Gizmos/index";
  57901. export * from "babylonjs/Helpers/index";
  57902. export * from "babylonjs/Instrumentation/index";
  57903. export * from "babylonjs/Layers/index";
  57904. export * from "babylonjs/LensFlares/index";
  57905. export * from "babylonjs/Lights/index";
  57906. export * from "babylonjs/Loading/index";
  57907. export * from "babylonjs/Materials/index";
  57908. export * from "babylonjs/Maths/index";
  57909. export * from "babylonjs/Meshes/index";
  57910. export * from "babylonjs/Morph/index";
  57911. export * from "babylonjs/node";
  57912. export * from "babylonjs/Offline/index";
  57913. export * from "babylonjs/Particles/index";
  57914. export * from "babylonjs/Physics/index";
  57915. export * from "babylonjs/PostProcesses/index";
  57916. export * from "babylonjs/Probes/index";
  57917. export * from "babylonjs/Rendering/index";
  57918. export * from "babylonjs/scene";
  57919. export * from "babylonjs/sceneComponent";
  57920. export * from "babylonjs/Sprites/index";
  57921. export * from "babylonjs/States/index";
  57922. export * from "babylonjs/Misc/index";
  57923. export * from "babylonjs/types";
  57924. }
  57925. declare module "babylonjs/Animations/pathCursor" {
  57926. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57927. /**
  57928. * A cursor which tracks a point on a path
  57929. */
  57930. export class PathCursor {
  57931. private path;
  57932. /**
  57933. * Stores path cursor callbacks for when an onchange event is triggered
  57934. */
  57935. private _onchange;
  57936. /**
  57937. * The value of the path cursor
  57938. */
  57939. value: number;
  57940. /**
  57941. * The animation array of the path cursor
  57942. */
  57943. animations: Animation[];
  57944. /**
  57945. * Initializes the path cursor
  57946. * @param path The path to track
  57947. */
  57948. constructor(path: Path2);
  57949. /**
  57950. * Gets the cursor point on the path
  57951. * @returns A point on the path cursor at the cursor location
  57952. */
  57953. getPoint(): Vector3;
  57954. /**
  57955. * Moves the cursor ahead by the step amount
  57956. * @param step The amount to move the cursor forward
  57957. * @returns This path cursor
  57958. */
  57959. moveAhead(step?: number): PathCursor;
  57960. /**
  57961. * Moves the cursor behind by the step amount
  57962. * @param step The amount to move the cursor back
  57963. * @returns This path cursor
  57964. */
  57965. moveBack(step?: number): PathCursor;
  57966. /**
  57967. * Moves the cursor by the step amount
  57968. * If the step amount is greater than one, an exception is thrown
  57969. * @param step The amount to move the cursor
  57970. * @returns This path cursor
  57971. */
  57972. move(step: number): PathCursor;
  57973. /**
  57974. * Ensures that the value is limited between zero and one
  57975. * @returns This path cursor
  57976. */
  57977. private ensureLimits;
  57978. /**
  57979. * Runs onchange callbacks on change (used by the animation engine)
  57980. * @returns This path cursor
  57981. */
  57982. private raiseOnChange;
  57983. /**
  57984. * Executes a function on change
  57985. * @param f A path cursor onchange callback
  57986. * @returns This path cursor
  57987. */
  57988. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57989. }
  57990. }
  57991. declare module "babylonjs/Legacy/legacy" {
  57992. import * as Babylon from "babylonjs/index";
  57993. export * from "babylonjs/index";
  57994. }
  57995. declare module "babylonjs/Shaders/blur.fragment" {
  57996. /** @hidden */
  57997. export var blurPixelShader: {
  57998. name: string;
  57999. shader: string;
  58000. };
  58001. }
  58002. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58003. /** @hidden */
  58004. export var bones300Declaration: {
  58005. name: string;
  58006. shader: string;
  58007. };
  58008. }
  58009. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58010. /** @hidden */
  58011. export var instances300Declaration: {
  58012. name: string;
  58013. shader: string;
  58014. };
  58015. }
  58016. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58017. /** @hidden */
  58018. export var pointCloudVertexDeclaration: {
  58019. name: string;
  58020. shader: string;
  58021. };
  58022. }
  58023. // Mixins
  58024. interface Window {
  58025. mozIndexedDB: IDBFactory;
  58026. webkitIndexedDB: IDBFactory;
  58027. msIndexedDB: IDBFactory;
  58028. webkitURL: typeof URL;
  58029. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58030. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58031. WebGLRenderingContext: WebGLRenderingContext;
  58032. MSGesture: MSGesture;
  58033. CANNON: any;
  58034. AudioContext: AudioContext;
  58035. webkitAudioContext: AudioContext;
  58036. PointerEvent: any;
  58037. Math: Math;
  58038. Uint8Array: Uint8ArrayConstructor;
  58039. Float32Array: Float32ArrayConstructor;
  58040. mozURL: typeof URL;
  58041. msURL: typeof URL;
  58042. VRFrameData: any; // WebVR, from specs 1.1
  58043. DracoDecoderModule: any;
  58044. setImmediate(handler: (...args: any[]) => void): number;
  58045. }
  58046. interface HTMLCanvasElement {
  58047. requestPointerLock(): void;
  58048. msRequestPointerLock?(): void;
  58049. mozRequestPointerLock?(): void;
  58050. webkitRequestPointerLock?(): void;
  58051. /** Track wether a record is in progress */
  58052. isRecording: boolean;
  58053. /** Capture Stream method defined by some browsers */
  58054. captureStream(fps?: number): MediaStream;
  58055. }
  58056. interface CanvasRenderingContext2D {
  58057. msImageSmoothingEnabled: boolean;
  58058. }
  58059. interface MouseEvent {
  58060. mozMovementX: number;
  58061. mozMovementY: number;
  58062. webkitMovementX: number;
  58063. webkitMovementY: number;
  58064. msMovementX: number;
  58065. msMovementY: number;
  58066. }
  58067. interface Navigator {
  58068. mozGetVRDevices: (any: any) => any;
  58069. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58070. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58071. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58072. webkitGetGamepads(): Gamepad[];
  58073. msGetGamepads(): Gamepad[];
  58074. webkitGamepads(): Gamepad[];
  58075. }
  58076. interface HTMLVideoElement {
  58077. mozSrcObject: any;
  58078. }
  58079. interface Math {
  58080. fround(x: number): number;
  58081. imul(a: number, b: number): number;
  58082. }
  58083. interface WebGLProgram {
  58084. context?: WebGLRenderingContext;
  58085. vertexShader?: WebGLShader;
  58086. fragmentShader?: WebGLShader;
  58087. isParallelCompiled: boolean;
  58088. onCompiled?: () => void;
  58089. }
  58090. interface WebGLRenderingContext {
  58091. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58092. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58093. vertexAttribDivisor(index: number, divisor: number): void;
  58094. createVertexArray(): any;
  58095. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58096. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58097. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58098. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58099. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58100. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58101. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58102. // Queries
  58103. createQuery(): WebGLQuery;
  58104. deleteQuery(query: WebGLQuery): void;
  58105. beginQuery(target: number, query: WebGLQuery): void;
  58106. endQuery(target: number): void;
  58107. getQueryParameter(query: WebGLQuery, pname: number): any;
  58108. getQuery(target: number, pname: number): any;
  58109. MAX_SAMPLES: number;
  58110. RGBA8: number;
  58111. READ_FRAMEBUFFER: number;
  58112. DRAW_FRAMEBUFFER: number;
  58113. UNIFORM_BUFFER: number;
  58114. HALF_FLOAT_OES: number;
  58115. RGBA16F: number;
  58116. RGBA32F: number;
  58117. R32F: number;
  58118. RG32F: number;
  58119. RGB32F: number;
  58120. R16F: number;
  58121. RG16F: number;
  58122. RGB16F: number;
  58123. RED: number;
  58124. RG: number;
  58125. R8: number;
  58126. RG8: number;
  58127. UNSIGNED_INT_24_8: number;
  58128. DEPTH24_STENCIL8: number;
  58129. /* Multiple Render Targets */
  58130. drawBuffers(buffers: number[]): void;
  58131. readBuffer(src: number): void;
  58132. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58133. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58134. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58135. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58136. // Occlusion Query
  58137. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58138. ANY_SAMPLES_PASSED: number;
  58139. QUERY_RESULT_AVAILABLE: number;
  58140. QUERY_RESULT: number;
  58141. }
  58142. interface WebGLBuffer {
  58143. references: number;
  58144. capacity: number;
  58145. is32Bits: boolean;
  58146. }
  58147. interface WebGLProgram {
  58148. transformFeedback?: WebGLTransformFeedback | null;
  58149. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58150. }
  58151. interface EXT_disjoint_timer_query {
  58152. QUERY_COUNTER_BITS_EXT: number;
  58153. TIME_ELAPSED_EXT: number;
  58154. TIMESTAMP_EXT: number;
  58155. GPU_DISJOINT_EXT: number;
  58156. QUERY_RESULT_EXT: number;
  58157. QUERY_RESULT_AVAILABLE_EXT: number;
  58158. queryCounterEXT(query: WebGLQuery, target: number): void;
  58159. createQueryEXT(): WebGLQuery;
  58160. beginQueryEXT(target: number, query: WebGLQuery): void;
  58161. endQueryEXT(target: number): void;
  58162. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58163. deleteQueryEXT(query: WebGLQuery): void;
  58164. }
  58165. interface WebGLUniformLocation {
  58166. _currentState: any;
  58167. }
  58168. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58169. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58170. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58171. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58172. interface WebGLRenderingContext {
  58173. readonly RASTERIZER_DISCARD: number;
  58174. readonly DEPTH_COMPONENT24: number;
  58175. readonly TEXTURE_3D: number;
  58176. readonly TEXTURE_2D_ARRAY: number;
  58177. readonly TEXTURE_COMPARE_FUNC: number;
  58178. readonly TEXTURE_COMPARE_MODE: number;
  58179. readonly COMPARE_REF_TO_TEXTURE: number;
  58180. readonly TEXTURE_WRAP_R: number;
  58181. readonly HALF_FLOAT: number;
  58182. readonly RGB8: number;
  58183. readonly RED_INTEGER: number;
  58184. readonly RG_INTEGER: number;
  58185. readonly RGB_INTEGER: number;
  58186. readonly RGBA_INTEGER: number;
  58187. readonly R8_SNORM: number;
  58188. readonly RG8_SNORM: number;
  58189. readonly RGB8_SNORM: number;
  58190. readonly RGBA8_SNORM: number;
  58191. readonly R8I: number;
  58192. readonly RG8I: number;
  58193. readonly RGB8I: number;
  58194. readonly RGBA8I: number;
  58195. readonly R8UI: number;
  58196. readonly RG8UI: number;
  58197. readonly RGB8UI: number;
  58198. readonly RGBA8UI: number;
  58199. readonly R16I: number;
  58200. readonly RG16I: number;
  58201. readonly RGB16I: number;
  58202. readonly RGBA16I: number;
  58203. readonly R16UI: number;
  58204. readonly RG16UI: number;
  58205. readonly RGB16UI: number;
  58206. readonly RGBA16UI: number;
  58207. readonly R32I: number;
  58208. readonly RG32I: number;
  58209. readonly RGB32I: number;
  58210. readonly RGBA32I: number;
  58211. readonly R32UI: number;
  58212. readonly RG32UI: number;
  58213. readonly RGB32UI: number;
  58214. readonly RGBA32UI: number;
  58215. readonly RGB10_A2UI: number;
  58216. readonly R11F_G11F_B10F: number;
  58217. readonly RGB9_E5: number;
  58218. readonly RGB10_A2: number;
  58219. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58220. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58221. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58222. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58223. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58224. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58225. 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;
  58226. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58227. readonly TRANSFORM_FEEDBACK: number;
  58228. readonly INTERLEAVED_ATTRIBS: number;
  58229. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58230. createTransformFeedback(): WebGLTransformFeedback;
  58231. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58232. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58233. beginTransformFeedback(primitiveMode: number): void;
  58234. endTransformFeedback(): void;
  58235. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58236. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58237. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58238. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58239. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58240. }
  58241. interface ImageBitmap {
  58242. readonly width: number;
  58243. readonly height: number;
  58244. close(): void;
  58245. }
  58246. interface WebGLQuery extends WebGLObject {
  58247. }
  58248. declare var WebGLQuery: {
  58249. prototype: WebGLQuery;
  58250. new(): WebGLQuery;
  58251. };
  58252. interface WebGLSampler extends WebGLObject {
  58253. }
  58254. declare var WebGLSampler: {
  58255. prototype: WebGLSampler;
  58256. new(): WebGLSampler;
  58257. };
  58258. interface WebGLSync extends WebGLObject {
  58259. }
  58260. declare var WebGLSync: {
  58261. prototype: WebGLSync;
  58262. new(): WebGLSync;
  58263. };
  58264. interface WebGLTransformFeedback extends WebGLObject {
  58265. }
  58266. declare var WebGLTransformFeedback: {
  58267. prototype: WebGLTransformFeedback;
  58268. new(): WebGLTransformFeedback;
  58269. };
  58270. interface WebGLVertexArrayObject extends WebGLObject {
  58271. }
  58272. declare var WebGLVertexArrayObject: {
  58273. prototype: WebGLVertexArrayObject;
  58274. new(): WebGLVertexArrayObject;
  58275. };
  58276. // Type definitions for WebVR API
  58277. // Project: https://w3c.github.io/webvr/
  58278. // Definitions by: six a <https://github.com/lostfictions>
  58279. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58280. interface VRDisplay extends EventTarget {
  58281. /**
  58282. * Dictionary of capabilities describing the VRDisplay.
  58283. */
  58284. readonly capabilities: VRDisplayCapabilities;
  58285. /**
  58286. * z-depth defining the far plane of the eye view frustum
  58287. * enables mapping of values in the render target depth
  58288. * attachment to scene coordinates. Initially set to 10000.0.
  58289. */
  58290. depthFar: number;
  58291. /**
  58292. * z-depth defining the near plane of the eye view frustum
  58293. * enables mapping of values in the render target depth
  58294. * attachment to scene coordinates. Initially set to 0.01.
  58295. */
  58296. depthNear: number;
  58297. /**
  58298. * An identifier for this distinct VRDisplay. Used as an
  58299. * association point in the Gamepad API.
  58300. */
  58301. readonly displayId: number;
  58302. /**
  58303. * A display name, a user-readable name identifying it.
  58304. */
  58305. readonly displayName: string;
  58306. readonly isConnected: boolean;
  58307. readonly isPresenting: boolean;
  58308. /**
  58309. * If this VRDisplay supports room-scale experiences, the optional
  58310. * stage attribute contains details on the room-scale parameters.
  58311. */
  58312. readonly stageParameters: VRStageParameters | null;
  58313. /**
  58314. * Passing the value returned by `requestAnimationFrame` to
  58315. * `cancelAnimationFrame` will unregister the callback.
  58316. * @param handle Define the hanle of the request to cancel
  58317. */
  58318. cancelAnimationFrame(handle: number): void;
  58319. /**
  58320. * Stops presenting to the VRDisplay.
  58321. * @returns a promise to know when it stopped
  58322. */
  58323. exitPresent(): Promise<void>;
  58324. /**
  58325. * Return the current VREyeParameters for the given eye.
  58326. * @param whichEye Define the eye we want the parameter for
  58327. * @returns the eye parameters
  58328. */
  58329. getEyeParameters(whichEye: string): VREyeParameters;
  58330. /**
  58331. * Populates the passed VRFrameData with the information required to render
  58332. * the current frame.
  58333. * @param frameData Define the data structure to populate
  58334. * @returns true if ok otherwise false
  58335. */
  58336. getFrameData(frameData: VRFrameData): boolean;
  58337. /**
  58338. * Get the layers currently being presented.
  58339. * @returns the list of VR layers
  58340. */
  58341. getLayers(): VRLayer[];
  58342. /**
  58343. * Return a VRPose containing the future predicted pose of the VRDisplay
  58344. * when the current frame will be presented. The value returned will not
  58345. * change until JavaScript has returned control to the browser.
  58346. *
  58347. * The VRPose will contain the position, orientation, velocity,
  58348. * and acceleration of each of these properties.
  58349. * @returns the pose object
  58350. */
  58351. getPose(): VRPose;
  58352. /**
  58353. * Return the current instantaneous pose of the VRDisplay, with no
  58354. * prediction applied.
  58355. * @returns the current instantaneous pose
  58356. */
  58357. getImmediatePose(): VRPose;
  58358. /**
  58359. * The callback passed to `requestAnimationFrame` will be called
  58360. * any time a new frame should be rendered. When the VRDisplay is
  58361. * presenting the callback will be called at the native refresh
  58362. * rate of the HMD. When not presenting this function acts
  58363. * identically to how window.requestAnimationFrame acts. Content should
  58364. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58365. * asynchronously from other displays and at differing refresh rates.
  58366. * @param callback Define the eaction to run next frame
  58367. * @returns the request handle it
  58368. */
  58369. requestAnimationFrame(callback: FrameRequestCallback): number;
  58370. /**
  58371. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58372. * Repeat calls while already presenting will update the VRLayers being displayed.
  58373. * @param layers Define the list of layer to present
  58374. * @returns a promise to know when the request has been fulfilled
  58375. */
  58376. requestPresent(layers: VRLayer[]): Promise<void>;
  58377. /**
  58378. * Reset the pose for this display, treating its current position and
  58379. * orientation as the "origin/zero" values. VRPose.position,
  58380. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58381. * updated when calling resetPose(). This should be called in only
  58382. * sitting-space experiences.
  58383. */
  58384. resetPose(): void;
  58385. /**
  58386. * The VRLayer provided to the VRDisplay will be captured and presented
  58387. * in the HMD. Calling this function has the same effect on the source
  58388. * canvas as any other operation that uses its source image, and canvases
  58389. * created without preserveDrawingBuffer set to true will be cleared.
  58390. * @param pose Define the pose to submit
  58391. */
  58392. submitFrame(pose?: VRPose): void;
  58393. }
  58394. declare var VRDisplay: {
  58395. prototype: VRDisplay;
  58396. new(): VRDisplay;
  58397. };
  58398. interface VRLayer {
  58399. leftBounds?: number[] | Float32Array | null;
  58400. rightBounds?: number[] | Float32Array | null;
  58401. source?: HTMLCanvasElement | null;
  58402. }
  58403. interface VRDisplayCapabilities {
  58404. readonly canPresent: boolean;
  58405. readonly hasExternalDisplay: boolean;
  58406. readonly hasOrientation: boolean;
  58407. readonly hasPosition: boolean;
  58408. readonly maxLayers: number;
  58409. }
  58410. interface VREyeParameters {
  58411. /** @deprecated */
  58412. readonly fieldOfView: VRFieldOfView;
  58413. readonly offset: Float32Array;
  58414. readonly renderHeight: number;
  58415. readonly renderWidth: number;
  58416. }
  58417. interface VRFieldOfView {
  58418. readonly downDegrees: number;
  58419. readonly leftDegrees: number;
  58420. readonly rightDegrees: number;
  58421. readonly upDegrees: number;
  58422. }
  58423. interface VRFrameData {
  58424. readonly leftProjectionMatrix: Float32Array;
  58425. readonly leftViewMatrix: Float32Array;
  58426. readonly pose: VRPose;
  58427. readonly rightProjectionMatrix: Float32Array;
  58428. readonly rightViewMatrix: Float32Array;
  58429. readonly timestamp: number;
  58430. }
  58431. interface VRPose {
  58432. readonly angularAcceleration: Float32Array | null;
  58433. readonly angularVelocity: Float32Array | null;
  58434. readonly linearAcceleration: Float32Array | null;
  58435. readonly linearVelocity: Float32Array | null;
  58436. readonly orientation: Float32Array | null;
  58437. readonly position: Float32Array | null;
  58438. readonly timestamp: number;
  58439. }
  58440. interface VRStageParameters {
  58441. sittingToStandingTransform?: Float32Array;
  58442. sizeX?: number;
  58443. sizeY?: number;
  58444. }
  58445. interface Navigator {
  58446. getVRDisplays(): Promise<VRDisplay[]>;
  58447. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58448. }
  58449. interface Window {
  58450. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58451. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58452. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58453. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58454. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58455. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58456. }
  58457. interface Gamepad {
  58458. readonly displayId: number;
  58459. }
  58460. interface XRDevice {
  58461. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58462. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58463. }
  58464. interface XRSession {
  58465. getInputSources(): Array<any>;
  58466. baseLayer: XRWebGLLayer;
  58467. requestFrameOfReference(type: string): Promise<void>;
  58468. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58469. end(): Promise<void>;
  58470. requestAnimationFrame: Function;
  58471. addEventListener: Function;
  58472. }
  58473. interface XRSessionCreationOptions {
  58474. outputContext?: WebGLRenderingContext | null;
  58475. immersive?: boolean;
  58476. environmentIntegration?: boolean;
  58477. }
  58478. interface XRLayer {
  58479. getViewport: Function;
  58480. framebufferWidth: number;
  58481. framebufferHeight: number;
  58482. }
  58483. interface XRView {
  58484. projectionMatrix: Float32Array;
  58485. }
  58486. interface XRFrame {
  58487. getDevicePose: Function;
  58488. getInputPose: Function;
  58489. views: Array<XRView>;
  58490. baseLayer: XRLayer;
  58491. }
  58492. interface XRFrameOfReference {
  58493. }
  58494. interface XRWebGLLayer extends XRLayer {
  58495. framebuffer: WebGLFramebuffer;
  58496. }
  58497. declare var XRWebGLLayer: {
  58498. prototype: XRWebGLLayer;
  58499. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58500. };
  58501. declare module "babylonjs" {
  58502. export * from "babylonjs/Legacy/legacy";
  58503. }
  58504. declare module BABYLON {
  58505. /** Alias type for value that can be null */
  58506. export type Nullable<T> = T | null;
  58507. /**
  58508. * Alias type for number that are floats
  58509. * @ignorenaming
  58510. */
  58511. export type float = number;
  58512. /**
  58513. * Alias type for number that are doubles.
  58514. * @ignorenaming
  58515. */
  58516. export type double = number;
  58517. /**
  58518. * Alias type for number that are integer
  58519. * @ignorenaming
  58520. */
  58521. export type int = number;
  58522. /** Alias type for number array or Float32Array */
  58523. export type FloatArray = number[] | Float32Array;
  58524. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58525. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58526. /**
  58527. * Alias for types that can be used by a Buffer or VertexBuffer.
  58528. */
  58529. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58530. /**
  58531. * Alias type for primitive types
  58532. * @ignorenaming
  58533. */
  58534. type Primitive = undefined | null | boolean | string | number | Function;
  58535. /**
  58536. * Type modifier to make all the properties of an object Readonly
  58537. */
  58538. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58539. /**
  58540. * Type modifier to make all the properties of an object Readonly recursively
  58541. */
  58542. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58543. /** @hidden */
  58544. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58545. }
  58546. /** @hidden */
  58547. /** @hidden */
  58548. type DeepImmutableObject<T> = {
  58549. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58550. };
  58551. }
  58552. declare module BABYLON {
  58553. /**
  58554. * Class containing a set of static utilities functions for arrays.
  58555. */
  58556. export class ArrayTools {
  58557. /**
  58558. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58559. * @param size the number of element to construct and put in the array
  58560. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58561. * @returns a new array filled with new objects
  58562. */
  58563. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58564. }
  58565. }
  58566. declare module BABYLON {
  58567. /**
  58568. * Scalar computation library
  58569. */
  58570. export class Scalar {
  58571. /**
  58572. * Two pi constants convenient for computation.
  58573. */
  58574. static TwoPi: number;
  58575. /**
  58576. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58577. * @param a number
  58578. * @param b number
  58579. * @param epsilon (default = 1.401298E-45)
  58580. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58581. */
  58582. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58583. /**
  58584. * Returns a string : the upper case translation of the number i to hexadecimal.
  58585. * @param i number
  58586. * @returns the upper case translation of the number i to hexadecimal.
  58587. */
  58588. static ToHex(i: number): string;
  58589. /**
  58590. * Returns -1 if value is negative and +1 is value is positive.
  58591. * @param value the value
  58592. * @returns the value itself if it's equal to zero.
  58593. */
  58594. static Sign(value: number): number;
  58595. /**
  58596. * Returns the value itself if it's between min and max.
  58597. * Returns min if the value is lower than min.
  58598. * Returns max if the value is greater than max.
  58599. * @param value the value to clmap
  58600. * @param min the min value to clamp to (default: 0)
  58601. * @param max the max value to clamp to (default: 1)
  58602. * @returns the clamped value
  58603. */
  58604. static Clamp(value: number, min?: number, max?: number): number;
  58605. /**
  58606. * the log2 of value.
  58607. * @param value the value to compute log2 of
  58608. * @returns the log2 of value.
  58609. */
  58610. static Log2(value: number): number;
  58611. /**
  58612. * Loops the value, so that it is never larger than length and never smaller than 0.
  58613. *
  58614. * This is similar to the modulo operator but it works with floating point numbers.
  58615. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58616. * With t = 5 and length = 2.5, the result would be 0.0.
  58617. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58618. * @param value the value
  58619. * @param length the length
  58620. * @returns the looped value
  58621. */
  58622. static Repeat(value: number, length: number): number;
  58623. /**
  58624. * Normalize the value between 0.0 and 1.0 using min and max values
  58625. * @param value value to normalize
  58626. * @param min max to normalize between
  58627. * @param max min to normalize between
  58628. * @returns the normalized value
  58629. */
  58630. static Normalize(value: number, min: number, max: number): number;
  58631. /**
  58632. * Denormalize the value from 0.0 and 1.0 using min and max values
  58633. * @param normalized value to denormalize
  58634. * @param min max to denormalize between
  58635. * @param max min to denormalize between
  58636. * @returns the denormalized value
  58637. */
  58638. static Denormalize(normalized: number, min: number, max: number): number;
  58639. /**
  58640. * Calculates the shortest difference between two given angles given in degrees.
  58641. * @param current current angle in degrees
  58642. * @param target target angle in degrees
  58643. * @returns the delta
  58644. */
  58645. static DeltaAngle(current: number, target: number): number;
  58646. /**
  58647. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58648. * @param tx value
  58649. * @param length length
  58650. * @returns The returned value will move back and forth between 0 and length
  58651. */
  58652. static PingPong(tx: number, length: number): number;
  58653. /**
  58654. * Interpolates between min and max with smoothing at the limits.
  58655. *
  58656. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58657. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58658. * @param from from
  58659. * @param to to
  58660. * @param tx value
  58661. * @returns the smooth stepped value
  58662. */
  58663. static SmoothStep(from: number, to: number, tx: number): number;
  58664. /**
  58665. * Moves a value current towards target.
  58666. *
  58667. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58668. * Negative values of maxDelta pushes the value away from target.
  58669. * @param current current value
  58670. * @param target target value
  58671. * @param maxDelta max distance to move
  58672. * @returns resulting value
  58673. */
  58674. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58675. /**
  58676. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58677. *
  58678. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58679. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58680. * @param current current value
  58681. * @param target target value
  58682. * @param maxDelta max distance to move
  58683. * @returns resulting angle
  58684. */
  58685. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58686. /**
  58687. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58688. * @param start start value
  58689. * @param end target value
  58690. * @param amount amount to lerp between
  58691. * @returns the lerped value
  58692. */
  58693. static Lerp(start: number, end: number, amount: number): number;
  58694. /**
  58695. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58696. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58697. * @param start start value
  58698. * @param end target value
  58699. * @param amount amount to lerp between
  58700. * @returns the lerped value
  58701. */
  58702. static LerpAngle(start: number, end: number, amount: number): number;
  58703. /**
  58704. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58705. * @param a start value
  58706. * @param b target value
  58707. * @param value value between a and b
  58708. * @returns the inverseLerp value
  58709. */
  58710. static InverseLerp(a: number, b: number, value: number): number;
  58711. /**
  58712. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58713. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58714. * @param value1 spline value
  58715. * @param tangent1 spline value
  58716. * @param value2 spline value
  58717. * @param tangent2 spline value
  58718. * @param amount input value
  58719. * @returns hermite result
  58720. */
  58721. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58722. /**
  58723. * Returns a random float number between and min and max values
  58724. * @param min min value of random
  58725. * @param max max value of random
  58726. * @returns random value
  58727. */
  58728. static RandomRange(min: number, max: number): number;
  58729. /**
  58730. * This function returns percentage of a number in a given range.
  58731. *
  58732. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58733. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58734. * @param number to convert to percentage
  58735. * @param min min range
  58736. * @param max max range
  58737. * @returns the percentage
  58738. */
  58739. static RangeToPercent(number: number, min: number, max: number): number;
  58740. /**
  58741. * This function returns number that corresponds to the percentage in a given range.
  58742. *
  58743. * PercentToRange(0.34,0,100) will return 34.
  58744. * @param percent to convert to number
  58745. * @param min min range
  58746. * @param max max range
  58747. * @returns the number
  58748. */
  58749. static PercentToRange(percent: number, min: number, max: number): number;
  58750. /**
  58751. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58752. * @param angle The angle to normalize in radian.
  58753. * @return The converted angle.
  58754. */
  58755. static NormalizeRadians(angle: number): number;
  58756. }
  58757. }
  58758. declare module BABYLON {
  58759. /**
  58760. * Constant used to convert a value to gamma space
  58761. * @ignorenaming
  58762. */
  58763. export const ToGammaSpace: number;
  58764. /**
  58765. * Constant used to convert a value to linear space
  58766. * @ignorenaming
  58767. */
  58768. export const ToLinearSpace = 2.2;
  58769. /**
  58770. * Constant used to define the minimal number value in Babylon.js
  58771. * @ignorenaming
  58772. */
  58773. export const Epsilon = 0.001;
  58774. /**
  58775. * Class used to hold a RBG color
  58776. */
  58777. export class Color3 {
  58778. /**
  58779. * Defines the red component (between 0 and 1, default is 0)
  58780. */
  58781. r: number;
  58782. /**
  58783. * Defines the green component (between 0 and 1, default is 0)
  58784. */
  58785. g: number;
  58786. /**
  58787. * Defines the blue component (between 0 and 1, default is 0)
  58788. */
  58789. b: number;
  58790. /**
  58791. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58792. * @param r defines the red component (between 0 and 1, default is 0)
  58793. * @param g defines the green component (between 0 and 1, default is 0)
  58794. * @param b defines the blue component (between 0 and 1, default is 0)
  58795. */
  58796. constructor(
  58797. /**
  58798. * Defines the red component (between 0 and 1, default is 0)
  58799. */
  58800. r?: number,
  58801. /**
  58802. * Defines the green component (between 0 and 1, default is 0)
  58803. */
  58804. g?: number,
  58805. /**
  58806. * Defines the blue component (between 0 and 1, default is 0)
  58807. */
  58808. b?: number);
  58809. /**
  58810. * Creates a string with the Color3 current values
  58811. * @returns the string representation of the Color3 object
  58812. */
  58813. toString(): string;
  58814. /**
  58815. * Returns the string "Color3"
  58816. * @returns "Color3"
  58817. */
  58818. getClassName(): string;
  58819. /**
  58820. * Compute the Color3 hash code
  58821. * @returns an unique number that can be used to hash Color3 objects
  58822. */
  58823. getHashCode(): number;
  58824. /**
  58825. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58826. * @param array defines the array where to store the r,g,b components
  58827. * @param index defines an optional index in the target array to define where to start storing values
  58828. * @returns the current Color3 object
  58829. */
  58830. toArray(array: FloatArray, index?: number): Color3;
  58831. /**
  58832. * Returns a new Color4 object from the current Color3 and the given alpha
  58833. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58834. * @returns a new Color4 object
  58835. */
  58836. toColor4(alpha?: number): Color4;
  58837. /**
  58838. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58839. * @returns the new array
  58840. */
  58841. asArray(): number[];
  58842. /**
  58843. * Returns the luminance value
  58844. * @returns a float value
  58845. */
  58846. toLuminance(): number;
  58847. /**
  58848. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58849. * @param otherColor defines the second operand
  58850. * @returns the new Color3 object
  58851. */
  58852. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58853. /**
  58854. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58855. * @param otherColor defines the second operand
  58856. * @param result defines the Color3 object where to store the result
  58857. * @returns the current Color3
  58858. */
  58859. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58860. /**
  58861. * Determines equality between Color3 objects
  58862. * @param otherColor defines the second operand
  58863. * @returns true if the rgb values are equal to the given ones
  58864. */
  58865. equals(otherColor: DeepImmutable<Color3>): boolean;
  58866. /**
  58867. * Determines equality between the current Color3 object and a set of r,b,g values
  58868. * @param r defines the red component to check
  58869. * @param g defines the green component to check
  58870. * @param b defines the blue component to check
  58871. * @returns true if the rgb values are equal to the given ones
  58872. */
  58873. equalsFloats(r: number, g: number, b: number): boolean;
  58874. /**
  58875. * Multiplies in place each rgb value by scale
  58876. * @param scale defines the scaling factor
  58877. * @returns the updated Color3
  58878. */
  58879. scale(scale: number): Color3;
  58880. /**
  58881. * Multiplies the rgb values by scale and stores the result into "result"
  58882. * @param scale defines the scaling factor
  58883. * @param result defines the Color3 object where to store the result
  58884. * @returns the unmodified current Color3
  58885. */
  58886. scaleToRef(scale: number, result: Color3): Color3;
  58887. /**
  58888. * Scale the current Color3 values by a factor and add the result to a given Color3
  58889. * @param scale defines the scale factor
  58890. * @param result defines color to store the result into
  58891. * @returns the unmodified current Color3
  58892. */
  58893. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58894. /**
  58895. * Clamps the rgb values by the min and max values and stores the result into "result"
  58896. * @param min defines minimum clamping value (default is 0)
  58897. * @param max defines maximum clamping value (default is 1)
  58898. * @param result defines color to store the result into
  58899. * @returns the original Color3
  58900. */
  58901. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58902. /**
  58903. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58904. * @param otherColor defines the second operand
  58905. * @returns the new Color3
  58906. */
  58907. add(otherColor: DeepImmutable<Color3>): Color3;
  58908. /**
  58909. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58910. * @param otherColor defines the second operand
  58911. * @param result defines Color3 object to store the result into
  58912. * @returns the unmodified current Color3
  58913. */
  58914. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58915. /**
  58916. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58917. * @param otherColor defines the second operand
  58918. * @returns the new Color3
  58919. */
  58920. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58921. /**
  58922. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58923. * @param otherColor defines the second operand
  58924. * @param result defines Color3 object to store the result into
  58925. * @returns the unmodified current Color3
  58926. */
  58927. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58928. /**
  58929. * Copy the current object
  58930. * @returns a new Color3 copied the current one
  58931. */
  58932. clone(): Color3;
  58933. /**
  58934. * Copies the rgb values from the source in the current Color3
  58935. * @param source defines the source Color3 object
  58936. * @returns the updated Color3 object
  58937. */
  58938. copyFrom(source: DeepImmutable<Color3>): Color3;
  58939. /**
  58940. * Updates the Color3 rgb values from the given floats
  58941. * @param r defines the red component to read from
  58942. * @param g defines the green component to read from
  58943. * @param b defines the blue component to read from
  58944. * @returns the current Color3 object
  58945. */
  58946. copyFromFloats(r: number, g: number, b: number): Color3;
  58947. /**
  58948. * Updates the Color3 rgb values from the given floats
  58949. * @param r defines the red component to read from
  58950. * @param g defines the green component to read from
  58951. * @param b defines the blue component to read from
  58952. * @returns the current Color3 object
  58953. */
  58954. set(r: number, g: number, b: number): Color3;
  58955. /**
  58956. * Compute the Color3 hexadecimal code as a string
  58957. * @returns a string containing the hexadecimal representation of the Color3 object
  58958. */
  58959. toHexString(): string;
  58960. /**
  58961. * Computes a new Color3 converted from the current one to linear space
  58962. * @returns a new Color3 object
  58963. */
  58964. toLinearSpace(): Color3;
  58965. /**
  58966. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58967. * @param convertedColor defines the Color3 object where to store the linear space version
  58968. * @returns the unmodified Color3
  58969. */
  58970. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58971. /**
  58972. * Computes a new Color3 converted from the current one to gamma space
  58973. * @returns a new Color3 object
  58974. */
  58975. toGammaSpace(): Color3;
  58976. /**
  58977. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58978. * @param convertedColor defines the Color3 object where to store the gamma space version
  58979. * @returns the unmodified Color3
  58980. */
  58981. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58982. private static _BlackReadOnly;
  58983. /**
  58984. * Creates a new Color3 from the string containing valid hexadecimal values
  58985. * @param hex defines a string containing valid hexadecimal values
  58986. * @returns a new Color3 object
  58987. */
  58988. static FromHexString(hex: string): Color3;
  58989. /**
  58990. * Creates a new Vector3 from the starting index of the given array
  58991. * @param array defines the source array
  58992. * @param offset defines an offset in the source array
  58993. * @returns a new Color3 object
  58994. */
  58995. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58996. /**
  58997. * Creates a new Color3 from integer values (< 256)
  58998. * @param r defines the red component to read from (value between 0 and 255)
  58999. * @param g defines the green component to read from (value between 0 and 255)
  59000. * @param b defines the blue component to read from (value between 0 and 255)
  59001. * @returns a new Color3 object
  59002. */
  59003. static FromInts(r: number, g: number, b: number): Color3;
  59004. /**
  59005. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59006. * @param start defines the start Color3 value
  59007. * @param end defines the end Color3 value
  59008. * @param amount defines the gradient value between start and end
  59009. * @returns a new Color3 object
  59010. */
  59011. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59012. /**
  59013. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59014. * @param left defines the start value
  59015. * @param right defines the end value
  59016. * @param amount defines the gradient factor
  59017. * @param result defines the Color3 object where to store the result
  59018. */
  59019. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59020. /**
  59021. * Returns a Color3 value containing a red color
  59022. * @returns a new Color3 object
  59023. */
  59024. static Red(): Color3;
  59025. /**
  59026. * Returns a Color3 value containing a green color
  59027. * @returns a new Color3 object
  59028. */
  59029. static Green(): Color3;
  59030. /**
  59031. * Returns a Color3 value containing a blue color
  59032. * @returns a new Color3 object
  59033. */
  59034. static Blue(): Color3;
  59035. /**
  59036. * Returns a Color3 value containing a black color
  59037. * @returns a new Color3 object
  59038. */
  59039. static Black(): Color3;
  59040. /**
  59041. * Gets a Color3 value containing a black color that must not be updated
  59042. */
  59043. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59044. /**
  59045. * Returns a Color3 value containing a white color
  59046. * @returns a new Color3 object
  59047. */
  59048. static White(): Color3;
  59049. /**
  59050. * Returns a Color3 value containing a purple color
  59051. * @returns a new Color3 object
  59052. */
  59053. static Purple(): Color3;
  59054. /**
  59055. * Returns a Color3 value containing a magenta color
  59056. * @returns a new Color3 object
  59057. */
  59058. static Magenta(): Color3;
  59059. /**
  59060. * Returns a Color3 value containing a yellow color
  59061. * @returns a new Color3 object
  59062. */
  59063. static Yellow(): Color3;
  59064. /**
  59065. * Returns a Color3 value containing a gray color
  59066. * @returns a new Color3 object
  59067. */
  59068. static Gray(): Color3;
  59069. /**
  59070. * Returns a Color3 value containing a teal color
  59071. * @returns a new Color3 object
  59072. */
  59073. static Teal(): Color3;
  59074. /**
  59075. * Returns a Color3 value containing a random color
  59076. * @returns a new Color3 object
  59077. */
  59078. static Random(): Color3;
  59079. }
  59080. /**
  59081. * Class used to hold a RBGA color
  59082. */
  59083. export class Color4 {
  59084. /**
  59085. * Defines the red component (between 0 and 1, default is 0)
  59086. */
  59087. r: number;
  59088. /**
  59089. * Defines the green component (between 0 and 1, default is 0)
  59090. */
  59091. g: number;
  59092. /**
  59093. * Defines the blue component (between 0 and 1, default is 0)
  59094. */
  59095. b: number;
  59096. /**
  59097. * Defines the alpha component (between 0 and 1, default is 1)
  59098. */
  59099. a: number;
  59100. /**
  59101. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59102. * @param r defines the red component (between 0 and 1, default is 0)
  59103. * @param g defines the green component (between 0 and 1, default is 0)
  59104. * @param b defines the blue component (between 0 and 1, default is 0)
  59105. * @param a defines the alpha component (between 0 and 1, default is 1)
  59106. */
  59107. constructor(
  59108. /**
  59109. * Defines the red component (between 0 and 1, default is 0)
  59110. */
  59111. r?: number,
  59112. /**
  59113. * Defines the green component (between 0 and 1, default is 0)
  59114. */
  59115. g?: number,
  59116. /**
  59117. * Defines the blue component (between 0 and 1, default is 0)
  59118. */
  59119. b?: number,
  59120. /**
  59121. * Defines the alpha component (between 0 and 1, default is 1)
  59122. */
  59123. a?: number);
  59124. /**
  59125. * Adds in place the given Color4 values to the current Color4 object
  59126. * @param right defines the second operand
  59127. * @returns the current updated Color4 object
  59128. */
  59129. addInPlace(right: DeepImmutable<Color4>): Color4;
  59130. /**
  59131. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59132. * @returns the new array
  59133. */
  59134. asArray(): number[];
  59135. /**
  59136. * Stores from the starting index in the given array the Color4 successive values
  59137. * @param array defines the array where to store the r,g,b components
  59138. * @param index defines an optional index in the target array to define where to start storing values
  59139. * @returns the current Color4 object
  59140. */
  59141. toArray(array: number[], index?: number): Color4;
  59142. /**
  59143. * Determines equality between Color4 objects
  59144. * @param otherColor defines the second operand
  59145. * @returns true if the rgba values are equal to the given ones
  59146. */
  59147. equals(otherColor: DeepImmutable<Color4>): boolean;
  59148. /**
  59149. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59150. * @param right defines the second operand
  59151. * @returns a new Color4 object
  59152. */
  59153. add(right: DeepImmutable<Color4>): Color4;
  59154. /**
  59155. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59156. * @param right defines the second operand
  59157. * @returns a new Color4 object
  59158. */
  59159. subtract(right: DeepImmutable<Color4>): Color4;
  59160. /**
  59161. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59162. * @param right defines the second operand
  59163. * @param result defines the Color4 object where to store the result
  59164. * @returns the current Color4 object
  59165. */
  59166. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59167. /**
  59168. * Creates a new Color4 with the current Color4 values multiplied by scale
  59169. * @param scale defines the scaling factor to apply
  59170. * @returns a new Color4 object
  59171. */
  59172. scale(scale: number): Color4;
  59173. /**
  59174. * Multiplies the current Color4 values by scale and stores the result in "result"
  59175. * @param scale defines the scaling factor to apply
  59176. * @param result defines the Color4 object where to store the result
  59177. * @returns the current unmodified Color4
  59178. */
  59179. scaleToRef(scale: number, result: Color4): Color4;
  59180. /**
  59181. * Scale the current Color4 values by a factor and add the result to a given Color4
  59182. * @param scale defines the scale factor
  59183. * @param result defines the Color4 object where to store the result
  59184. * @returns the unmodified current Color4
  59185. */
  59186. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59187. /**
  59188. * Clamps the rgb values by the min and max values and stores the result into "result"
  59189. * @param min defines minimum clamping value (default is 0)
  59190. * @param max defines maximum clamping value (default is 1)
  59191. * @param result defines color to store the result into.
  59192. * @returns the cuurent Color4
  59193. */
  59194. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59195. /**
  59196. * Multipy an Color4 value by another and return a new Color4 object
  59197. * @param color defines the Color4 value to multiply by
  59198. * @returns a new Color4 object
  59199. */
  59200. multiply(color: Color4): Color4;
  59201. /**
  59202. * Multipy a Color4 value by another and push the result in a reference value
  59203. * @param color defines the Color4 value to multiply by
  59204. * @param result defines the Color4 to fill the result in
  59205. * @returns the result Color4
  59206. */
  59207. multiplyToRef(color: Color4, result: Color4): Color4;
  59208. /**
  59209. * Creates a string with the Color4 current values
  59210. * @returns the string representation of the Color4 object
  59211. */
  59212. toString(): string;
  59213. /**
  59214. * Returns the string "Color4"
  59215. * @returns "Color4"
  59216. */
  59217. getClassName(): string;
  59218. /**
  59219. * Compute the Color4 hash code
  59220. * @returns an unique number that can be used to hash Color4 objects
  59221. */
  59222. getHashCode(): number;
  59223. /**
  59224. * Creates a new Color4 copied from the current one
  59225. * @returns a new Color4 object
  59226. */
  59227. clone(): Color4;
  59228. /**
  59229. * Copies the given Color4 values into the current one
  59230. * @param source defines the source Color4 object
  59231. * @returns the current updated Color4 object
  59232. */
  59233. copyFrom(source: Color4): Color4;
  59234. /**
  59235. * Copies the given float values into the current one
  59236. * @param r defines the red component to read from
  59237. * @param g defines the green component to read from
  59238. * @param b defines the blue component to read from
  59239. * @param a defines the alpha component to read from
  59240. * @returns the current updated Color4 object
  59241. */
  59242. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59243. /**
  59244. * Copies the given float values into the current one
  59245. * @param r defines the red component to read from
  59246. * @param g defines the green component to read from
  59247. * @param b defines the blue component to read from
  59248. * @param a defines the alpha component to read from
  59249. * @returns the current updated Color4 object
  59250. */
  59251. set(r: number, g: number, b: number, a: number): Color4;
  59252. /**
  59253. * Compute the Color4 hexadecimal code as a string
  59254. * @returns a string containing the hexadecimal representation of the Color4 object
  59255. */
  59256. toHexString(): string;
  59257. /**
  59258. * Computes a new Color4 converted from the current one to linear space
  59259. * @returns a new Color4 object
  59260. */
  59261. toLinearSpace(): Color4;
  59262. /**
  59263. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59264. * @param convertedColor defines the Color4 object where to store the linear space version
  59265. * @returns the unmodified Color4
  59266. */
  59267. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59268. /**
  59269. * Computes a new Color4 converted from the current one to gamma space
  59270. * @returns a new Color4 object
  59271. */
  59272. toGammaSpace(): Color4;
  59273. /**
  59274. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59275. * @param convertedColor defines the Color4 object where to store the gamma space version
  59276. * @returns the unmodified Color4
  59277. */
  59278. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59279. /**
  59280. * Creates a new Color4 from the string containing valid hexadecimal values
  59281. * @param hex defines a string containing valid hexadecimal values
  59282. * @returns a new Color4 object
  59283. */
  59284. static FromHexString(hex: string): Color4;
  59285. /**
  59286. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59287. * @param left defines the start value
  59288. * @param right defines the end value
  59289. * @param amount defines the gradient factor
  59290. * @returns a new Color4 object
  59291. */
  59292. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59293. /**
  59294. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59295. * @param left defines the start value
  59296. * @param right defines the end value
  59297. * @param amount defines the gradient factor
  59298. * @param result defines the Color4 object where to store data
  59299. */
  59300. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59301. /**
  59302. * Creates a new Color4 from a Color3 and an alpha value
  59303. * @param color3 defines the source Color3 to read from
  59304. * @param alpha defines the alpha component (1.0 by default)
  59305. * @returns a new Color4 object
  59306. */
  59307. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59308. /**
  59309. * Creates a new Color4 from the starting index element of the given array
  59310. * @param array defines the source array to read from
  59311. * @param offset defines the offset in the source array
  59312. * @returns a new Color4 object
  59313. */
  59314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59315. /**
  59316. * Creates a new Color3 from integer values (< 256)
  59317. * @param r defines the red component to read from (value between 0 and 255)
  59318. * @param g defines the green component to read from (value between 0 and 255)
  59319. * @param b defines the blue component to read from (value between 0 and 255)
  59320. * @param a defines the alpha component to read from (value between 0 and 255)
  59321. * @returns a new Color3 object
  59322. */
  59323. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59324. /**
  59325. * Check the content of a given array and convert it to an array containing RGBA data
  59326. * If the original array was already containing count * 4 values then it is returned directly
  59327. * @param colors defines the array to check
  59328. * @param count defines the number of RGBA data to expect
  59329. * @returns an array containing count * 4 values (RGBA)
  59330. */
  59331. static CheckColors4(colors: number[], count: number): number[];
  59332. }
  59333. /**
  59334. * Class representing a vector containing 2 coordinates
  59335. */
  59336. export class Vector2 {
  59337. /** defines the first coordinate */
  59338. x: number;
  59339. /** defines the second coordinate */
  59340. y: number;
  59341. /**
  59342. * Creates a new Vector2 from the given x and y coordinates
  59343. * @param x defines the first coordinate
  59344. * @param y defines the second coordinate
  59345. */
  59346. constructor(
  59347. /** defines the first coordinate */
  59348. x?: number,
  59349. /** defines the second coordinate */
  59350. y?: number);
  59351. /**
  59352. * Gets a string with the Vector2 coordinates
  59353. * @returns a string with the Vector2 coordinates
  59354. */
  59355. toString(): string;
  59356. /**
  59357. * Gets class name
  59358. * @returns the string "Vector2"
  59359. */
  59360. getClassName(): string;
  59361. /**
  59362. * Gets current vector hash code
  59363. * @returns the Vector2 hash code as a number
  59364. */
  59365. getHashCode(): number;
  59366. /**
  59367. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59368. * @param array defines the source array
  59369. * @param index defines the offset in source array
  59370. * @returns the current Vector2
  59371. */
  59372. toArray(array: FloatArray, index?: number): Vector2;
  59373. /**
  59374. * Copy the current vector to an array
  59375. * @returns a new array with 2 elements: the Vector2 coordinates.
  59376. */
  59377. asArray(): number[];
  59378. /**
  59379. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59380. * @param source defines the source Vector2
  59381. * @returns the current updated Vector2
  59382. */
  59383. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59384. /**
  59385. * Sets the Vector2 coordinates with the given floats
  59386. * @param x defines the first coordinate
  59387. * @param y defines the second coordinate
  59388. * @returns the current updated Vector2
  59389. */
  59390. copyFromFloats(x: number, y: number): Vector2;
  59391. /**
  59392. * Sets the Vector2 coordinates with the given floats
  59393. * @param x defines the first coordinate
  59394. * @param y defines the second coordinate
  59395. * @returns the current updated Vector2
  59396. */
  59397. set(x: number, y: number): Vector2;
  59398. /**
  59399. * Add another vector with the current one
  59400. * @param otherVector defines the other vector
  59401. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59402. */
  59403. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59404. /**
  59405. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59406. * @param otherVector defines the other vector
  59407. * @param result defines the target vector
  59408. * @returns the unmodified current Vector2
  59409. */
  59410. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59411. /**
  59412. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59413. * @param otherVector defines the other vector
  59414. * @returns the current updated Vector2
  59415. */
  59416. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59417. /**
  59418. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59419. * @param otherVector defines the other vector
  59420. * @returns a new Vector2
  59421. */
  59422. addVector3(otherVector: Vector3): Vector2;
  59423. /**
  59424. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59425. * @param otherVector defines the other vector
  59426. * @returns a new Vector2
  59427. */
  59428. subtract(otherVector: Vector2): Vector2;
  59429. /**
  59430. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59431. * @param otherVector defines the other vector
  59432. * @param result defines the target vector
  59433. * @returns the unmodified current Vector2
  59434. */
  59435. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59436. /**
  59437. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59438. * @param otherVector defines the other vector
  59439. * @returns the current updated Vector2
  59440. */
  59441. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59442. /**
  59443. * Multiplies in place the current Vector2 coordinates by the given ones
  59444. * @param otherVector defines the other vector
  59445. * @returns the current updated Vector2
  59446. */
  59447. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59448. /**
  59449. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59450. * @param otherVector defines the other vector
  59451. * @returns a new Vector2
  59452. */
  59453. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59454. /**
  59455. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59456. * @param otherVector defines the other vector
  59457. * @param result defines the target vector
  59458. * @returns the unmodified current Vector2
  59459. */
  59460. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59461. /**
  59462. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59463. * @param x defines the first coordinate
  59464. * @param y defines the second coordinate
  59465. * @returns a new Vector2
  59466. */
  59467. multiplyByFloats(x: number, y: number): Vector2;
  59468. /**
  59469. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59470. * @param otherVector defines the other vector
  59471. * @returns a new Vector2
  59472. */
  59473. divide(otherVector: Vector2): Vector2;
  59474. /**
  59475. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59476. * @param otherVector defines the other vector
  59477. * @param result defines the target vector
  59478. * @returns the unmodified current Vector2
  59479. */
  59480. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59481. /**
  59482. * Divides the current Vector2 coordinates by the given ones
  59483. * @param otherVector defines the other vector
  59484. * @returns the current updated Vector2
  59485. */
  59486. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59487. /**
  59488. * Gets a new Vector2 with current Vector2 negated coordinates
  59489. * @returns a new Vector2
  59490. */
  59491. negate(): Vector2;
  59492. /**
  59493. * Multiply the Vector2 coordinates by scale
  59494. * @param scale defines the scaling factor
  59495. * @returns the current updated Vector2
  59496. */
  59497. scaleInPlace(scale: number): Vector2;
  59498. /**
  59499. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59500. * @param scale defines the scaling factor
  59501. * @returns a new Vector2
  59502. */
  59503. scale(scale: number): Vector2;
  59504. /**
  59505. * Scale the current Vector2 values by a factor to a given Vector2
  59506. * @param scale defines the scale factor
  59507. * @param result defines the Vector2 object where to store the result
  59508. * @returns the unmodified current Vector2
  59509. */
  59510. scaleToRef(scale: number, result: Vector2): Vector2;
  59511. /**
  59512. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59513. * @param scale defines the scale factor
  59514. * @param result defines the Vector2 object where to store the result
  59515. * @returns the unmodified current Vector2
  59516. */
  59517. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59518. /**
  59519. * Gets a boolean if two vectors are equals
  59520. * @param otherVector defines the other vector
  59521. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59522. */
  59523. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59524. /**
  59525. * Gets a boolean if two vectors are equals (using an epsilon value)
  59526. * @param otherVector defines the other vector
  59527. * @param epsilon defines the minimal distance to consider equality
  59528. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59529. */
  59530. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59531. /**
  59532. * Gets a new Vector2 from current Vector2 floored values
  59533. * @returns a new Vector2
  59534. */
  59535. floor(): Vector2;
  59536. /**
  59537. * Gets a new Vector2 from current Vector2 floored values
  59538. * @returns a new Vector2
  59539. */
  59540. fract(): Vector2;
  59541. /**
  59542. * Gets the length of the vector
  59543. * @returns the vector length (float)
  59544. */
  59545. length(): number;
  59546. /**
  59547. * Gets the vector squared length
  59548. * @returns the vector squared length (float)
  59549. */
  59550. lengthSquared(): number;
  59551. /**
  59552. * Normalize the vector
  59553. * @returns the current updated Vector2
  59554. */
  59555. normalize(): Vector2;
  59556. /**
  59557. * Gets a new Vector2 copied from the Vector2
  59558. * @returns a new Vector2
  59559. */
  59560. clone(): Vector2;
  59561. /**
  59562. * Gets a new Vector2(0, 0)
  59563. * @returns a new Vector2
  59564. */
  59565. static Zero(): Vector2;
  59566. /**
  59567. * Gets a new Vector2(1, 1)
  59568. * @returns a new Vector2
  59569. */
  59570. static One(): Vector2;
  59571. /**
  59572. * Gets a new Vector2 set from the given index element of the given array
  59573. * @param array defines the data source
  59574. * @param offset defines the offset in the data source
  59575. * @returns a new Vector2
  59576. */
  59577. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59578. /**
  59579. * Sets "result" from the given index element of the given array
  59580. * @param array defines the data source
  59581. * @param offset defines the offset in the data source
  59582. * @param result defines the target vector
  59583. */
  59584. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59585. /**
  59586. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59587. * @param value1 defines 1st point of control
  59588. * @param value2 defines 2nd point of control
  59589. * @param value3 defines 3rd point of control
  59590. * @param value4 defines 4th point of control
  59591. * @param amount defines the interpolation factor
  59592. * @returns a new Vector2
  59593. */
  59594. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59595. /**
  59596. * 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".
  59597. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59598. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59599. * @param value defines the value to clamp
  59600. * @param min defines the lower limit
  59601. * @param max defines the upper limit
  59602. * @returns a new Vector2
  59603. */
  59604. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59605. /**
  59606. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59607. * @param value1 defines the 1st control point
  59608. * @param tangent1 defines the outgoing tangent
  59609. * @param value2 defines the 2nd control point
  59610. * @param tangent2 defines the incoming tangent
  59611. * @param amount defines the interpolation factor
  59612. * @returns a new Vector2
  59613. */
  59614. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59615. /**
  59616. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59617. * @param start defines the start vector
  59618. * @param end defines the end vector
  59619. * @param amount defines the interpolation factor
  59620. * @returns a new Vector2
  59621. */
  59622. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59623. /**
  59624. * Gets the dot product of the vector "left" and the vector "right"
  59625. * @param left defines first vector
  59626. * @param right defines second vector
  59627. * @returns the dot product (float)
  59628. */
  59629. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59630. /**
  59631. * Returns a new Vector2 equal to the normalized given vector
  59632. * @param vector defines the vector to normalize
  59633. * @returns a new Vector2
  59634. */
  59635. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59636. /**
  59637. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59638. * @param left defines 1st vector
  59639. * @param right defines 2nd vector
  59640. * @returns a new Vector2
  59641. */
  59642. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59643. /**
  59644. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59645. * @param left defines 1st vector
  59646. * @param right defines 2nd vector
  59647. * @returns a new Vector2
  59648. */
  59649. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59650. /**
  59651. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59652. * @param vector defines the vector to transform
  59653. * @param transformation defines the matrix to apply
  59654. * @returns a new Vector2
  59655. */
  59656. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59657. /**
  59658. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59659. * @param vector defines the vector to transform
  59660. * @param transformation defines the matrix to apply
  59661. * @param result defines the target vector
  59662. */
  59663. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59664. /**
  59665. * Determines if a given vector is included in a triangle
  59666. * @param p defines the vector to test
  59667. * @param p0 defines 1st triangle point
  59668. * @param p1 defines 2nd triangle point
  59669. * @param p2 defines 3rd triangle point
  59670. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59671. */
  59672. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59673. /**
  59674. * Gets the distance between the vectors "value1" and "value2"
  59675. * @param value1 defines first vector
  59676. * @param value2 defines second vector
  59677. * @returns the distance between vectors
  59678. */
  59679. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59680. /**
  59681. * Returns the squared distance between the vectors "value1" and "value2"
  59682. * @param value1 defines first vector
  59683. * @param value2 defines second vector
  59684. * @returns the squared distance between vectors
  59685. */
  59686. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59687. /**
  59688. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59689. * @param value1 defines first vector
  59690. * @param value2 defines second vector
  59691. * @returns a new Vector2
  59692. */
  59693. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59694. /**
  59695. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59696. * @param p defines the middle point
  59697. * @param segA defines one point of the segment
  59698. * @param segB defines the other point of the segment
  59699. * @returns the shortest distance
  59700. */
  59701. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59702. }
  59703. /**
  59704. * Classed used to store (x,y,z) vector representation
  59705. * A Vector3 is the main object used in 3D geometry
  59706. * It can represent etiher the coordinates of a point the space, either a direction
  59707. * Reminder: js uses a left handed forward facing system
  59708. */
  59709. export class Vector3 {
  59710. /**
  59711. * Defines the first coordinates (on X axis)
  59712. */
  59713. x: number;
  59714. /**
  59715. * Defines the second coordinates (on Y axis)
  59716. */
  59717. y: number;
  59718. /**
  59719. * Defines the third coordinates (on Z axis)
  59720. */
  59721. z: number;
  59722. private static _UpReadOnly;
  59723. /**
  59724. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59725. * @param x defines the first coordinates (on X axis)
  59726. * @param y defines the second coordinates (on Y axis)
  59727. * @param z defines the third coordinates (on Z axis)
  59728. */
  59729. constructor(
  59730. /**
  59731. * Defines the first coordinates (on X axis)
  59732. */
  59733. x?: number,
  59734. /**
  59735. * Defines the second coordinates (on Y axis)
  59736. */
  59737. y?: number,
  59738. /**
  59739. * Defines the third coordinates (on Z axis)
  59740. */
  59741. z?: number);
  59742. /**
  59743. * Creates a string representation of the Vector3
  59744. * @returns a string with the Vector3 coordinates.
  59745. */
  59746. toString(): string;
  59747. /**
  59748. * Gets the class name
  59749. * @returns the string "Vector3"
  59750. */
  59751. getClassName(): string;
  59752. /**
  59753. * Creates the Vector3 hash code
  59754. * @returns a number which tends to be unique between Vector3 instances
  59755. */
  59756. getHashCode(): number;
  59757. /**
  59758. * Creates an array containing three elements : the coordinates of the Vector3
  59759. * @returns a new array of numbers
  59760. */
  59761. asArray(): number[];
  59762. /**
  59763. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59764. * @param array defines the destination array
  59765. * @param index defines the offset in the destination array
  59766. * @returns the current Vector3
  59767. */
  59768. toArray(array: FloatArray, index?: number): Vector3;
  59769. /**
  59770. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59771. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59772. */
  59773. toQuaternion(): Quaternion;
  59774. /**
  59775. * Adds the given vector to the current Vector3
  59776. * @param otherVector defines the second operand
  59777. * @returns the current updated Vector3
  59778. */
  59779. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59780. /**
  59781. * Adds the given coordinates to the current Vector3
  59782. * @param x defines the x coordinate of the operand
  59783. * @param y defines the y coordinate of the operand
  59784. * @param z defines the z coordinate of the operand
  59785. * @returns the current updated Vector3
  59786. */
  59787. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59788. /**
  59789. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59790. * @param otherVector defines the second operand
  59791. * @returns the resulting Vector3
  59792. */
  59793. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59794. /**
  59795. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59796. * @param otherVector defines the second operand
  59797. * @param result defines the Vector3 object where to store the result
  59798. * @returns the current Vector3
  59799. */
  59800. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59801. /**
  59802. * Subtract the given vector from the current Vector3
  59803. * @param otherVector defines the second operand
  59804. * @returns the current updated Vector3
  59805. */
  59806. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59807. /**
  59808. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59809. * @param otherVector defines the second operand
  59810. * @returns the resulting Vector3
  59811. */
  59812. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59813. /**
  59814. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59815. * @param otherVector defines the second operand
  59816. * @param result defines the Vector3 object where to store the result
  59817. * @returns the current Vector3
  59818. */
  59819. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59820. /**
  59821. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59822. * @param x defines the x coordinate of the operand
  59823. * @param y defines the y coordinate of the operand
  59824. * @param z defines the z coordinate of the operand
  59825. * @returns the resulting Vector3
  59826. */
  59827. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59828. /**
  59829. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59830. * @param x defines the x coordinate of the operand
  59831. * @param y defines the y coordinate of the operand
  59832. * @param z defines the z coordinate of the operand
  59833. * @param result defines the Vector3 object where to store the result
  59834. * @returns the current Vector3
  59835. */
  59836. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59837. /**
  59838. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59839. * @returns a new Vector3
  59840. */
  59841. negate(): Vector3;
  59842. /**
  59843. * Multiplies the Vector3 coordinates by the float "scale"
  59844. * @param scale defines the multiplier factor
  59845. * @returns the current updated Vector3
  59846. */
  59847. scaleInPlace(scale: number): Vector3;
  59848. /**
  59849. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59850. * @param scale defines the multiplier factor
  59851. * @returns a new Vector3
  59852. */
  59853. scale(scale: number): Vector3;
  59854. /**
  59855. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59856. * @param scale defines the multiplier factor
  59857. * @param result defines the Vector3 object where to store the result
  59858. * @returns the current Vector3
  59859. */
  59860. scaleToRef(scale: number, result: Vector3): Vector3;
  59861. /**
  59862. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59863. * @param scale defines the scale factor
  59864. * @param result defines the Vector3 object where to store the result
  59865. * @returns the unmodified current Vector3
  59866. */
  59867. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59868. /**
  59869. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59870. * @param otherVector defines the second operand
  59871. * @returns true if both vectors are equals
  59872. */
  59873. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59874. /**
  59875. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59876. * @param otherVector defines the second operand
  59877. * @param epsilon defines the minimal distance to define values as equals
  59878. * @returns true if both vectors are distant less than epsilon
  59879. */
  59880. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59881. /**
  59882. * Returns true if the current Vector3 coordinates equals the given floats
  59883. * @param x defines the x coordinate of the operand
  59884. * @param y defines the y coordinate of the operand
  59885. * @param z defines the z coordinate of the operand
  59886. * @returns true if both vectors are equals
  59887. */
  59888. equalsToFloats(x: number, y: number, z: number): boolean;
  59889. /**
  59890. * Multiplies the current Vector3 coordinates by the given ones
  59891. * @param otherVector defines the second operand
  59892. * @returns the current updated Vector3
  59893. */
  59894. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59895. /**
  59896. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59897. * @param otherVector defines the second operand
  59898. * @returns the new Vector3
  59899. */
  59900. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59901. /**
  59902. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59903. * @param otherVector defines the second operand
  59904. * @param result defines the Vector3 object where to store the result
  59905. * @returns the current Vector3
  59906. */
  59907. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59908. /**
  59909. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59910. * @param x defines the x coordinate of the operand
  59911. * @param y defines the y coordinate of the operand
  59912. * @param z defines the z coordinate of the operand
  59913. * @returns the new Vector3
  59914. */
  59915. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59916. /**
  59917. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59918. * @param otherVector defines the second operand
  59919. * @returns the new Vector3
  59920. */
  59921. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59922. /**
  59923. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59924. * @param otherVector defines the second operand
  59925. * @param result defines the Vector3 object where to store the result
  59926. * @returns the current Vector3
  59927. */
  59928. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59929. /**
  59930. * Divides the current Vector3 coordinates by the given ones.
  59931. * @param otherVector defines the second operand
  59932. * @returns the current updated Vector3
  59933. */
  59934. divideInPlace(otherVector: Vector3): Vector3;
  59935. /**
  59936. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59937. * @param other defines the second operand
  59938. * @returns the current updated Vector3
  59939. */
  59940. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59941. /**
  59942. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59943. * @param other defines the second operand
  59944. * @returns the current updated Vector3
  59945. */
  59946. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59947. /**
  59948. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59949. * @param x defines the x coordinate of the operand
  59950. * @param y defines the y coordinate of the operand
  59951. * @param z defines the z coordinate of the operand
  59952. * @returns the current updated Vector3
  59953. */
  59954. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59955. /**
  59956. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59957. * @param x defines the x coordinate of the operand
  59958. * @param y defines the y coordinate of the operand
  59959. * @param z defines the z coordinate of the operand
  59960. * @returns the current updated Vector3
  59961. */
  59962. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59963. /**
  59964. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59965. * Check if is non uniform within a certain amount of decimal places to account for this
  59966. * @param epsilon the amount the values can differ
  59967. * @returns if the the vector is non uniform to a certain number of decimal places
  59968. */
  59969. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59970. /**
  59971. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59972. */
  59973. readonly isNonUniform: boolean;
  59974. /**
  59975. * Gets a new Vector3 from current Vector3 floored values
  59976. * @returns a new Vector3
  59977. */
  59978. floor(): Vector3;
  59979. /**
  59980. * Gets a new Vector3 from current Vector3 floored values
  59981. * @returns a new Vector3
  59982. */
  59983. fract(): Vector3;
  59984. /**
  59985. * Gets the length of the Vector3
  59986. * @returns the length of the Vecto3
  59987. */
  59988. length(): number;
  59989. /**
  59990. * Gets the squared length of the Vector3
  59991. * @returns squared length of the Vector3
  59992. */
  59993. lengthSquared(): number;
  59994. /**
  59995. * Normalize the current Vector3.
  59996. * Please note that this is an in place operation.
  59997. * @returns the current updated Vector3
  59998. */
  59999. normalize(): Vector3;
  60000. /**
  60001. * Reorders the x y z properties of the vector in place
  60002. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60003. * @returns the current updated vector
  60004. */
  60005. reorderInPlace(order: string): this;
  60006. /**
  60007. * Rotates the vector around 0,0,0 by a quaternion
  60008. * @param quaternion the rotation quaternion
  60009. * @param result vector to store the result
  60010. * @returns the resulting vector
  60011. */
  60012. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60013. /**
  60014. * Rotates a vector around a given point
  60015. * @param quaternion the rotation quaternion
  60016. * @param point the point to rotate around
  60017. * @param result vector to store the result
  60018. * @returns the resulting vector
  60019. */
  60020. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60021. /**
  60022. * Normalize the current Vector3 with the given input length.
  60023. * Please note that this is an in place operation.
  60024. * @param len the length of the vector
  60025. * @returns the current updated Vector3
  60026. */
  60027. normalizeFromLength(len: number): Vector3;
  60028. /**
  60029. * Normalize the current Vector3 to a new vector
  60030. * @returns the new Vector3
  60031. */
  60032. normalizeToNew(): Vector3;
  60033. /**
  60034. * Normalize the current Vector3 to the reference
  60035. * @param reference define the Vector3 to update
  60036. * @returns the updated Vector3
  60037. */
  60038. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60039. /**
  60040. * Creates a new Vector3 copied from the current Vector3
  60041. * @returns the new Vector3
  60042. */
  60043. clone(): Vector3;
  60044. /**
  60045. * Copies the given vector coordinates to the current Vector3 ones
  60046. * @param source defines the source Vector3
  60047. * @returns the current updated Vector3
  60048. */
  60049. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60050. /**
  60051. * Copies the given floats to the current Vector3 coordinates
  60052. * @param x defines the x coordinate of the operand
  60053. * @param y defines the y coordinate of the operand
  60054. * @param z defines the z coordinate of the operand
  60055. * @returns the current updated Vector3
  60056. */
  60057. copyFromFloats(x: number, y: number, z: number): Vector3;
  60058. /**
  60059. * Copies the given floats to the current Vector3 coordinates
  60060. * @param x defines the x coordinate of the operand
  60061. * @param y defines the y coordinate of the operand
  60062. * @param z defines the z coordinate of the operand
  60063. * @returns the current updated Vector3
  60064. */
  60065. set(x: number, y: number, z: number): Vector3;
  60066. /**
  60067. * Copies the given float to the current Vector3 coordinates
  60068. * @param v defines the x, y and z coordinates of the operand
  60069. * @returns the current updated Vector3
  60070. */
  60071. setAll(v: number): Vector3;
  60072. /**
  60073. * Get the clip factor between two vectors
  60074. * @param vector0 defines the first operand
  60075. * @param vector1 defines the second operand
  60076. * @param axis defines the axis to use
  60077. * @param size defines the size along the axis
  60078. * @returns the clip factor
  60079. */
  60080. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60081. /**
  60082. * Get angle between two vectors
  60083. * @param vector0 angle between vector0 and vector1
  60084. * @param vector1 angle between vector0 and vector1
  60085. * @param normal direction of the normal
  60086. * @return the angle between vector0 and vector1
  60087. */
  60088. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60089. /**
  60090. * Returns a new Vector3 set from the index "offset" of the given array
  60091. * @param array defines the source array
  60092. * @param offset defines the offset in the source array
  60093. * @returns the new Vector3
  60094. */
  60095. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60096. /**
  60097. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60098. * This function is deprecated. Use FromArray instead
  60099. * @param array defines the source array
  60100. * @param offset defines the offset in the source array
  60101. * @returns the new Vector3
  60102. */
  60103. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60104. /**
  60105. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60106. * @param array defines the source array
  60107. * @param offset defines the offset in the source array
  60108. * @param result defines the Vector3 where to store the result
  60109. */
  60110. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60111. /**
  60112. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60113. * This function is deprecated. Use FromArrayToRef instead.
  60114. * @param array defines the source array
  60115. * @param offset defines the offset in the source array
  60116. * @param result defines the Vector3 where to store the result
  60117. */
  60118. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60119. /**
  60120. * Sets the given vector "result" with the given floats.
  60121. * @param x defines the x coordinate of the source
  60122. * @param y defines the y coordinate of the source
  60123. * @param z defines the z coordinate of the source
  60124. * @param result defines the Vector3 where to store the result
  60125. */
  60126. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60127. /**
  60128. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60129. * @returns a new empty Vector3
  60130. */
  60131. static Zero(): Vector3;
  60132. /**
  60133. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60134. * @returns a new unit Vector3
  60135. */
  60136. static One(): Vector3;
  60137. /**
  60138. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60139. * @returns a new up Vector3
  60140. */
  60141. static Up(): Vector3;
  60142. /**
  60143. * Gets a up Vector3 that must not be updated
  60144. */
  60145. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60146. /**
  60147. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60148. * @returns a new down Vector3
  60149. */
  60150. static Down(): Vector3;
  60151. /**
  60152. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60153. * @returns a new forward Vector3
  60154. */
  60155. static Forward(): Vector3;
  60156. /**
  60157. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60158. * @returns a new forward Vector3
  60159. */
  60160. static Backward(): Vector3;
  60161. /**
  60162. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60163. * @returns a new right Vector3
  60164. */
  60165. static Right(): Vector3;
  60166. /**
  60167. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60168. * @returns a new left Vector3
  60169. */
  60170. static Left(): Vector3;
  60171. /**
  60172. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60173. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60174. * @param vector defines the Vector3 to transform
  60175. * @param transformation defines the transformation matrix
  60176. * @returns the transformed Vector3
  60177. */
  60178. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60179. /**
  60180. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60181. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60182. * @param vector defines the Vector3 to transform
  60183. * @param transformation defines the transformation matrix
  60184. * @param result defines the Vector3 where to store the result
  60185. */
  60186. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60187. /**
  60188. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60189. * This method computes tranformed coordinates only, not transformed direction vectors
  60190. * @param x define the x coordinate of the source vector
  60191. * @param y define the y coordinate of the source vector
  60192. * @param z define the z coordinate of the source vector
  60193. * @param transformation defines the transformation matrix
  60194. * @param result defines the Vector3 where to store the result
  60195. */
  60196. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60197. /**
  60198. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60199. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60200. * @param vector defines the Vector3 to transform
  60201. * @param transformation defines the transformation matrix
  60202. * @returns the new Vector3
  60203. */
  60204. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60205. /**
  60206. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60207. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60208. * @param vector defines the Vector3 to transform
  60209. * @param transformation defines the transformation matrix
  60210. * @param result defines the Vector3 where to store the result
  60211. */
  60212. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60213. /**
  60214. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60215. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60216. * @param x define the x coordinate of the source vector
  60217. * @param y define the y coordinate of the source vector
  60218. * @param z define the z coordinate of the source vector
  60219. * @param transformation defines the transformation matrix
  60220. * @param result defines the Vector3 where to store the result
  60221. */
  60222. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60223. /**
  60224. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60225. * @param value1 defines the first control point
  60226. * @param value2 defines the second control point
  60227. * @param value3 defines the third control point
  60228. * @param value4 defines the fourth control point
  60229. * @param amount defines the amount on the spline to use
  60230. * @returns the new Vector3
  60231. */
  60232. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60233. /**
  60234. * 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"
  60235. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60236. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60237. * @param value defines the current value
  60238. * @param min defines the lower range value
  60239. * @param max defines the upper range value
  60240. * @returns the new Vector3
  60241. */
  60242. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60243. /**
  60244. * 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"
  60245. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60246. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60247. * @param value defines the current value
  60248. * @param min defines the lower range value
  60249. * @param max defines the upper range value
  60250. * @param result defines the Vector3 where to store the result
  60251. */
  60252. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60253. /**
  60254. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60255. * @param value1 defines the first control point
  60256. * @param tangent1 defines the first tangent vector
  60257. * @param value2 defines the second control point
  60258. * @param tangent2 defines the second tangent vector
  60259. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60260. * @returns the new Vector3
  60261. */
  60262. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60263. /**
  60264. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60265. * @param start defines the start value
  60266. * @param end defines the end value
  60267. * @param amount max defines amount between both (between 0 and 1)
  60268. * @returns the new Vector3
  60269. */
  60270. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60271. /**
  60272. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60273. * @param start defines the start value
  60274. * @param end defines the end value
  60275. * @param amount max defines amount between both (between 0 and 1)
  60276. * @param result defines the Vector3 where to store the result
  60277. */
  60278. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60279. /**
  60280. * Returns the dot product (float) between the vectors "left" and "right"
  60281. * @param left defines the left operand
  60282. * @param right defines the right operand
  60283. * @returns the dot product
  60284. */
  60285. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60286. /**
  60287. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60288. * The cross product is then orthogonal to both "left" and "right"
  60289. * @param left defines the left operand
  60290. * @param right defines the right operand
  60291. * @returns the cross product
  60292. */
  60293. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60294. /**
  60295. * Sets the given vector "result" with the cross product of "left" and "right"
  60296. * The cross product is then orthogonal to both "left" and "right"
  60297. * @param left defines the left operand
  60298. * @param right defines the right operand
  60299. * @param result defines the Vector3 where to store the result
  60300. */
  60301. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60302. /**
  60303. * Returns a new Vector3 as the normalization of the given vector
  60304. * @param vector defines the Vector3 to normalize
  60305. * @returns the new Vector3
  60306. */
  60307. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60308. /**
  60309. * Sets the given vector "result" with the normalization of the given first vector
  60310. * @param vector defines the Vector3 to normalize
  60311. * @param result defines the Vector3 where to store the result
  60312. */
  60313. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60314. /**
  60315. * Project a Vector3 onto screen space
  60316. * @param vector defines the Vector3 to project
  60317. * @param world defines the world matrix to use
  60318. * @param transform defines the transform (view x projection) matrix to use
  60319. * @param viewport defines the screen viewport to use
  60320. * @returns the new Vector3
  60321. */
  60322. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60323. /** @hidden */
  60324. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60325. /**
  60326. * Unproject from screen space to object space
  60327. * @param source defines the screen space Vector3 to use
  60328. * @param viewportWidth defines the current width of the viewport
  60329. * @param viewportHeight defines the current height of the viewport
  60330. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60331. * @param transform defines the transform (view x projection) matrix to use
  60332. * @returns the new Vector3
  60333. */
  60334. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60335. /**
  60336. * Unproject from screen space to object space
  60337. * @param source defines the screen space Vector3 to use
  60338. * @param viewportWidth defines the current width of the viewport
  60339. * @param viewportHeight defines the current height of the viewport
  60340. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60341. * @param view defines the view matrix to use
  60342. * @param projection defines the projection matrix to use
  60343. * @returns the new Vector3
  60344. */
  60345. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60346. /**
  60347. * Unproject from screen space to object space
  60348. * @param source defines the screen space Vector3 to use
  60349. * @param viewportWidth defines the current width of the viewport
  60350. * @param viewportHeight defines the current height of the viewport
  60351. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60352. * @param view defines the view matrix to use
  60353. * @param projection defines the projection matrix to use
  60354. * @param result defines the Vector3 where to store the result
  60355. */
  60356. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60357. /**
  60358. * Unproject from screen space to object space
  60359. * @param sourceX defines the screen space x coordinate to use
  60360. * @param sourceY defines the screen space y coordinate to use
  60361. * @param sourceZ defines the screen space z coordinate to use
  60362. * @param viewportWidth defines the current width of the viewport
  60363. * @param viewportHeight defines the current height of the viewport
  60364. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60365. * @param view defines the view matrix to use
  60366. * @param projection defines the projection matrix to use
  60367. * @param result defines the Vector3 where to store the result
  60368. */
  60369. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60370. /**
  60371. * Gets the minimal coordinate values between two Vector3
  60372. * @param left defines the first operand
  60373. * @param right defines the second operand
  60374. * @returns the new Vector3
  60375. */
  60376. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60377. /**
  60378. * Gets the maximal coordinate values between two Vector3
  60379. * @param left defines the first operand
  60380. * @param right defines the second operand
  60381. * @returns the new Vector3
  60382. */
  60383. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60384. /**
  60385. * Returns the distance between the vectors "value1" and "value2"
  60386. * @param value1 defines the first operand
  60387. * @param value2 defines the second operand
  60388. * @returns the distance
  60389. */
  60390. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60391. /**
  60392. * Returns the squared distance between the vectors "value1" and "value2"
  60393. * @param value1 defines the first operand
  60394. * @param value2 defines the second operand
  60395. * @returns the squared distance
  60396. */
  60397. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60398. /**
  60399. * Returns a new Vector3 located at the center between "value1" and "value2"
  60400. * @param value1 defines the first operand
  60401. * @param value2 defines the second operand
  60402. * @returns the new Vector3
  60403. */
  60404. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60405. /**
  60406. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60407. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60408. * to something in order to rotate it from its local system to the given target system
  60409. * Note: axis1, axis2 and axis3 are normalized during this operation
  60410. * @param axis1 defines the first axis
  60411. * @param axis2 defines the second axis
  60412. * @param axis3 defines the third axis
  60413. * @returns a new Vector3
  60414. */
  60415. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60416. /**
  60417. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60418. * @param axis1 defines the first axis
  60419. * @param axis2 defines the second axis
  60420. * @param axis3 defines the third axis
  60421. * @param ref defines the Vector3 where to store the result
  60422. */
  60423. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60424. }
  60425. /**
  60426. * Vector4 class created for EulerAngle class conversion to Quaternion
  60427. */
  60428. export class Vector4 {
  60429. /** x value of the vector */
  60430. x: number;
  60431. /** y value of the vector */
  60432. y: number;
  60433. /** z value of the vector */
  60434. z: number;
  60435. /** w value of the vector */
  60436. w: number;
  60437. /**
  60438. * Creates a Vector4 object from the given floats.
  60439. * @param x x value of the vector
  60440. * @param y y value of the vector
  60441. * @param z z value of the vector
  60442. * @param w w value of the vector
  60443. */
  60444. constructor(
  60445. /** x value of the vector */
  60446. x: number,
  60447. /** y value of the vector */
  60448. y: number,
  60449. /** z value of the vector */
  60450. z: number,
  60451. /** w value of the vector */
  60452. w: number);
  60453. /**
  60454. * Returns the string with the Vector4 coordinates.
  60455. * @returns a string containing all the vector values
  60456. */
  60457. toString(): string;
  60458. /**
  60459. * Returns the string "Vector4".
  60460. * @returns "Vector4"
  60461. */
  60462. getClassName(): string;
  60463. /**
  60464. * Returns the Vector4 hash code.
  60465. * @returns a unique hash code
  60466. */
  60467. getHashCode(): number;
  60468. /**
  60469. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60470. * @returns the resulting array
  60471. */
  60472. asArray(): number[];
  60473. /**
  60474. * Populates the given array from the given index with the Vector4 coordinates.
  60475. * @param array array to populate
  60476. * @param index index of the array to start at (default: 0)
  60477. * @returns the Vector4.
  60478. */
  60479. toArray(array: FloatArray, index?: number): Vector4;
  60480. /**
  60481. * Adds the given vector to the current Vector4.
  60482. * @param otherVector the vector to add
  60483. * @returns the updated Vector4.
  60484. */
  60485. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60486. /**
  60487. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60488. * @param otherVector the vector to add
  60489. * @returns the resulting vector
  60490. */
  60491. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60492. /**
  60493. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60494. * @param otherVector the vector to add
  60495. * @param result the vector to store the result
  60496. * @returns the current Vector4.
  60497. */
  60498. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60499. /**
  60500. * Subtract in place the given vector from the current Vector4.
  60501. * @param otherVector the vector to subtract
  60502. * @returns the updated Vector4.
  60503. */
  60504. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60505. /**
  60506. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60507. * @param otherVector the vector to add
  60508. * @returns the new vector with the result
  60509. */
  60510. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60511. /**
  60512. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60513. * @param otherVector the vector to subtract
  60514. * @param result the vector to store the result
  60515. * @returns the current Vector4.
  60516. */
  60517. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60518. /**
  60519. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60520. */
  60521. /**
  60522. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60523. * @param x value to subtract
  60524. * @param y value to subtract
  60525. * @param z value to subtract
  60526. * @param w value to subtract
  60527. * @returns new vector containing the result
  60528. */
  60529. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60530. /**
  60531. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60532. * @param x value to subtract
  60533. * @param y value to subtract
  60534. * @param z value to subtract
  60535. * @param w value to subtract
  60536. * @param result the vector to store the result in
  60537. * @returns the current Vector4.
  60538. */
  60539. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60540. /**
  60541. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60542. * @returns a new vector with the negated values
  60543. */
  60544. negate(): Vector4;
  60545. /**
  60546. * Multiplies the current Vector4 coordinates by scale (float).
  60547. * @param scale the number to scale with
  60548. * @returns the updated Vector4.
  60549. */
  60550. scaleInPlace(scale: number): Vector4;
  60551. /**
  60552. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60553. * @param scale the number to scale with
  60554. * @returns a new vector with the result
  60555. */
  60556. scale(scale: number): Vector4;
  60557. /**
  60558. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60559. * @param scale the number to scale with
  60560. * @param result a vector to store the result in
  60561. * @returns the current Vector4.
  60562. */
  60563. scaleToRef(scale: number, result: Vector4): Vector4;
  60564. /**
  60565. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60566. * @param scale defines the scale factor
  60567. * @param result defines the Vector4 object where to store the result
  60568. * @returns the unmodified current Vector4
  60569. */
  60570. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60571. /**
  60572. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60573. * @param otherVector the vector to compare against
  60574. * @returns true if they are equal
  60575. */
  60576. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60577. /**
  60578. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60579. * @param otherVector vector to compare against
  60580. * @param epsilon (Default: very small number)
  60581. * @returns true if they are equal
  60582. */
  60583. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60584. /**
  60585. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60586. * @param x x value to compare against
  60587. * @param y y value to compare against
  60588. * @param z z value to compare against
  60589. * @param w w value to compare against
  60590. * @returns true if equal
  60591. */
  60592. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60593. /**
  60594. * Multiplies in place the current Vector4 by the given one.
  60595. * @param otherVector vector to multiple with
  60596. * @returns the updated Vector4.
  60597. */
  60598. multiplyInPlace(otherVector: Vector4): Vector4;
  60599. /**
  60600. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60601. * @param otherVector vector to multiple with
  60602. * @returns resulting new vector
  60603. */
  60604. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60605. /**
  60606. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60607. * @param otherVector vector to multiple with
  60608. * @param result vector to store the result
  60609. * @returns the current Vector4.
  60610. */
  60611. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60612. /**
  60613. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60614. * @param x x value multiply with
  60615. * @param y y value multiply with
  60616. * @param z z value multiply with
  60617. * @param w w value multiply with
  60618. * @returns resulting new vector
  60619. */
  60620. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60621. /**
  60622. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60623. * @param otherVector vector to devide with
  60624. * @returns resulting new vector
  60625. */
  60626. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60627. /**
  60628. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60629. * @param otherVector vector to devide with
  60630. * @param result vector to store the result
  60631. * @returns the current Vector4.
  60632. */
  60633. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60634. /**
  60635. * Divides the current Vector3 coordinates by the given ones.
  60636. * @param otherVector vector to devide with
  60637. * @returns the updated Vector3.
  60638. */
  60639. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60640. /**
  60641. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60642. * @param other defines the second operand
  60643. * @returns the current updated Vector4
  60644. */
  60645. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60646. /**
  60647. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60648. * @param other defines the second operand
  60649. * @returns the current updated Vector4
  60650. */
  60651. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60652. /**
  60653. * Gets a new Vector4 from current Vector4 floored values
  60654. * @returns a new Vector4
  60655. */
  60656. floor(): Vector4;
  60657. /**
  60658. * Gets a new Vector4 from current Vector3 floored values
  60659. * @returns a new Vector4
  60660. */
  60661. fract(): Vector4;
  60662. /**
  60663. * Returns the Vector4 length (float).
  60664. * @returns the length
  60665. */
  60666. length(): number;
  60667. /**
  60668. * Returns the Vector4 squared length (float).
  60669. * @returns the length squared
  60670. */
  60671. lengthSquared(): number;
  60672. /**
  60673. * Normalizes in place the Vector4.
  60674. * @returns the updated Vector4.
  60675. */
  60676. normalize(): Vector4;
  60677. /**
  60678. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60679. * @returns this converted to a new vector3
  60680. */
  60681. toVector3(): Vector3;
  60682. /**
  60683. * Returns a new Vector4 copied from the current one.
  60684. * @returns the new cloned vector
  60685. */
  60686. clone(): Vector4;
  60687. /**
  60688. * Updates the current Vector4 with the given one coordinates.
  60689. * @param source the source vector to copy from
  60690. * @returns the updated Vector4.
  60691. */
  60692. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60693. /**
  60694. * Updates the current Vector4 coordinates with the given floats.
  60695. * @param x float to copy from
  60696. * @param y float to copy from
  60697. * @param z float to copy from
  60698. * @param w float to copy from
  60699. * @returns the updated Vector4.
  60700. */
  60701. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60702. /**
  60703. * Updates the current Vector4 coordinates with the given floats.
  60704. * @param x float to set from
  60705. * @param y float to set from
  60706. * @param z float to set from
  60707. * @param w float to set from
  60708. * @returns the updated Vector4.
  60709. */
  60710. set(x: number, y: number, z: number, w: number): Vector4;
  60711. /**
  60712. * Copies the given float to the current Vector3 coordinates
  60713. * @param v defines the x, y, z and w coordinates of the operand
  60714. * @returns the current updated Vector3
  60715. */
  60716. setAll(v: number): Vector4;
  60717. /**
  60718. * Returns a new Vector4 set from the starting index of the given array.
  60719. * @param array the array to pull values from
  60720. * @param offset the offset into the array to start at
  60721. * @returns the new vector
  60722. */
  60723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60724. /**
  60725. * Updates the given vector "result" from the starting index of the given array.
  60726. * @param array the array to pull values from
  60727. * @param offset the offset into the array to start at
  60728. * @param result the vector to store the result in
  60729. */
  60730. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60731. /**
  60732. * Updates the given vector "result" from the starting index of the given Float32Array.
  60733. * @param array the array to pull values from
  60734. * @param offset the offset into the array to start at
  60735. * @param result the vector to store the result in
  60736. */
  60737. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60738. /**
  60739. * Updates the given vector "result" coordinates from the given floats.
  60740. * @param x float to set from
  60741. * @param y float to set from
  60742. * @param z float to set from
  60743. * @param w float to set from
  60744. * @param result the vector to the floats in
  60745. */
  60746. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60747. /**
  60748. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60749. * @returns the new vector
  60750. */
  60751. static Zero(): Vector4;
  60752. /**
  60753. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60754. * @returns the new vector
  60755. */
  60756. static One(): Vector4;
  60757. /**
  60758. * Returns a new normalized Vector4 from the given one.
  60759. * @param vector the vector to normalize
  60760. * @returns the vector
  60761. */
  60762. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60763. /**
  60764. * Updates the given vector "result" from the normalization of the given one.
  60765. * @param vector the vector to normalize
  60766. * @param result the vector to store the result in
  60767. */
  60768. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60769. /**
  60770. * Returns a vector with the minimum values from the left and right vectors
  60771. * @param left left vector to minimize
  60772. * @param right right vector to minimize
  60773. * @returns a new vector with the minimum of the left and right vector values
  60774. */
  60775. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60776. /**
  60777. * Returns a vector with the maximum values from the left and right vectors
  60778. * @param left left vector to maximize
  60779. * @param right right vector to maximize
  60780. * @returns a new vector with the maximum of the left and right vector values
  60781. */
  60782. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60783. /**
  60784. * Returns the distance (float) between the vectors "value1" and "value2".
  60785. * @param value1 value to calulate the distance between
  60786. * @param value2 value to calulate the distance between
  60787. * @return the distance between the two vectors
  60788. */
  60789. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60790. /**
  60791. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60792. * @param value1 value to calulate the distance between
  60793. * @param value2 value to calulate the distance between
  60794. * @return the distance between the two vectors squared
  60795. */
  60796. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60797. /**
  60798. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60799. * @param value1 value to calulate the center between
  60800. * @param value2 value to calulate the center between
  60801. * @return the center between the two vectors
  60802. */
  60803. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60804. /**
  60805. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60806. * This methods computes transformed normalized direction vectors only.
  60807. * @param vector the vector to transform
  60808. * @param transformation the transformation matrix to apply
  60809. * @returns the new vector
  60810. */
  60811. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60812. /**
  60813. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60814. * This methods computes transformed normalized direction vectors only.
  60815. * @param vector the vector to transform
  60816. * @param transformation the transformation matrix to apply
  60817. * @param result the vector to store the result in
  60818. */
  60819. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60820. /**
  60821. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60822. * This methods computes transformed normalized direction vectors only.
  60823. * @param x value to transform
  60824. * @param y value to transform
  60825. * @param z value to transform
  60826. * @param w value to transform
  60827. * @param transformation the transformation matrix to apply
  60828. * @param result the vector to store the results in
  60829. */
  60830. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60831. /**
  60832. * Creates a new Vector4 from a Vector3
  60833. * @param source defines the source data
  60834. * @param w defines the 4th component (default is 0)
  60835. * @returns a new Vector4
  60836. */
  60837. static FromVector3(source: Vector3, w?: number): Vector4;
  60838. }
  60839. /**
  60840. * Interface for the size containing width and height
  60841. */
  60842. export interface ISize {
  60843. /**
  60844. * Width
  60845. */
  60846. width: number;
  60847. /**
  60848. * Heighht
  60849. */
  60850. height: number;
  60851. }
  60852. /**
  60853. * Size containing widht and height
  60854. */
  60855. export class Size implements ISize {
  60856. /**
  60857. * Width
  60858. */
  60859. width: number;
  60860. /**
  60861. * Height
  60862. */
  60863. height: number;
  60864. /**
  60865. * Creates a Size object from the given width and height (floats).
  60866. * @param width width of the new size
  60867. * @param height height of the new size
  60868. */
  60869. constructor(width: number, height: number);
  60870. /**
  60871. * Returns a string with the Size width and height
  60872. * @returns a string with the Size width and height
  60873. */
  60874. toString(): string;
  60875. /**
  60876. * "Size"
  60877. * @returns the string "Size"
  60878. */
  60879. getClassName(): string;
  60880. /**
  60881. * Returns the Size hash code.
  60882. * @returns a hash code for a unique width and height
  60883. */
  60884. getHashCode(): number;
  60885. /**
  60886. * Updates the current size from the given one.
  60887. * @param src the given size
  60888. */
  60889. copyFrom(src: Size): void;
  60890. /**
  60891. * Updates in place the current Size from the given floats.
  60892. * @param width width of the new size
  60893. * @param height height of the new size
  60894. * @returns the updated Size.
  60895. */
  60896. copyFromFloats(width: number, height: number): Size;
  60897. /**
  60898. * Updates in place the current Size from the given floats.
  60899. * @param width width to set
  60900. * @param height height to set
  60901. * @returns the updated Size.
  60902. */
  60903. set(width: number, height: number): Size;
  60904. /**
  60905. * Multiplies the width and height by numbers
  60906. * @param w factor to multiple the width by
  60907. * @param h factor to multiple the height by
  60908. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60909. */
  60910. multiplyByFloats(w: number, h: number): Size;
  60911. /**
  60912. * Clones the size
  60913. * @returns a new Size copied from the given one.
  60914. */
  60915. clone(): Size;
  60916. /**
  60917. * True if the current Size and the given one width and height are strictly equal.
  60918. * @param other the other size to compare against
  60919. * @returns True if the current Size and the given one width and height are strictly equal.
  60920. */
  60921. equals(other: Size): boolean;
  60922. /**
  60923. * The surface of the Size : width * height (float).
  60924. */
  60925. readonly surface: number;
  60926. /**
  60927. * Create a new size of zero
  60928. * @returns a new Size set to (0.0, 0.0)
  60929. */
  60930. static Zero(): Size;
  60931. /**
  60932. * Sums the width and height of two sizes
  60933. * @param otherSize size to add to this size
  60934. * @returns a new Size set as the addition result of the current Size and the given one.
  60935. */
  60936. add(otherSize: Size): Size;
  60937. /**
  60938. * Subtracts the width and height of two
  60939. * @param otherSize size to subtract to this size
  60940. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60941. */
  60942. subtract(otherSize: Size): Size;
  60943. /**
  60944. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60945. * @param start starting size to lerp between
  60946. * @param end end size to lerp between
  60947. * @param amount amount to lerp between the start and end values
  60948. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60949. */
  60950. static Lerp(start: Size, end: Size, amount: number): Size;
  60951. }
  60952. /**
  60953. * Class used to store quaternion data
  60954. * @see https://en.wikipedia.org/wiki/Quaternion
  60955. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60956. */
  60957. export class Quaternion {
  60958. /** defines the first component (0 by default) */
  60959. x: number;
  60960. /** defines the second component (0 by default) */
  60961. y: number;
  60962. /** defines the third component (0 by default) */
  60963. z: number;
  60964. /** defines the fourth component (1.0 by default) */
  60965. w: number;
  60966. /**
  60967. * Creates a new Quaternion from the given floats
  60968. * @param x defines the first component (0 by default)
  60969. * @param y defines the second component (0 by default)
  60970. * @param z defines the third component (0 by default)
  60971. * @param w defines the fourth component (1.0 by default)
  60972. */
  60973. constructor(
  60974. /** defines the first component (0 by default) */
  60975. x?: number,
  60976. /** defines the second component (0 by default) */
  60977. y?: number,
  60978. /** defines the third component (0 by default) */
  60979. z?: number,
  60980. /** defines the fourth component (1.0 by default) */
  60981. w?: number);
  60982. /**
  60983. * Gets a string representation for the current quaternion
  60984. * @returns a string with the Quaternion coordinates
  60985. */
  60986. toString(): string;
  60987. /**
  60988. * Gets the class name of the quaternion
  60989. * @returns the string "Quaternion"
  60990. */
  60991. getClassName(): string;
  60992. /**
  60993. * Gets a hash code for this quaternion
  60994. * @returns the quaternion hash code
  60995. */
  60996. getHashCode(): number;
  60997. /**
  60998. * Copy the quaternion to an array
  60999. * @returns a new array populated with 4 elements from the quaternion coordinates
  61000. */
  61001. asArray(): number[];
  61002. /**
  61003. * Check if two quaternions are equals
  61004. * @param otherQuaternion defines the second operand
  61005. * @return true if the current quaternion and the given one coordinates are strictly equals
  61006. */
  61007. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61008. /**
  61009. * Clone the current quaternion
  61010. * @returns a new quaternion copied from the current one
  61011. */
  61012. clone(): Quaternion;
  61013. /**
  61014. * Copy a quaternion to the current one
  61015. * @param other defines the other quaternion
  61016. * @returns the updated current quaternion
  61017. */
  61018. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61019. /**
  61020. * Updates the current quaternion with the given float coordinates
  61021. * @param x defines the x coordinate
  61022. * @param y defines the y coordinate
  61023. * @param z defines the z coordinate
  61024. * @param w defines the w coordinate
  61025. * @returns the updated current quaternion
  61026. */
  61027. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61028. /**
  61029. * Updates the current quaternion from the given float coordinates
  61030. * @param x defines the x coordinate
  61031. * @param y defines the y coordinate
  61032. * @param z defines the z coordinate
  61033. * @param w defines the w coordinate
  61034. * @returns the updated current quaternion
  61035. */
  61036. set(x: number, y: number, z: number, w: number): Quaternion;
  61037. /**
  61038. * Adds two quaternions
  61039. * @param other defines the second operand
  61040. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61041. */
  61042. add(other: DeepImmutable<Quaternion>): Quaternion;
  61043. /**
  61044. * Add a quaternion to the current one
  61045. * @param other defines the quaternion to add
  61046. * @returns the current quaternion
  61047. */
  61048. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61049. /**
  61050. * Subtract two quaternions
  61051. * @param other defines the second operand
  61052. * @returns a new quaternion as the subtraction result of the given one from the current one
  61053. */
  61054. subtract(other: Quaternion): Quaternion;
  61055. /**
  61056. * Multiplies the current quaternion by a scale factor
  61057. * @param value defines the scale factor
  61058. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61059. */
  61060. scale(value: number): Quaternion;
  61061. /**
  61062. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61063. * @param scale defines the scale factor
  61064. * @param result defines the Quaternion object where to store the result
  61065. * @returns the unmodified current quaternion
  61066. */
  61067. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61068. /**
  61069. * Multiplies in place the current quaternion by a scale factor
  61070. * @param value defines the scale factor
  61071. * @returns the current modified quaternion
  61072. */
  61073. scaleInPlace(value: number): Quaternion;
  61074. /**
  61075. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61076. * @param scale defines the scale factor
  61077. * @param result defines the Quaternion object where to store the result
  61078. * @returns the unmodified current quaternion
  61079. */
  61080. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61081. /**
  61082. * Multiplies two quaternions
  61083. * @param q1 defines the second operand
  61084. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61085. */
  61086. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61087. /**
  61088. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61089. * @param q1 defines the second operand
  61090. * @param result defines the target quaternion
  61091. * @returns the current quaternion
  61092. */
  61093. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61094. /**
  61095. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61096. * @param q1 defines the second operand
  61097. * @returns the currentupdated quaternion
  61098. */
  61099. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61100. /**
  61101. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61102. * @param ref defines the target quaternion
  61103. * @returns the current quaternion
  61104. */
  61105. conjugateToRef(ref: Quaternion): Quaternion;
  61106. /**
  61107. * Conjugates in place (1-q) the current quaternion
  61108. * @returns the current updated quaternion
  61109. */
  61110. conjugateInPlace(): Quaternion;
  61111. /**
  61112. * Conjugates in place (1-q) the current quaternion
  61113. * @returns a new quaternion
  61114. */
  61115. conjugate(): Quaternion;
  61116. /**
  61117. * Gets length of current quaternion
  61118. * @returns the quaternion length (float)
  61119. */
  61120. length(): number;
  61121. /**
  61122. * Normalize in place the current quaternion
  61123. * @returns the current updated quaternion
  61124. */
  61125. normalize(): Quaternion;
  61126. /**
  61127. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61128. * @param order is a reserved parameter and is ignore for now
  61129. * @returns a new Vector3 containing the Euler angles
  61130. */
  61131. toEulerAngles(order?: string): Vector3;
  61132. /**
  61133. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61134. * @param result defines the vector which will be filled with the Euler angles
  61135. * @param order is a reserved parameter and is ignore for now
  61136. * @returns the current unchanged quaternion
  61137. */
  61138. toEulerAnglesToRef(result: Vector3): Quaternion;
  61139. /**
  61140. * Updates the given rotation matrix with the current quaternion values
  61141. * @param result defines the target matrix
  61142. * @returns the current unchanged quaternion
  61143. */
  61144. toRotationMatrix(result: Matrix): Quaternion;
  61145. /**
  61146. * Updates the current quaternion from the given rotation matrix values
  61147. * @param matrix defines the source matrix
  61148. * @returns the current updated quaternion
  61149. */
  61150. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61151. /**
  61152. * Creates a new quaternion from a rotation matrix
  61153. * @param matrix defines the source matrix
  61154. * @returns a new quaternion created from the given rotation matrix values
  61155. */
  61156. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61157. /**
  61158. * Updates the given quaternion with the given rotation matrix values
  61159. * @param matrix defines the source matrix
  61160. * @param result defines the target quaternion
  61161. */
  61162. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61163. /**
  61164. * Returns the dot product (float) between the quaternions "left" and "right"
  61165. * @param left defines the left operand
  61166. * @param right defines the right operand
  61167. * @returns the dot product
  61168. */
  61169. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61170. /**
  61171. * Checks if the two quaternions are close to each other
  61172. * @param quat0 defines the first quaternion to check
  61173. * @param quat1 defines the second quaternion to check
  61174. * @returns true if the two quaternions are close to each other
  61175. */
  61176. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61177. /**
  61178. * Creates an empty quaternion
  61179. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61180. */
  61181. static Zero(): Quaternion;
  61182. /**
  61183. * Inverse a given quaternion
  61184. * @param q defines the source quaternion
  61185. * @returns a new quaternion as the inverted current quaternion
  61186. */
  61187. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61188. /**
  61189. * Inverse a given quaternion
  61190. * @param q defines the source quaternion
  61191. * @param result the quaternion the result will be stored in
  61192. * @returns the result quaternion
  61193. */
  61194. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61195. /**
  61196. * Creates an identity quaternion
  61197. * @returns the identity quaternion
  61198. */
  61199. static Identity(): Quaternion;
  61200. /**
  61201. * Gets a boolean indicating if the given quaternion is identity
  61202. * @param quaternion defines the quaternion to check
  61203. * @returns true if the quaternion is identity
  61204. */
  61205. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61206. /**
  61207. * Creates a quaternion from a rotation around an axis
  61208. * @param axis defines the axis to use
  61209. * @param angle defines the angle to use
  61210. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61211. */
  61212. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61213. /**
  61214. * Creates a rotation around an axis and stores it into the given quaternion
  61215. * @param axis defines the axis to use
  61216. * @param angle defines the angle to use
  61217. * @param result defines the target quaternion
  61218. * @returns the target quaternion
  61219. */
  61220. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61221. /**
  61222. * Creates a new quaternion from data stored into an array
  61223. * @param array defines the data source
  61224. * @param offset defines the offset in the source array where the data starts
  61225. * @returns a new quaternion
  61226. */
  61227. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61228. /**
  61229. * Create a quaternion from Euler rotation angles
  61230. * @param x Pitch
  61231. * @param y Yaw
  61232. * @param z Roll
  61233. * @returns the new Quaternion
  61234. */
  61235. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61236. /**
  61237. * Updates a quaternion from Euler rotation angles
  61238. * @param x Pitch
  61239. * @param y Yaw
  61240. * @param z Roll
  61241. * @param result the quaternion to store the result
  61242. * @returns the updated quaternion
  61243. */
  61244. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61245. /**
  61246. * Create a quaternion from Euler rotation vector
  61247. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61248. * @returns the new Quaternion
  61249. */
  61250. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61251. /**
  61252. * Updates a quaternion from Euler rotation vector
  61253. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61254. * @param result the quaternion to store the result
  61255. * @returns the updated quaternion
  61256. */
  61257. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61258. /**
  61259. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61260. * @param yaw defines the rotation around Y axis
  61261. * @param pitch defines the rotation around X axis
  61262. * @param roll defines the rotation around Z axis
  61263. * @returns the new quaternion
  61264. */
  61265. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61266. /**
  61267. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61268. * @param yaw defines the rotation around Y axis
  61269. * @param pitch defines the rotation around X axis
  61270. * @param roll defines the rotation around Z axis
  61271. * @param result defines the target quaternion
  61272. */
  61273. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61274. /**
  61275. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61276. * @param alpha defines the rotation around first axis
  61277. * @param beta defines the rotation around second axis
  61278. * @param gamma defines the rotation around third axis
  61279. * @returns the new quaternion
  61280. */
  61281. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61282. /**
  61283. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61284. * @param alpha defines the rotation around first axis
  61285. * @param beta defines the rotation around second axis
  61286. * @param gamma defines the rotation around third axis
  61287. * @param result defines the target quaternion
  61288. */
  61289. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61290. /**
  61291. * 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)
  61292. * @param axis1 defines the first axis
  61293. * @param axis2 defines the second axis
  61294. * @param axis3 defines the third axis
  61295. * @returns the new quaternion
  61296. */
  61297. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61298. /**
  61299. * 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
  61300. * @param axis1 defines the first axis
  61301. * @param axis2 defines the second axis
  61302. * @param axis3 defines the third axis
  61303. * @param ref defines the target quaternion
  61304. */
  61305. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61306. /**
  61307. * Interpolates between two quaternions
  61308. * @param left defines first quaternion
  61309. * @param right defines second quaternion
  61310. * @param amount defines the gradient to use
  61311. * @returns the new interpolated quaternion
  61312. */
  61313. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61314. /**
  61315. * Interpolates between two quaternions and stores it into a target quaternion
  61316. * @param left defines first quaternion
  61317. * @param right defines second quaternion
  61318. * @param amount defines the gradient to use
  61319. * @param result defines the target quaternion
  61320. */
  61321. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61322. /**
  61323. * Interpolate between two quaternions using Hermite interpolation
  61324. * @param value1 defines first quaternion
  61325. * @param tangent1 defines the incoming tangent
  61326. * @param value2 defines second quaternion
  61327. * @param tangent2 defines the outgoing tangent
  61328. * @param amount defines the target quaternion
  61329. * @returns the new interpolated quaternion
  61330. */
  61331. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61332. }
  61333. /**
  61334. * Class used to store matrix data (4x4)
  61335. */
  61336. export class Matrix {
  61337. private static _updateFlagSeed;
  61338. private static _identityReadOnly;
  61339. private _isIdentity;
  61340. private _isIdentityDirty;
  61341. private _isIdentity3x2;
  61342. private _isIdentity3x2Dirty;
  61343. /**
  61344. * Gets the update flag of the matrix which is an unique number for the matrix.
  61345. * It will be incremented every time the matrix data change.
  61346. * You can use it to speed the comparison between two versions of the same matrix.
  61347. */
  61348. updateFlag: number;
  61349. private readonly _m;
  61350. /**
  61351. * Gets the internal data of the matrix
  61352. */
  61353. readonly m: DeepImmutable<Float32Array>;
  61354. /** @hidden */
  61355. _markAsUpdated(): void;
  61356. /** @hidden */
  61357. private _updateIdentityStatus;
  61358. /**
  61359. * Creates an empty matrix (filled with zeros)
  61360. */
  61361. constructor();
  61362. /**
  61363. * Check if the current matrix is identity
  61364. * @returns true is the matrix is the identity matrix
  61365. */
  61366. isIdentity(): boolean;
  61367. /**
  61368. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61369. * @returns true is the matrix is the identity matrix
  61370. */
  61371. isIdentityAs3x2(): boolean;
  61372. /**
  61373. * Gets the determinant of the matrix
  61374. * @returns the matrix determinant
  61375. */
  61376. determinant(): number;
  61377. /**
  61378. * Returns the matrix as a Float32Array
  61379. * @returns the matrix underlying array
  61380. */
  61381. toArray(): DeepImmutable<Float32Array>;
  61382. /**
  61383. * Returns the matrix as a Float32Array
  61384. * @returns the matrix underlying array.
  61385. */
  61386. asArray(): DeepImmutable<Float32Array>;
  61387. /**
  61388. * Inverts the current matrix in place
  61389. * @returns the current inverted matrix
  61390. */
  61391. invert(): Matrix;
  61392. /**
  61393. * Sets all the matrix elements to zero
  61394. * @returns the current matrix
  61395. */
  61396. reset(): Matrix;
  61397. /**
  61398. * Adds the current matrix with a second one
  61399. * @param other defines the matrix to add
  61400. * @returns a new matrix as the addition of the current matrix and the given one
  61401. */
  61402. add(other: DeepImmutable<Matrix>): Matrix;
  61403. /**
  61404. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61405. * @param other defines the matrix to add
  61406. * @param result defines the target matrix
  61407. * @returns the current matrix
  61408. */
  61409. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61410. /**
  61411. * Adds in place the given matrix to the current matrix
  61412. * @param other defines the second operand
  61413. * @returns the current updated matrix
  61414. */
  61415. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61416. /**
  61417. * Sets the given matrix to the current inverted Matrix
  61418. * @param other defines the target matrix
  61419. * @returns the unmodified current matrix
  61420. */
  61421. invertToRef(other: Matrix): Matrix;
  61422. /**
  61423. * add a value at the specified position in the current Matrix
  61424. * @param index the index of the value within the matrix. between 0 and 15.
  61425. * @param value the value to be added
  61426. * @returns the current updated matrix
  61427. */
  61428. addAtIndex(index: number, value: number): Matrix;
  61429. /**
  61430. * mutiply the specified position in the current Matrix by a value
  61431. * @param index the index of the value within the matrix. between 0 and 15.
  61432. * @param value the value to be added
  61433. * @returns the current updated matrix
  61434. */
  61435. multiplyAtIndex(index: number, value: number): Matrix;
  61436. /**
  61437. * Inserts the translation vector (using 3 floats) in the current matrix
  61438. * @param x defines the 1st component of the translation
  61439. * @param y defines the 2nd component of the translation
  61440. * @param z defines the 3rd component of the translation
  61441. * @returns the current updated matrix
  61442. */
  61443. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61444. /**
  61445. * Inserts the translation vector in the current matrix
  61446. * @param vector3 defines the translation to insert
  61447. * @returns the current updated matrix
  61448. */
  61449. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61450. /**
  61451. * Gets the translation value of the current matrix
  61452. * @returns a new Vector3 as the extracted translation from the matrix
  61453. */
  61454. getTranslation(): Vector3;
  61455. /**
  61456. * Fill a Vector3 with the extracted translation from the matrix
  61457. * @param result defines the Vector3 where to store the translation
  61458. * @returns the current matrix
  61459. */
  61460. getTranslationToRef(result: Vector3): Matrix;
  61461. /**
  61462. * Remove rotation and scaling part from the matrix
  61463. * @returns the updated matrix
  61464. */
  61465. removeRotationAndScaling(): Matrix;
  61466. /**
  61467. * Multiply two matrices
  61468. * @param other defines the second operand
  61469. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61470. */
  61471. multiply(other: DeepImmutable<Matrix>): Matrix;
  61472. /**
  61473. * Copy the current matrix from the given one
  61474. * @param other defines the source matrix
  61475. * @returns the current updated matrix
  61476. */
  61477. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61478. /**
  61479. * Populates the given array from the starting index with the current matrix values
  61480. * @param array defines the target array
  61481. * @param offset defines the offset in the target array where to start storing values
  61482. * @returns the current matrix
  61483. */
  61484. copyToArray(array: Float32Array, offset?: number): Matrix;
  61485. /**
  61486. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61487. * @param other defines the second operand
  61488. * @param result defines the matrix where to store the multiplication
  61489. * @returns the current matrix
  61490. */
  61491. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61492. /**
  61493. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61494. * @param other defines the second operand
  61495. * @param result defines the array where to store the multiplication
  61496. * @param offset defines the offset in the target array where to start storing values
  61497. * @returns the current matrix
  61498. */
  61499. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61500. /**
  61501. * Check equality between this matrix and a second one
  61502. * @param value defines the second matrix to compare
  61503. * @returns true is the current matrix and the given one values are strictly equal
  61504. */
  61505. equals(value: DeepImmutable<Matrix>): boolean;
  61506. /**
  61507. * Clone the current matrix
  61508. * @returns a new matrix from the current matrix
  61509. */
  61510. clone(): Matrix;
  61511. /**
  61512. * Returns the name of the current matrix class
  61513. * @returns the string "Matrix"
  61514. */
  61515. getClassName(): string;
  61516. /**
  61517. * Gets the hash code of the current matrix
  61518. * @returns the hash code
  61519. */
  61520. getHashCode(): number;
  61521. /**
  61522. * Decomposes the current Matrix into a translation, rotation and scaling components
  61523. * @param scale defines the scale vector3 given as a reference to update
  61524. * @param rotation defines the rotation quaternion given as a reference to update
  61525. * @param translation defines the translation vector3 given as a reference to update
  61526. * @returns true if operation was successful
  61527. */
  61528. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61529. /**
  61530. * Gets specific row of the matrix
  61531. * @param index defines the number of the row to get
  61532. * @returns the index-th row of the current matrix as a new Vector4
  61533. */
  61534. getRow(index: number): Nullable<Vector4>;
  61535. /**
  61536. * Sets the index-th row of the current matrix to the vector4 values
  61537. * @param index defines the number of the row to set
  61538. * @param row defines the target vector4
  61539. * @returns the updated current matrix
  61540. */
  61541. setRow(index: number, row: Vector4): Matrix;
  61542. /**
  61543. * Compute the transpose of the matrix
  61544. * @returns the new transposed matrix
  61545. */
  61546. transpose(): Matrix;
  61547. /**
  61548. * Compute the transpose of the matrix and store it in a given matrix
  61549. * @param result defines the target matrix
  61550. * @returns the current matrix
  61551. */
  61552. transposeToRef(result: Matrix): Matrix;
  61553. /**
  61554. * Sets the index-th row of the current matrix with the given 4 x float values
  61555. * @param index defines the row index
  61556. * @param x defines the x component to set
  61557. * @param y defines the y component to set
  61558. * @param z defines the z component to set
  61559. * @param w defines the w component to set
  61560. * @returns the updated current matrix
  61561. */
  61562. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61563. /**
  61564. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61565. * @param scale defines the scale factor
  61566. * @returns a new matrix
  61567. */
  61568. scale(scale: number): Matrix;
  61569. /**
  61570. * Scale the current matrix values by a factor to a given result matrix
  61571. * @param scale defines the scale factor
  61572. * @param result defines the matrix to store the result
  61573. * @returns the current matrix
  61574. */
  61575. scaleToRef(scale: number, result: Matrix): Matrix;
  61576. /**
  61577. * Scale the current matrix values by a factor and add the result to a given matrix
  61578. * @param scale defines the scale factor
  61579. * @param result defines the Matrix to store the result
  61580. * @returns the current matrix
  61581. */
  61582. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61583. /**
  61584. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61585. * @param ref matrix to store the result
  61586. */
  61587. toNormalMatrix(ref: Matrix): void;
  61588. /**
  61589. * Gets only rotation part of the current matrix
  61590. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61591. */
  61592. getRotationMatrix(): Matrix;
  61593. /**
  61594. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61595. * @param result defines the target matrix to store data to
  61596. * @returns the current matrix
  61597. */
  61598. getRotationMatrixToRef(result: Matrix): Matrix;
  61599. /**
  61600. * Toggles model matrix from being right handed to left handed in place and vice versa
  61601. */
  61602. toggleModelMatrixHandInPlace(): void;
  61603. /**
  61604. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61605. */
  61606. toggleProjectionMatrixHandInPlace(): void;
  61607. /**
  61608. * Creates a matrix from an array
  61609. * @param array defines the source array
  61610. * @param offset defines an offset in the source array
  61611. * @returns a new Matrix set from the starting index of the given array
  61612. */
  61613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61614. /**
  61615. * Copy the content of an array into a given matrix
  61616. * @param array defines the source array
  61617. * @param offset defines an offset in the source array
  61618. * @param result defines the target matrix
  61619. */
  61620. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61621. /**
  61622. * Stores an array into a matrix after having multiplied each component by a given factor
  61623. * @param array defines the source array
  61624. * @param offset defines the offset in the source array
  61625. * @param scale defines the scaling factor
  61626. * @param result defines the target matrix
  61627. */
  61628. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61629. /**
  61630. * Gets an identity matrix that must not be updated
  61631. */
  61632. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61633. /**
  61634. * Stores a list of values (16) inside a given matrix
  61635. * @param initialM11 defines 1st value of 1st row
  61636. * @param initialM12 defines 2nd value of 1st row
  61637. * @param initialM13 defines 3rd value of 1st row
  61638. * @param initialM14 defines 4th value of 1st row
  61639. * @param initialM21 defines 1st value of 2nd row
  61640. * @param initialM22 defines 2nd value of 2nd row
  61641. * @param initialM23 defines 3rd value of 2nd row
  61642. * @param initialM24 defines 4th value of 2nd row
  61643. * @param initialM31 defines 1st value of 3rd row
  61644. * @param initialM32 defines 2nd value of 3rd row
  61645. * @param initialM33 defines 3rd value of 3rd row
  61646. * @param initialM34 defines 4th value of 3rd row
  61647. * @param initialM41 defines 1st value of 4th row
  61648. * @param initialM42 defines 2nd value of 4th row
  61649. * @param initialM43 defines 3rd value of 4th row
  61650. * @param initialM44 defines 4th value of 4th row
  61651. * @param result defines the target matrix
  61652. */
  61653. 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;
  61654. /**
  61655. * Creates new matrix from a list of values (16)
  61656. * @param initialM11 defines 1st value of 1st row
  61657. * @param initialM12 defines 2nd value of 1st row
  61658. * @param initialM13 defines 3rd value of 1st row
  61659. * @param initialM14 defines 4th value of 1st row
  61660. * @param initialM21 defines 1st value of 2nd row
  61661. * @param initialM22 defines 2nd value of 2nd row
  61662. * @param initialM23 defines 3rd value of 2nd row
  61663. * @param initialM24 defines 4th value of 2nd row
  61664. * @param initialM31 defines 1st value of 3rd row
  61665. * @param initialM32 defines 2nd value of 3rd row
  61666. * @param initialM33 defines 3rd value of 3rd row
  61667. * @param initialM34 defines 4th value of 3rd row
  61668. * @param initialM41 defines 1st value of 4th row
  61669. * @param initialM42 defines 2nd value of 4th row
  61670. * @param initialM43 defines 3rd value of 4th row
  61671. * @param initialM44 defines 4th value of 4th row
  61672. * @returns the new matrix
  61673. */
  61674. 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;
  61675. /**
  61676. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61677. * @param scale defines the scale vector3
  61678. * @param rotation defines the rotation quaternion
  61679. * @param translation defines the translation vector3
  61680. * @returns a new matrix
  61681. */
  61682. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61683. /**
  61684. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61685. * @param scale defines the scale vector3
  61686. * @param rotation defines the rotation quaternion
  61687. * @param translation defines the translation vector3
  61688. * @param result defines the target matrix
  61689. */
  61690. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61691. /**
  61692. * Creates a new identity matrix
  61693. * @returns a new identity matrix
  61694. */
  61695. static Identity(): Matrix;
  61696. /**
  61697. * Creates a new identity matrix and stores the result in a given matrix
  61698. * @param result defines the target matrix
  61699. */
  61700. static IdentityToRef(result: Matrix): void;
  61701. /**
  61702. * Creates a new zero matrix
  61703. * @returns a new zero matrix
  61704. */
  61705. static Zero(): Matrix;
  61706. /**
  61707. * Creates a new rotation matrix for "angle" radians around the X axis
  61708. * @param angle defines the angle (in radians) to use
  61709. * @return the new matrix
  61710. */
  61711. static RotationX(angle: number): Matrix;
  61712. /**
  61713. * Creates a new matrix as the invert of a given matrix
  61714. * @param source defines the source matrix
  61715. * @returns the new matrix
  61716. */
  61717. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61718. /**
  61719. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61720. * @param angle defines the angle (in radians) to use
  61721. * @param result defines the target matrix
  61722. */
  61723. static RotationXToRef(angle: number, result: Matrix): void;
  61724. /**
  61725. * Creates a new rotation matrix for "angle" radians around the Y axis
  61726. * @param angle defines the angle (in radians) to use
  61727. * @return the new matrix
  61728. */
  61729. static RotationY(angle: number): Matrix;
  61730. /**
  61731. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61732. * @param angle defines the angle (in radians) to use
  61733. * @param result defines the target matrix
  61734. */
  61735. static RotationYToRef(angle: number, result: Matrix): void;
  61736. /**
  61737. * Creates a new rotation matrix for "angle" radians around the Z axis
  61738. * @param angle defines the angle (in radians) to use
  61739. * @return the new matrix
  61740. */
  61741. static RotationZ(angle: number): Matrix;
  61742. /**
  61743. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61744. * @param angle defines the angle (in radians) to use
  61745. * @param result defines the target matrix
  61746. */
  61747. static RotationZToRef(angle: number, result: Matrix): void;
  61748. /**
  61749. * Creates a new rotation matrix for "angle" radians around the given axis
  61750. * @param axis defines the axis to use
  61751. * @param angle defines the angle (in radians) to use
  61752. * @return the new matrix
  61753. */
  61754. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61755. /**
  61756. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61757. * @param axis defines the axis to use
  61758. * @param angle defines the angle (in radians) to use
  61759. * @param result defines the target matrix
  61760. */
  61761. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61762. /**
  61763. * Creates a rotation matrix
  61764. * @param yaw defines the yaw angle in radians (Y axis)
  61765. * @param pitch defines the pitch angle in radians (X axis)
  61766. * @param roll defines the roll angle in radians (X axis)
  61767. * @returns the new rotation matrix
  61768. */
  61769. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61770. /**
  61771. * Creates a rotation matrix and stores it in a given matrix
  61772. * @param yaw defines the yaw angle in radians (Y axis)
  61773. * @param pitch defines the pitch angle in radians (X axis)
  61774. * @param roll defines the roll angle in radians (X axis)
  61775. * @param result defines the target matrix
  61776. */
  61777. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61778. /**
  61779. * Creates a scaling matrix
  61780. * @param x defines the scale factor on X axis
  61781. * @param y defines the scale factor on Y axis
  61782. * @param z defines the scale factor on Z axis
  61783. * @returns the new matrix
  61784. */
  61785. static Scaling(x: number, y: number, z: number): Matrix;
  61786. /**
  61787. * Creates a scaling matrix and stores it in a given matrix
  61788. * @param x defines the scale factor on X axis
  61789. * @param y defines the scale factor on Y axis
  61790. * @param z defines the scale factor on Z axis
  61791. * @param result defines the target matrix
  61792. */
  61793. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61794. /**
  61795. * Creates a translation matrix
  61796. * @param x defines the translation on X axis
  61797. * @param y defines the translation on Y axis
  61798. * @param z defines the translationon Z axis
  61799. * @returns the new matrix
  61800. */
  61801. static Translation(x: number, y: number, z: number): Matrix;
  61802. /**
  61803. * Creates a translation matrix and stores it in a given matrix
  61804. * @param x defines the translation on X axis
  61805. * @param y defines the translation on Y axis
  61806. * @param z defines the translationon Z axis
  61807. * @param result defines the target matrix
  61808. */
  61809. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61810. /**
  61811. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61812. * @param startValue defines the start value
  61813. * @param endValue defines the end value
  61814. * @param gradient defines the gradient factor
  61815. * @returns the new matrix
  61816. */
  61817. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61818. /**
  61819. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61820. * @param startValue defines the start value
  61821. * @param endValue defines the end value
  61822. * @param gradient defines the gradient factor
  61823. * @param result defines the Matrix object where to store data
  61824. */
  61825. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61826. /**
  61827. * Builds a new matrix whose values are computed by:
  61828. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61829. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61830. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61831. * @param startValue defines the first matrix
  61832. * @param endValue defines the second matrix
  61833. * @param gradient defines the gradient between the two matrices
  61834. * @returns the new matrix
  61835. */
  61836. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61837. /**
  61838. * Update a matrix to values which are computed by:
  61839. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61840. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61841. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61842. * @param startValue defines the first matrix
  61843. * @param endValue defines the second matrix
  61844. * @param gradient defines the gradient between the two matrices
  61845. * @param result defines the target matrix
  61846. */
  61847. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61848. /**
  61849. * 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"
  61850. * This function works in left handed mode
  61851. * @param eye defines the final position of the entity
  61852. * @param target defines where the entity should look at
  61853. * @param up defines the up vector for the entity
  61854. * @returns the new matrix
  61855. */
  61856. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61857. /**
  61858. * 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".
  61859. * This function works in left handed mode
  61860. * @param eye defines the final position of the entity
  61861. * @param target defines where the entity should look at
  61862. * @param up defines the up vector for the entity
  61863. * @param result defines the target matrix
  61864. */
  61865. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61866. /**
  61867. * 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"
  61868. * This function works in right handed mode
  61869. * @param eye defines the final position of the entity
  61870. * @param target defines where the entity should look at
  61871. * @param up defines the up vector for the entity
  61872. * @returns the new matrix
  61873. */
  61874. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61875. /**
  61876. * 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".
  61877. * This function works in right handed mode
  61878. * @param eye defines the final position of the entity
  61879. * @param target defines where the entity should look at
  61880. * @param up defines the up vector for the entity
  61881. * @param result defines the target matrix
  61882. */
  61883. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61884. /**
  61885. * Create a left-handed orthographic projection matrix
  61886. * @param width defines the viewport width
  61887. * @param height defines the viewport height
  61888. * @param znear defines the near clip plane
  61889. * @param zfar defines the far clip plane
  61890. * @returns a new matrix as a left-handed orthographic projection matrix
  61891. */
  61892. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61893. /**
  61894. * Store a left-handed orthographic projection to a given matrix
  61895. * @param width defines the viewport width
  61896. * @param height defines the viewport height
  61897. * @param znear defines the near clip plane
  61898. * @param zfar defines the far clip plane
  61899. * @param result defines the target matrix
  61900. */
  61901. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61902. /**
  61903. * Create a left-handed orthographic projection matrix
  61904. * @param left defines the viewport left coordinate
  61905. * @param right defines the viewport right coordinate
  61906. * @param bottom defines the viewport bottom coordinate
  61907. * @param top defines the viewport top coordinate
  61908. * @param znear defines the near clip plane
  61909. * @param zfar defines the far clip plane
  61910. * @returns a new matrix as a left-handed orthographic projection matrix
  61911. */
  61912. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61913. /**
  61914. * Stores a left-handed orthographic projection into a given matrix
  61915. * @param left defines the viewport left coordinate
  61916. * @param right defines the viewport right coordinate
  61917. * @param bottom defines the viewport bottom coordinate
  61918. * @param top defines the viewport top coordinate
  61919. * @param znear defines the near clip plane
  61920. * @param zfar defines the far clip plane
  61921. * @param result defines the target matrix
  61922. */
  61923. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61924. /**
  61925. * Creates a right-handed orthographic projection matrix
  61926. * @param left defines the viewport left coordinate
  61927. * @param right defines the viewport right coordinate
  61928. * @param bottom defines the viewport bottom coordinate
  61929. * @param top defines the viewport top coordinate
  61930. * @param znear defines the near clip plane
  61931. * @param zfar defines the far clip plane
  61932. * @returns a new matrix as a right-handed orthographic projection matrix
  61933. */
  61934. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61935. /**
  61936. * Stores a right-handed orthographic projection into a given matrix
  61937. * @param left defines the viewport left coordinate
  61938. * @param right defines the viewport right coordinate
  61939. * @param bottom defines the viewport bottom coordinate
  61940. * @param top defines the viewport top coordinate
  61941. * @param znear defines the near clip plane
  61942. * @param zfar defines the far clip plane
  61943. * @param result defines the target matrix
  61944. */
  61945. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61946. /**
  61947. * Creates a left-handed perspective projection matrix
  61948. * @param width defines the viewport width
  61949. * @param height defines the viewport height
  61950. * @param znear defines the near clip plane
  61951. * @param zfar defines the far clip plane
  61952. * @returns a new matrix as a left-handed perspective projection matrix
  61953. */
  61954. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61955. /**
  61956. * Creates a left-handed perspective projection matrix
  61957. * @param fov defines the horizontal field of view
  61958. * @param aspect defines the aspect ratio
  61959. * @param znear defines the near clip plane
  61960. * @param zfar defines the far clip plane
  61961. * @returns a new matrix as a left-handed perspective projection matrix
  61962. */
  61963. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61964. /**
  61965. * Stores a left-handed perspective projection into a given matrix
  61966. * @param fov defines the horizontal field of view
  61967. * @param aspect defines the aspect ratio
  61968. * @param znear defines the near clip plane
  61969. * @param zfar defines the far clip plane
  61970. * @param result defines the target matrix
  61971. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61972. */
  61973. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61974. /**
  61975. * Creates a right-handed perspective projection matrix
  61976. * @param fov defines the horizontal field of view
  61977. * @param aspect defines the aspect ratio
  61978. * @param znear defines the near clip plane
  61979. * @param zfar defines the far clip plane
  61980. * @returns a new matrix as a right-handed perspective projection matrix
  61981. */
  61982. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61983. /**
  61984. * Stores a right-handed perspective projection into a given matrix
  61985. * @param fov defines the horizontal field of view
  61986. * @param aspect defines the aspect ratio
  61987. * @param znear defines the near clip plane
  61988. * @param zfar defines the far clip plane
  61989. * @param result defines the target matrix
  61990. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61991. */
  61992. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61993. /**
  61994. * Stores a perspective projection for WebVR info a given matrix
  61995. * @param fov defines the field of view
  61996. * @param znear defines the near clip plane
  61997. * @param zfar defines the far clip plane
  61998. * @param result defines the target matrix
  61999. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62000. */
  62001. static PerspectiveFovWebVRToRef(fov: {
  62002. upDegrees: number;
  62003. downDegrees: number;
  62004. leftDegrees: number;
  62005. rightDegrees: number;
  62006. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62007. /**
  62008. * Computes a complete transformation matrix
  62009. * @param viewport defines the viewport to use
  62010. * @param world defines the world matrix
  62011. * @param view defines the view matrix
  62012. * @param projection defines the projection matrix
  62013. * @param zmin defines the near clip plane
  62014. * @param zmax defines the far clip plane
  62015. * @returns the transformation matrix
  62016. */
  62017. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62018. /**
  62019. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62020. * @param matrix defines the matrix to use
  62021. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62022. */
  62023. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62024. /**
  62025. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62026. * @param matrix defines the matrix to use
  62027. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62028. */
  62029. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62030. /**
  62031. * Compute the transpose of a given matrix
  62032. * @param matrix defines the matrix to transpose
  62033. * @returns the new matrix
  62034. */
  62035. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62036. /**
  62037. * Compute the transpose of a matrix and store it in a target matrix
  62038. * @param matrix defines the matrix to transpose
  62039. * @param result defines the target matrix
  62040. */
  62041. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62042. /**
  62043. * Computes a reflection matrix from a plane
  62044. * @param plane defines the reflection plane
  62045. * @returns a new matrix
  62046. */
  62047. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62048. /**
  62049. * Computes a reflection matrix from a plane
  62050. * @param plane defines the reflection plane
  62051. * @param result defines the target matrix
  62052. */
  62053. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62054. /**
  62055. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62056. * @param xaxis defines the value of the 1st axis
  62057. * @param yaxis defines the value of the 2nd axis
  62058. * @param zaxis defines the value of the 3rd axis
  62059. * @param result defines the target matrix
  62060. */
  62061. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62062. /**
  62063. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62064. * @param quat defines the quaternion to use
  62065. * @param result defines the target matrix
  62066. */
  62067. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62068. }
  62069. /**
  62070. * Represens a plane by the equation ax + by + cz + d = 0
  62071. */
  62072. export class Plane {
  62073. /**
  62074. * Normal of the plane (a,b,c)
  62075. */
  62076. normal: Vector3;
  62077. /**
  62078. * d component of the plane
  62079. */
  62080. d: number;
  62081. /**
  62082. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62083. * @param a a component of the plane
  62084. * @param b b component of the plane
  62085. * @param c c component of the plane
  62086. * @param d d component of the plane
  62087. */
  62088. constructor(a: number, b: number, c: number, d: number);
  62089. /**
  62090. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62091. */
  62092. asArray(): number[];
  62093. /**
  62094. * @returns a new plane copied from the current Plane.
  62095. */
  62096. clone(): Plane;
  62097. /**
  62098. * @returns the string "Plane".
  62099. */
  62100. getClassName(): string;
  62101. /**
  62102. * @returns the Plane hash code.
  62103. */
  62104. getHashCode(): number;
  62105. /**
  62106. * Normalize the current Plane in place.
  62107. * @returns the updated Plane.
  62108. */
  62109. normalize(): Plane;
  62110. /**
  62111. * Applies a transformation the plane and returns the result
  62112. * @param transformation the transformation matrix to be applied to the plane
  62113. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62114. */
  62115. transform(transformation: DeepImmutable<Matrix>): Plane;
  62116. /**
  62117. * Calcualtte the dot product between the point and the plane normal
  62118. * @param point point to calculate the dot product with
  62119. * @returns the dot product (float) of the point coordinates and the plane normal.
  62120. */
  62121. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62122. /**
  62123. * Updates the current Plane from the plane defined by the three given points.
  62124. * @param point1 one of the points used to contruct the plane
  62125. * @param point2 one of the points used to contruct the plane
  62126. * @param point3 one of the points used to contruct the plane
  62127. * @returns the updated Plane.
  62128. */
  62129. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62130. /**
  62131. * Checks if the plane is facing a given direction
  62132. * @param direction the direction to check if the plane is facing
  62133. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62134. * @returns True is the vector "direction" is the same side than the plane normal.
  62135. */
  62136. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62137. /**
  62138. * Calculates the distance to a point
  62139. * @param point point to calculate distance to
  62140. * @returns the signed distance (float) from the given point to the Plane.
  62141. */
  62142. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62143. /**
  62144. * Creates a plane from an array
  62145. * @param array the array to create a plane from
  62146. * @returns a new Plane from the given array.
  62147. */
  62148. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62149. /**
  62150. * Creates a plane from three points
  62151. * @param point1 point used to create the plane
  62152. * @param point2 point used to create the plane
  62153. * @param point3 point used to create the plane
  62154. * @returns a new Plane defined by the three given points.
  62155. */
  62156. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62157. /**
  62158. * Creates a plane from an origin point and a normal
  62159. * @param origin origin of the plane to be constructed
  62160. * @param normal normal of the plane to be constructed
  62161. * @returns a new Plane the normal vector to this plane at the given origin point.
  62162. * Note : the vector "normal" is updated because normalized.
  62163. */
  62164. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62165. /**
  62166. * Calculates the distance from a plane and a point
  62167. * @param origin origin of the plane to be constructed
  62168. * @param normal normal of the plane to be constructed
  62169. * @param point point to calculate distance to
  62170. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62171. */
  62172. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62173. }
  62174. /**
  62175. * Class used to represent a viewport on screen
  62176. */
  62177. export class Viewport {
  62178. /** viewport left coordinate */
  62179. x: number;
  62180. /** viewport top coordinate */
  62181. y: number;
  62182. /**viewport width */
  62183. width: number;
  62184. /** viewport height */
  62185. height: number;
  62186. /**
  62187. * Creates a Viewport object located at (x, y) and sized (width, height)
  62188. * @param x defines viewport left coordinate
  62189. * @param y defines viewport top coordinate
  62190. * @param width defines the viewport width
  62191. * @param height defines the viewport height
  62192. */
  62193. constructor(
  62194. /** viewport left coordinate */
  62195. x: number,
  62196. /** viewport top coordinate */
  62197. y: number,
  62198. /**viewport width */
  62199. width: number,
  62200. /** viewport height */
  62201. height: number);
  62202. /**
  62203. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62204. * @param renderWidth defines the rendering width
  62205. * @param renderHeight defines the rendering height
  62206. * @returns a new Viewport
  62207. */
  62208. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62209. /**
  62210. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62211. * @param renderWidth defines the rendering width
  62212. * @param renderHeight defines the rendering height
  62213. * @param ref defines the target viewport
  62214. * @returns the current viewport
  62215. */
  62216. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62217. /**
  62218. * Returns a new Viewport copied from the current one
  62219. * @returns a new Viewport
  62220. */
  62221. clone(): Viewport;
  62222. }
  62223. /**
  62224. * Reprasents a camera frustum
  62225. */
  62226. export class Frustum {
  62227. /**
  62228. * Gets the planes representing the frustum
  62229. * @param transform matrix to be applied to the returned planes
  62230. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62231. */
  62232. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62233. /**
  62234. * Gets the near frustum plane transformed by the transform matrix
  62235. * @param transform transformation matrix to be applied to the resulting frustum plane
  62236. * @param frustumPlane the resuling frustum plane
  62237. */
  62238. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62239. /**
  62240. * Gets the far frustum plane transformed by the transform matrix
  62241. * @param transform transformation matrix to be applied to the resulting frustum plane
  62242. * @param frustumPlane the resuling frustum plane
  62243. */
  62244. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62245. /**
  62246. * Gets the left frustum plane transformed by the transform matrix
  62247. * @param transform transformation matrix to be applied to the resulting frustum plane
  62248. * @param frustumPlane the resuling frustum plane
  62249. */
  62250. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62251. /**
  62252. * Gets the right frustum plane transformed by the transform matrix
  62253. * @param transform transformation matrix to be applied to the resulting frustum plane
  62254. * @param frustumPlane the resuling frustum plane
  62255. */
  62256. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62257. /**
  62258. * Gets the top frustum plane transformed by the transform matrix
  62259. * @param transform transformation matrix to be applied to the resulting frustum plane
  62260. * @param frustumPlane the resuling frustum plane
  62261. */
  62262. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62263. /**
  62264. * Gets the bottom frustum plane transformed by the transform matrix
  62265. * @param transform transformation matrix to be applied to the resulting frustum plane
  62266. * @param frustumPlane the resuling frustum plane
  62267. */
  62268. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62269. /**
  62270. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62271. * @param transform transformation matrix to be applied to the resulting frustum planes
  62272. * @param frustumPlanes the resuling frustum planes
  62273. */
  62274. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62275. }
  62276. /** Defines supported spaces */
  62277. export enum Space {
  62278. /** Local (object) space */
  62279. LOCAL = 0,
  62280. /** World space */
  62281. WORLD = 1,
  62282. /** Bone space */
  62283. BONE = 2
  62284. }
  62285. /** Defines the 3 main axes */
  62286. export class Axis {
  62287. /** X axis */
  62288. static X: Vector3;
  62289. /** Y axis */
  62290. static Y: Vector3;
  62291. /** Z axis */
  62292. static Z: Vector3;
  62293. }
  62294. /** Class used to represent a Bezier curve */
  62295. export class BezierCurve {
  62296. /**
  62297. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62298. * @param t defines the time
  62299. * @param x1 defines the left coordinate on X axis
  62300. * @param y1 defines the left coordinate on Y axis
  62301. * @param x2 defines the right coordinate on X axis
  62302. * @param y2 defines the right coordinate on Y axis
  62303. * @returns the interpolated value
  62304. */
  62305. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62306. }
  62307. /**
  62308. * Defines potential orientation for back face culling
  62309. */
  62310. export enum Orientation {
  62311. /**
  62312. * Clockwise
  62313. */
  62314. CW = 0,
  62315. /** Counter clockwise */
  62316. CCW = 1
  62317. }
  62318. /**
  62319. * Defines angle representation
  62320. */
  62321. export class Angle {
  62322. private _radians;
  62323. /**
  62324. * Creates an Angle object of "radians" radians (float).
  62325. * @param radians the angle in radians
  62326. */
  62327. constructor(radians: number);
  62328. /**
  62329. * Get value in degrees
  62330. * @returns the Angle value in degrees (float)
  62331. */
  62332. degrees(): number;
  62333. /**
  62334. * Get value in radians
  62335. * @returns the Angle value in radians (float)
  62336. */
  62337. radians(): number;
  62338. /**
  62339. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62340. * @param a defines first vector
  62341. * @param b defines second vector
  62342. * @returns a new Angle
  62343. */
  62344. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62345. /**
  62346. * Gets a new Angle object from the given float in radians
  62347. * @param radians defines the angle value in radians
  62348. * @returns a new Angle
  62349. */
  62350. static FromRadians(radians: number): Angle;
  62351. /**
  62352. * Gets a new Angle object from the given float in degrees
  62353. * @param degrees defines the angle value in degrees
  62354. * @returns a new Angle
  62355. */
  62356. static FromDegrees(degrees: number): Angle;
  62357. }
  62358. /**
  62359. * This represents an arc in a 2d space.
  62360. */
  62361. export class Arc2 {
  62362. /** Defines the start point of the arc */
  62363. startPoint: Vector2;
  62364. /** Defines the mid point of the arc */
  62365. midPoint: Vector2;
  62366. /** Defines the end point of the arc */
  62367. endPoint: Vector2;
  62368. /**
  62369. * Defines the center point of the arc.
  62370. */
  62371. centerPoint: Vector2;
  62372. /**
  62373. * Defines the radius of the arc.
  62374. */
  62375. radius: number;
  62376. /**
  62377. * Defines the angle of the arc (from mid point to end point).
  62378. */
  62379. angle: Angle;
  62380. /**
  62381. * Defines the start angle of the arc (from start point to middle point).
  62382. */
  62383. startAngle: Angle;
  62384. /**
  62385. * Defines the orientation of the arc (clock wise/counter clock wise).
  62386. */
  62387. orientation: Orientation;
  62388. /**
  62389. * Creates an Arc object from the three given points : start, middle and end.
  62390. * @param startPoint Defines the start point of the arc
  62391. * @param midPoint Defines the midlle point of the arc
  62392. * @param endPoint Defines the end point of the arc
  62393. */
  62394. constructor(
  62395. /** Defines the start point of the arc */
  62396. startPoint: Vector2,
  62397. /** Defines the mid point of the arc */
  62398. midPoint: Vector2,
  62399. /** Defines the end point of the arc */
  62400. endPoint: Vector2);
  62401. }
  62402. /**
  62403. * Represents a 2D path made up of multiple 2D points
  62404. */
  62405. export class Path2 {
  62406. private _points;
  62407. private _length;
  62408. /**
  62409. * If the path start and end point are the same
  62410. */
  62411. closed: boolean;
  62412. /**
  62413. * Creates a Path2 object from the starting 2D coordinates x and y.
  62414. * @param x the starting points x value
  62415. * @param y the starting points y value
  62416. */
  62417. constructor(x: number, y: number);
  62418. /**
  62419. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62420. * @param x the added points x value
  62421. * @param y the added points y value
  62422. * @returns the updated Path2.
  62423. */
  62424. addLineTo(x: number, y: number): Path2;
  62425. /**
  62426. * 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.
  62427. * @param midX middle point x value
  62428. * @param midY middle point y value
  62429. * @param endX end point x value
  62430. * @param endY end point y value
  62431. * @param numberOfSegments (default: 36)
  62432. * @returns the updated Path2.
  62433. */
  62434. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62435. /**
  62436. * Closes the Path2.
  62437. * @returns the Path2.
  62438. */
  62439. close(): Path2;
  62440. /**
  62441. * Gets the sum of the distance between each sequential point in the path
  62442. * @returns the Path2 total length (float).
  62443. */
  62444. length(): number;
  62445. /**
  62446. * Gets the points which construct the path
  62447. * @returns the Path2 internal array of points.
  62448. */
  62449. getPoints(): Vector2[];
  62450. /**
  62451. * Retreives the point at the distance aways from the starting point
  62452. * @param normalizedLengthPosition the length along the path to retreive the point from
  62453. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62454. */
  62455. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62456. /**
  62457. * Creates a new path starting from an x and y position
  62458. * @param x starting x value
  62459. * @param y starting y value
  62460. * @returns a new Path2 starting at the coordinates (x, y).
  62461. */
  62462. static StartingAt(x: number, y: number): Path2;
  62463. }
  62464. /**
  62465. * Represents a 3D path made up of multiple 3D points
  62466. */
  62467. export class Path3D {
  62468. /**
  62469. * an array of Vector3, the curve axis of the Path3D
  62470. */
  62471. path: Vector3[];
  62472. private _curve;
  62473. private _distances;
  62474. private _tangents;
  62475. private _normals;
  62476. private _binormals;
  62477. private _raw;
  62478. /**
  62479. * new Path3D(path, normal, raw)
  62480. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62481. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62482. * @param path an array of Vector3, the curve axis of the Path3D
  62483. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62484. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62485. */
  62486. constructor(
  62487. /**
  62488. * an array of Vector3, the curve axis of the Path3D
  62489. */
  62490. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62491. /**
  62492. * Returns the Path3D array of successive Vector3 designing its curve.
  62493. * @returns the Path3D array of successive Vector3 designing its curve.
  62494. */
  62495. getCurve(): Vector3[];
  62496. /**
  62497. * Returns an array populated with tangent vectors on each Path3D curve point.
  62498. * @returns an array populated with tangent vectors on each Path3D curve point.
  62499. */
  62500. getTangents(): Vector3[];
  62501. /**
  62502. * Returns an array populated with normal vectors on each Path3D curve point.
  62503. * @returns an array populated with normal vectors on each Path3D curve point.
  62504. */
  62505. getNormals(): Vector3[];
  62506. /**
  62507. * Returns an array populated with binormal vectors on each Path3D curve point.
  62508. * @returns an array populated with binormal vectors on each Path3D curve point.
  62509. */
  62510. getBinormals(): Vector3[];
  62511. /**
  62512. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62513. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62514. */
  62515. getDistances(): number[];
  62516. /**
  62517. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62518. * @param path path which all values are copied into the curves points
  62519. * @param firstNormal which should be projected onto the curve
  62520. * @returns the same object updated.
  62521. */
  62522. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62523. private _compute;
  62524. private _getFirstNonNullVector;
  62525. private _getLastNonNullVector;
  62526. private _normalVector;
  62527. }
  62528. /**
  62529. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62530. * A Curve3 is designed from a series of successive Vector3.
  62531. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62532. */
  62533. export class Curve3 {
  62534. private _points;
  62535. private _length;
  62536. /**
  62537. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62538. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62539. * @param v1 (Vector3) the control point
  62540. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62541. * @param nbPoints (integer) the wanted number of points in the curve
  62542. * @returns the created Curve3
  62543. */
  62544. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62545. /**
  62546. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62547. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62548. * @param v1 (Vector3) the first control point
  62549. * @param v2 (Vector3) the second control point
  62550. * @param v3 (Vector3) the end point of the Cubic Bezier
  62551. * @param nbPoints (integer) the wanted number of points in the curve
  62552. * @returns the created Curve3
  62553. */
  62554. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62555. /**
  62556. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62557. * @param p1 (Vector3) the origin point of the Hermite Spline
  62558. * @param t1 (Vector3) the tangent vector at the origin point
  62559. * @param p2 (Vector3) the end point of the Hermite Spline
  62560. * @param t2 (Vector3) the tangent vector at the end point
  62561. * @param nbPoints (integer) the wanted number of points in the curve
  62562. * @returns the created Curve3
  62563. */
  62564. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62565. /**
  62566. * Returns a Curve3 object along a CatmullRom Spline curve :
  62567. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62568. * @param nbPoints (integer) the wanted number of points between each curve control points
  62569. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62570. * @returns the created Curve3
  62571. */
  62572. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62573. /**
  62574. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62575. * A Curve3 is designed from a series of successive Vector3.
  62576. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62577. * @param points points which make up the curve
  62578. */
  62579. constructor(points: Vector3[]);
  62580. /**
  62581. * @returns the Curve3 stored array of successive Vector3
  62582. */
  62583. getPoints(): Vector3[];
  62584. /**
  62585. * @returns the computed length (float) of the curve.
  62586. */
  62587. length(): number;
  62588. /**
  62589. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62590. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62591. * curveA and curveB keep unchanged.
  62592. * @param curve the curve to continue from this curve
  62593. * @returns the newly constructed curve
  62594. */
  62595. continue(curve: DeepImmutable<Curve3>): Curve3;
  62596. private _computeLength;
  62597. }
  62598. /**
  62599. * Contains position and normal vectors for a vertex
  62600. */
  62601. export class PositionNormalVertex {
  62602. /** the position of the vertex (defaut: 0,0,0) */
  62603. position: Vector3;
  62604. /** the normal of the vertex (defaut: 0,1,0) */
  62605. normal: Vector3;
  62606. /**
  62607. * Creates a PositionNormalVertex
  62608. * @param position the position of the vertex (defaut: 0,0,0)
  62609. * @param normal the normal of the vertex (defaut: 0,1,0)
  62610. */
  62611. constructor(
  62612. /** the position of the vertex (defaut: 0,0,0) */
  62613. position?: Vector3,
  62614. /** the normal of the vertex (defaut: 0,1,0) */
  62615. normal?: Vector3);
  62616. /**
  62617. * Clones the PositionNormalVertex
  62618. * @returns the cloned PositionNormalVertex
  62619. */
  62620. clone(): PositionNormalVertex;
  62621. }
  62622. /**
  62623. * Contains position, normal and uv vectors for a vertex
  62624. */
  62625. export class PositionNormalTextureVertex {
  62626. /** the position of the vertex (defaut: 0,0,0) */
  62627. position: Vector3;
  62628. /** the normal of the vertex (defaut: 0,1,0) */
  62629. normal: Vector3;
  62630. /** the uv of the vertex (default: 0,0) */
  62631. uv: Vector2;
  62632. /**
  62633. * Creates a PositionNormalTextureVertex
  62634. * @param position the position of the vertex (defaut: 0,0,0)
  62635. * @param normal the normal of the vertex (defaut: 0,1,0)
  62636. * @param uv the uv of the vertex (default: 0,0)
  62637. */
  62638. constructor(
  62639. /** the position of the vertex (defaut: 0,0,0) */
  62640. position?: Vector3,
  62641. /** the normal of the vertex (defaut: 0,1,0) */
  62642. normal?: Vector3,
  62643. /** the uv of the vertex (default: 0,0) */
  62644. uv?: Vector2);
  62645. /**
  62646. * Clones the PositionNormalTextureVertex
  62647. * @returns the cloned PositionNormalTextureVertex
  62648. */
  62649. clone(): PositionNormalTextureVertex;
  62650. }
  62651. /**
  62652. * @hidden
  62653. */
  62654. export class Tmp {
  62655. static Color3: Color3[];
  62656. static Color4: Color4[];
  62657. static Vector2: Vector2[];
  62658. static Vector3: Vector3[];
  62659. static Vector4: Vector4[];
  62660. static Quaternion: Quaternion[];
  62661. static Matrix: Matrix[];
  62662. }
  62663. }
  62664. declare module BABYLON {
  62665. /**
  62666. * Class used to enable access to offline support
  62667. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62668. */
  62669. export interface IOfflineProvider {
  62670. /**
  62671. * Gets a boolean indicating if scene must be saved in the database
  62672. */
  62673. enableSceneOffline: boolean;
  62674. /**
  62675. * Gets a boolean indicating if textures must be saved in the database
  62676. */
  62677. enableTexturesOffline: boolean;
  62678. /**
  62679. * Open the offline support and make it available
  62680. * @param successCallback defines the callback to call on success
  62681. * @param errorCallback defines the callback to call on error
  62682. */
  62683. open(successCallback: () => void, errorCallback: () => void): void;
  62684. /**
  62685. * Loads an image from the offline support
  62686. * @param url defines the url to load from
  62687. * @param image defines the target DOM image
  62688. */
  62689. loadImage(url: string, image: HTMLImageElement): void;
  62690. /**
  62691. * Loads a file from offline support
  62692. * @param url defines the URL to load from
  62693. * @param sceneLoaded defines a callback to call on success
  62694. * @param progressCallBack defines a callback to call when progress changed
  62695. * @param errorCallback defines a callback to call on error
  62696. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62697. */
  62698. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62699. }
  62700. }
  62701. declare module BABYLON {
  62702. /**
  62703. * A class serves as a medium between the observable and its observers
  62704. */
  62705. export class EventState {
  62706. /**
  62707. * Create a new EventState
  62708. * @param mask defines the mask associated with this state
  62709. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62710. * @param target defines the original target of the state
  62711. * @param currentTarget defines the current target of the state
  62712. */
  62713. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62714. /**
  62715. * Initialize the current event state
  62716. * @param mask defines the mask associated with this state
  62717. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62718. * @param target defines the original target of the state
  62719. * @param currentTarget defines the current target of the state
  62720. * @returns the current event state
  62721. */
  62722. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62723. /**
  62724. * An Observer can set this property to true to prevent subsequent observers of being notified
  62725. */
  62726. skipNextObservers: boolean;
  62727. /**
  62728. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62729. */
  62730. mask: number;
  62731. /**
  62732. * The object that originally notified the event
  62733. */
  62734. target?: any;
  62735. /**
  62736. * The current object in the bubbling phase
  62737. */
  62738. currentTarget?: any;
  62739. /**
  62740. * This will be populated with the return value of the last function that was executed.
  62741. * If it is the first function in the callback chain it will be the event data.
  62742. */
  62743. lastReturnValue?: any;
  62744. }
  62745. /**
  62746. * Represent an Observer registered to a given Observable object.
  62747. */
  62748. export class Observer<T> {
  62749. /**
  62750. * Defines the callback to call when the observer is notified
  62751. */
  62752. callback: (eventData: T, eventState: EventState) => void;
  62753. /**
  62754. * Defines the mask of the observer (used to filter notifications)
  62755. */
  62756. mask: number;
  62757. /**
  62758. * Defines the current scope used to restore the JS context
  62759. */
  62760. scope: any;
  62761. /** @hidden */
  62762. _willBeUnregistered: boolean;
  62763. /**
  62764. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62765. */
  62766. unregisterOnNextCall: boolean;
  62767. /**
  62768. * Creates a new observer
  62769. * @param callback defines the callback to call when the observer is notified
  62770. * @param mask defines the mask of the observer (used to filter notifications)
  62771. * @param scope defines the current scope used to restore the JS context
  62772. */
  62773. constructor(
  62774. /**
  62775. * Defines the callback to call when the observer is notified
  62776. */
  62777. callback: (eventData: T, eventState: EventState) => void,
  62778. /**
  62779. * Defines the mask of the observer (used to filter notifications)
  62780. */
  62781. mask: number,
  62782. /**
  62783. * Defines the current scope used to restore the JS context
  62784. */
  62785. scope?: any);
  62786. }
  62787. /**
  62788. * Represent a list of observers registered to multiple Observables object.
  62789. */
  62790. export class MultiObserver<T> {
  62791. private _observers;
  62792. private _observables;
  62793. /**
  62794. * Release associated resources
  62795. */
  62796. dispose(): void;
  62797. /**
  62798. * Raise a callback when one of the observable will notify
  62799. * @param observables defines a list of observables to watch
  62800. * @param callback defines the callback to call on notification
  62801. * @param mask defines the mask used to filter notifications
  62802. * @param scope defines the current scope used to restore the JS context
  62803. * @returns the new MultiObserver
  62804. */
  62805. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62806. }
  62807. /**
  62808. * The Observable class is a simple implementation of the Observable pattern.
  62809. *
  62810. * 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.
  62811. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62812. * 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).
  62813. * 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.
  62814. */
  62815. export class Observable<T> {
  62816. private _observers;
  62817. private _eventState;
  62818. private _onObserverAdded;
  62819. /**
  62820. * Creates a new observable
  62821. * @param onObserverAdded defines a callback to call when a new observer is added
  62822. */
  62823. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62824. /**
  62825. * Create a new Observer with the specified callback
  62826. * @param callback the callback that will be executed for that Observer
  62827. * @param mask the mask used to filter observers
  62828. * @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.
  62829. * @param scope optional scope for the callback to be called from
  62830. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62831. * @returns the new observer created for the callback
  62832. */
  62833. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62834. /**
  62835. * Create a new Observer with the specified callback and unregisters after the next notification
  62836. * @param callback the callback that will be executed for that Observer
  62837. * @returns the new observer created for the callback
  62838. */
  62839. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62840. /**
  62841. * Remove an Observer from the Observable object
  62842. * @param observer the instance of the Observer to remove
  62843. * @returns false if it doesn't belong to this Observable
  62844. */
  62845. remove(observer: Nullable<Observer<T>>): boolean;
  62846. /**
  62847. * Remove a callback from the Observable object
  62848. * @param callback the callback to remove
  62849. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62850. * @returns false if it doesn't belong to this Observable
  62851. */
  62852. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62853. private _deferUnregister;
  62854. private _remove;
  62855. /**
  62856. * Moves the observable to the top of the observer list making it get called first when notified
  62857. * @param observer the observer to move
  62858. */
  62859. makeObserverTopPriority(observer: Observer<T>): void;
  62860. /**
  62861. * Moves the observable to the bottom of the observer list making it get called last when notified
  62862. * @param observer the observer to move
  62863. */
  62864. makeObserverBottomPriority(observer: Observer<T>): void;
  62865. /**
  62866. * Notify all Observers by calling their respective callback with the given data
  62867. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62868. * @param eventData defines the data to send to all observers
  62869. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62870. * @param target defines the original target of the state
  62871. * @param currentTarget defines the current target of the state
  62872. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62873. */
  62874. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62875. /**
  62876. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62877. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62878. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62879. * and it is crucial that all callbacks will be executed.
  62880. * The order of the callbacks is kept, callbacks are not executed parallel.
  62881. *
  62882. * @param eventData The data to be sent to each callback
  62883. * @param mask is used to filter observers defaults to -1
  62884. * @param target defines the callback target (see EventState)
  62885. * @param currentTarget defines he current object in the bubbling phase
  62886. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62887. */
  62888. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62889. /**
  62890. * Notify a specific observer
  62891. * @param observer defines the observer to notify
  62892. * @param eventData defines the data to be sent to each callback
  62893. * @param mask is used to filter observers defaults to -1
  62894. */
  62895. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62896. /**
  62897. * Gets a boolean indicating if the observable has at least one observer
  62898. * @returns true is the Observable has at least one Observer registered
  62899. */
  62900. hasObservers(): boolean;
  62901. /**
  62902. * Clear the list of observers
  62903. */
  62904. clear(): void;
  62905. /**
  62906. * Clone the current observable
  62907. * @returns a new observable
  62908. */
  62909. clone(): Observable<T>;
  62910. /**
  62911. * Does this observable handles observer registered with a given mask
  62912. * @param mask defines the mask to be tested
  62913. * @return whether or not one observer registered with the given mask is handeled
  62914. **/
  62915. hasSpecificMask(mask?: number): boolean;
  62916. }
  62917. }
  62918. declare module BABYLON {
  62919. /**
  62920. * Class used to help managing file picking and drag'n'drop
  62921. * File Storage
  62922. */
  62923. export class FilesInputStore {
  62924. /**
  62925. * List of files ready to be loaded
  62926. */
  62927. static FilesToLoad: {
  62928. [key: string]: File;
  62929. };
  62930. }
  62931. }
  62932. declare module BABYLON {
  62933. /** Defines the cross module used constants to avoid circular dependncies */
  62934. export class Constants {
  62935. /** Defines that alpha blending is disabled */
  62936. static readonly ALPHA_DISABLE: number;
  62937. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62938. static readonly ALPHA_ADD: number;
  62939. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62940. static readonly ALPHA_COMBINE: number;
  62941. /** Defines that alpha blending to DEST - SRC * DEST */
  62942. static readonly ALPHA_SUBTRACT: number;
  62943. /** Defines that alpha blending to SRC * DEST */
  62944. static readonly ALPHA_MULTIPLY: number;
  62945. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62946. static readonly ALPHA_MAXIMIZED: number;
  62947. /** Defines that alpha blending to SRC + DEST */
  62948. static readonly ALPHA_ONEONE: number;
  62949. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62950. static readonly ALPHA_PREMULTIPLIED: number;
  62951. /**
  62952. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62953. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62954. */
  62955. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62956. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62957. static readonly ALPHA_INTERPOLATE: number;
  62958. /**
  62959. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62960. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62961. */
  62962. static readonly ALPHA_SCREENMODE: number;
  62963. /** Defines that the ressource is not delayed*/
  62964. static readonly DELAYLOADSTATE_NONE: number;
  62965. /** Defines that the ressource was successfully delay loaded */
  62966. static readonly DELAYLOADSTATE_LOADED: number;
  62967. /** Defines that the ressource is currently delay loading */
  62968. static readonly DELAYLOADSTATE_LOADING: number;
  62969. /** Defines that the ressource is delayed and has not started loading */
  62970. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62971. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62972. static readonly NEVER: number;
  62973. /** 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 */
  62974. static readonly ALWAYS: number;
  62975. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62976. static readonly LESS: number;
  62977. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62978. static readonly EQUAL: number;
  62979. /** 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 */
  62980. static readonly LEQUAL: number;
  62981. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62982. static readonly GREATER: number;
  62983. /** 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 */
  62984. static readonly GEQUAL: number;
  62985. /** 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 */
  62986. static readonly NOTEQUAL: number;
  62987. /** Passed to stencilOperation to specify that stencil value must be kept */
  62988. static readonly KEEP: number;
  62989. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62990. static readonly REPLACE: number;
  62991. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62992. static readonly INCR: number;
  62993. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62994. static readonly DECR: number;
  62995. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62996. static readonly INVERT: number;
  62997. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62998. static readonly INCR_WRAP: number;
  62999. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63000. static readonly DECR_WRAP: number;
  63001. /** Texture is not repeating outside of 0..1 UVs */
  63002. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63003. /** Texture is repeating outside of 0..1 UVs */
  63004. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63005. /** Texture is repeating and mirrored */
  63006. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63007. /** ALPHA */
  63008. static readonly TEXTUREFORMAT_ALPHA: number;
  63009. /** LUMINANCE */
  63010. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63011. /** LUMINANCE_ALPHA */
  63012. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63013. /** RGB */
  63014. static readonly TEXTUREFORMAT_RGB: number;
  63015. /** RGBA */
  63016. static readonly TEXTUREFORMAT_RGBA: number;
  63017. /** RED */
  63018. static readonly TEXTUREFORMAT_RED: number;
  63019. /** RED (2nd reference) */
  63020. static readonly TEXTUREFORMAT_R: number;
  63021. /** RG */
  63022. static readonly TEXTUREFORMAT_RG: number;
  63023. /** RED_INTEGER */
  63024. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63025. /** RED_INTEGER (2nd reference) */
  63026. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63027. /** RG_INTEGER */
  63028. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63029. /** RGB_INTEGER */
  63030. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63031. /** RGBA_INTEGER */
  63032. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63033. /** UNSIGNED_BYTE */
  63034. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63035. /** UNSIGNED_BYTE (2nd reference) */
  63036. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63037. /** FLOAT */
  63038. static readonly TEXTURETYPE_FLOAT: number;
  63039. /** HALF_FLOAT */
  63040. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63041. /** BYTE */
  63042. static readonly TEXTURETYPE_BYTE: number;
  63043. /** SHORT */
  63044. static readonly TEXTURETYPE_SHORT: number;
  63045. /** UNSIGNED_SHORT */
  63046. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63047. /** INT */
  63048. static readonly TEXTURETYPE_INT: number;
  63049. /** UNSIGNED_INT */
  63050. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63051. /** UNSIGNED_SHORT_4_4_4_4 */
  63052. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63053. /** UNSIGNED_SHORT_5_5_5_1 */
  63054. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63055. /** UNSIGNED_SHORT_5_6_5 */
  63056. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63057. /** UNSIGNED_INT_2_10_10_10_REV */
  63058. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63059. /** UNSIGNED_INT_24_8 */
  63060. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63061. /** UNSIGNED_INT_10F_11F_11F_REV */
  63062. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63063. /** UNSIGNED_INT_5_9_9_9_REV */
  63064. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63065. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63066. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63067. /** nearest is mag = nearest and min = nearest and mip = linear */
  63068. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63069. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63070. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63071. /** Trilinear is mag = linear and min = linear and mip = linear */
  63072. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63073. /** nearest is mag = nearest and min = nearest and mip = linear */
  63074. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63075. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63076. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63077. /** Trilinear is mag = linear and min = linear and mip = linear */
  63078. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63079. /** mag = nearest and min = nearest and mip = nearest */
  63080. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63081. /** mag = nearest and min = linear and mip = nearest */
  63082. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63083. /** mag = nearest and min = linear and mip = linear */
  63084. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63085. /** mag = nearest and min = linear and mip = none */
  63086. static readonly TEXTURE_NEAREST_LINEAR: number;
  63087. /** mag = nearest and min = nearest and mip = none */
  63088. static readonly TEXTURE_NEAREST_NEAREST: number;
  63089. /** mag = linear and min = nearest and mip = nearest */
  63090. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63091. /** mag = linear and min = nearest and mip = linear */
  63092. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63093. /** mag = linear and min = linear and mip = none */
  63094. static readonly TEXTURE_LINEAR_LINEAR: number;
  63095. /** mag = linear and min = nearest and mip = none */
  63096. static readonly TEXTURE_LINEAR_NEAREST: number;
  63097. /** Explicit coordinates mode */
  63098. static readonly TEXTURE_EXPLICIT_MODE: number;
  63099. /** Spherical coordinates mode */
  63100. static readonly TEXTURE_SPHERICAL_MODE: number;
  63101. /** Planar coordinates mode */
  63102. static readonly TEXTURE_PLANAR_MODE: number;
  63103. /** Cubic coordinates mode */
  63104. static readonly TEXTURE_CUBIC_MODE: number;
  63105. /** Projection coordinates mode */
  63106. static readonly TEXTURE_PROJECTION_MODE: number;
  63107. /** Skybox coordinates mode */
  63108. static readonly TEXTURE_SKYBOX_MODE: number;
  63109. /** Inverse Cubic coordinates mode */
  63110. static readonly TEXTURE_INVCUBIC_MODE: number;
  63111. /** Equirectangular coordinates mode */
  63112. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63113. /** Equirectangular Fixed coordinates mode */
  63114. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63115. /** Equirectangular Fixed Mirrored coordinates mode */
  63116. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63117. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63118. static readonly SCALEMODE_FLOOR: number;
  63119. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63120. static readonly SCALEMODE_NEAREST: number;
  63121. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63122. static readonly SCALEMODE_CEILING: number;
  63123. /**
  63124. * The dirty texture flag value
  63125. */
  63126. static readonly MATERIAL_TextureDirtyFlag: number;
  63127. /**
  63128. * The dirty light flag value
  63129. */
  63130. static readonly MATERIAL_LightDirtyFlag: number;
  63131. /**
  63132. * The dirty fresnel flag value
  63133. */
  63134. static readonly MATERIAL_FresnelDirtyFlag: number;
  63135. /**
  63136. * The dirty attribute flag value
  63137. */
  63138. static readonly MATERIAL_AttributesDirtyFlag: number;
  63139. /**
  63140. * The dirty misc flag value
  63141. */
  63142. static readonly MATERIAL_MiscDirtyFlag: number;
  63143. /**
  63144. * The all dirty flag value
  63145. */
  63146. static readonly MATERIAL_AllDirtyFlag: number;
  63147. /**
  63148. * Returns the triangle fill mode
  63149. */
  63150. static readonly MATERIAL_TriangleFillMode: number;
  63151. /**
  63152. * Returns the wireframe mode
  63153. */
  63154. static readonly MATERIAL_WireFrameFillMode: number;
  63155. /**
  63156. * Returns the point fill mode
  63157. */
  63158. static readonly MATERIAL_PointFillMode: number;
  63159. /**
  63160. * Returns the point list draw mode
  63161. */
  63162. static readonly MATERIAL_PointListDrawMode: number;
  63163. /**
  63164. * Returns the line list draw mode
  63165. */
  63166. static readonly MATERIAL_LineListDrawMode: number;
  63167. /**
  63168. * Returns the line loop draw mode
  63169. */
  63170. static readonly MATERIAL_LineLoopDrawMode: number;
  63171. /**
  63172. * Returns the line strip draw mode
  63173. */
  63174. static readonly MATERIAL_LineStripDrawMode: number;
  63175. /**
  63176. * Returns the triangle strip draw mode
  63177. */
  63178. static readonly MATERIAL_TriangleStripDrawMode: number;
  63179. /**
  63180. * Returns the triangle fan draw mode
  63181. */
  63182. static readonly MATERIAL_TriangleFanDrawMode: number;
  63183. /**
  63184. * Stores the clock-wise side orientation
  63185. */
  63186. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63187. /**
  63188. * Stores the counter clock-wise side orientation
  63189. */
  63190. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63191. /**
  63192. * Nothing
  63193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63194. */
  63195. static readonly ACTION_NothingTrigger: number;
  63196. /**
  63197. * On pick
  63198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63199. */
  63200. static readonly ACTION_OnPickTrigger: number;
  63201. /**
  63202. * On left pick
  63203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63204. */
  63205. static readonly ACTION_OnLeftPickTrigger: number;
  63206. /**
  63207. * On right pick
  63208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63209. */
  63210. static readonly ACTION_OnRightPickTrigger: number;
  63211. /**
  63212. * On center pick
  63213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63214. */
  63215. static readonly ACTION_OnCenterPickTrigger: number;
  63216. /**
  63217. * On pick down
  63218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63219. */
  63220. static readonly ACTION_OnPickDownTrigger: number;
  63221. /**
  63222. * On double pick
  63223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63224. */
  63225. static readonly ACTION_OnDoublePickTrigger: number;
  63226. /**
  63227. * On pick up
  63228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63229. */
  63230. static readonly ACTION_OnPickUpTrigger: number;
  63231. /**
  63232. * On pick out.
  63233. * This trigger will only be raised if you also declared a OnPickDown
  63234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63235. */
  63236. static readonly ACTION_OnPickOutTrigger: number;
  63237. /**
  63238. * On long press
  63239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63240. */
  63241. static readonly ACTION_OnLongPressTrigger: number;
  63242. /**
  63243. * On pointer over
  63244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63245. */
  63246. static readonly ACTION_OnPointerOverTrigger: number;
  63247. /**
  63248. * On pointer out
  63249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63250. */
  63251. static readonly ACTION_OnPointerOutTrigger: number;
  63252. /**
  63253. * On every frame
  63254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63255. */
  63256. static readonly ACTION_OnEveryFrameTrigger: number;
  63257. /**
  63258. * On intersection enter
  63259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63260. */
  63261. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63262. /**
  63263. * On intersection exit
  63264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63265. */
  63266. static readonly ACTION_OnIntersectionExitTrigger: number;
  63267. /**
  63268. * On key down
  63269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63270. */
  63271. static readonly ACTION_OnKeyDownTrigger: number;
  63272. /**
  63273. * On key up
  63274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63275. */
  63276. static readonly ACTION_OnKeyUpTrigger: number;
  63277. /**
  63278. * Billboard mode will only apply to Y axis
  63279. */
  63280. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63281. /**
  63282. * Billboard mode will apply to all axes
  63283. */
  63284. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63285. /**
  63286. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63287. */
  63288. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63289. /**
  63290. * Gets or sets base Assets URL
  63291. */
  63292. static readonly PARTICLES_BaseAssetsUrl: string;
  63293. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63294. * Test order :
  63295. * Is the bounding sphere outside the frustum ?
  63296. * If not, are the bounding box vertices outside the frustum ?
  63297. * It not, then the cullable object is in the frustum.
  63298. */
  63299. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63300. /** Culling strategy : Bounding Sphere Only.
  63301. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63302. * It's also less accurate than the standard because some not visible objects can still be selected.
  63303. * Test : is the bounding sphere outside the frustum ?
  63304. * If not, then the cullable object is in the frustum.
  63305. */
  63306. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63307. /** Culling strategy : Optimistic Inclusion.
  63308. * This in an inclusion test first, then the standard exclusion test.
  63309. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63310. * 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.
  63311. * Anyway, it's as accurate as the standard strategy.
  63312. * Test :
  63313. * Is the cullable object bounding sphere center in the frustum ?
  63314. * If not, apply the default culling strategy.
  63315. */
  63316. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63317. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63318. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63319. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63320. * 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.
  63321. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63322. * Test :
  63323. * Is the cullable object bounding sphere center in the frustum ?
  63324. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63325. */
  63326. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63327. /**
  63328. * No logging while loading
  63329. */
  63330. static readonly SCENELOADER_NO_LOGGING: number;
  63331. /**
  63332. * Minimal logging while loading
  63333. */
  63334. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63335. /**
  63336. * Summary logging while loading
  63337. */
  63338. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63339. /**
  63340. * Detailled logging while loading
  63341. */
  63342. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63343. }
  63344. }
  63345. declare module BABYLON {
  63346. /**
  63347. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63348. * Babylon.js
  63349. */
  63350. export class DomManagement {
  63351. /**
  63352. * Checks if the window object exists
  63353. * @returns true if the window object exists
  63354. */
  63355. static IsWindowObjectExist(): boolean;
  63356. /**
  63357. * Extracts text content from a DOM element hierarchy
  63358. * @param element defines the root element
  63359. * @returns a string
  63360. */
  63361. static GetDOMTextContent(element: HTMLElement): string;
  63362. }
  63363. }
  63364. declare module BABYLON {
  63365. /**
  63366. * Logger used througouht the application to allow configuration of
  63367. * the log level required for the messages.
  63368. */
  63369. export class Logger {
  63370. /**
  63371. * No log
  63372. */
  63373. static readonly NoneLogLevel: number;
  63374. /**
  63375. * Only message logs
  63376. */
  63377. static readonly MessageLogLevel: number;
  63378. /**
  63379. * Only warning logs
  63380. */
  63381. static readonly WarningLogLevel: number;
  63382. /**
  63383. * Only error logs
  63384. */
  63385. static readonly ErrorLogLevel: number;
  63386. /**
  63387. * All logs
  63388. */
  63389. static readonly AllLogLevel: number;
  63390. private static _LogCache;
  63391. /**
  63392. * Gets a value indicating the number of loading errors
  63393. * @ignorenaming
  63394. */
  63395. static errorsCount: number;
  63396. /**
  63397. * Callback called when a new log is added
  63398. */
  63399. static OnNewCacheEntry: (entry: string) => void;
  63400. private static _AddLogEntry;
  63401. private static _FormatMessage;
  63402. private static _LogDisabled;
  63403. private static _LogEnabled;
  63404. private static _WarnDisabled;
  63405. private static _WarnEnabled;
  63406. private static _ErrorDisabled;
  63407. private static _ErrorEnabled;
  63408. /**
  63409. * Log a message to the console
  63410. */
  63411. static Log: (message: string) => void;
  63412. /**
  63413. * Write a warning message to the console
  63414. */
  63415. static Warn: (message: string) => void;
  63416. /**
  63417. * Write an error message to the console
  63418. */
  63419. static Error: (message: string) => void;
  63420. /**
  63421. * Gets current log cache (list of logs)
  63422. */
  63423. static readonly LogCache: string;
  63424. /**
  63425. * Clears the log cache
  63426. */
  63427. static ClearLogCache(): void;
  63428. /**
  63429. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63430. */
  63431. static LogLevels: number;
  63432. }
  63433. }
  63434. declare module BABYLON {
  63435. /** @hidden */
  63436. export class _TypeStore {
  63437. /** @hidden */
  63438. static RegisteredTypes: {
  63439. [key: string]: Object;
  63440. };
  63441. /** @hidden */
  63442. static GetClass(fqdn: string): any;
  63443. }
  63444. }
  63445. declare module BABYLON {
  63446. /**
  63447. * Class containing a set of static utilities functions for deep copy.
  63448. */
  63449. export class DeepCopier {
  63450. /**
  63451. * Tries to copy an object by duplicating every property
  63452. * @param source defines the source object
  63453. * @param destination defines the target object
  63454. * @param doNotCopyList defines a list of properties to avoid
  63455. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63456. */
  63457. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63458. }
  63459. }
  63460. declare module BABYLON {
  63461. /**
  63462. * Class containing a set of static utilities functions for precision date
  63463. */
  63464. export class PrecisionDate {
  63465. /**
  63466. * Gets either window.performance.now() if supported or Date.now() else
  63467. */
  63468. static readonly Now: number;
  63469. }
  63470. }
  63471. declare module BABYLON {
  63472. /** @hidden */
  63473. export class _DevTools {
  63474. static WarnImport(name: string): string;
  63475. }
  63476. }
  63477. declare module BABYLON {
  63478. /**
  63479. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63480. */
  63481. export class WebRequest {
  63482. private _xhr;
  63483. /**
  63484. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63485. * i.e. when loading files, where the server/service expects an Authorization header
  63486. */
  63487. static CustomRequestHeaders: {
  63488. [key: string]: string;
  63489. };
  63490. /**
  63491. * Add callback functions in this array to update all the requests before they get sent to the network
  63492. */
  63493. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63494. private _injectCustomRequestHeaders;
  63495. /**
  63496. * Gets or sets a function to be called when loading progress changes
  63497. */
  63498. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63499. /**
  63500. * Returns client's state
  63501. */
  63502. readonly readyState: number;
  63503. /**
  63504. * Returns client's status
  63505. */
  63506. readonly status: number;
  63507. /**
  63508. * Returns client's status as a text
  63509. */
  63510. readonly statusText: string;
  63511. /**
  63512. * Returns client's response
  63513. */
  63514. readonly response: any;
  63515. /**
  63516. * Returns client's response url
  63517. */
  63518. readonly responseURL: string;
  63519. /**
  63520. * Returns client's response as text
  63521. */
  63522. readonly responseText: string;
  63523. /**
  63524. * Gets or sets the expected response type
  63525. */
  63526. responseType: XMLHttpRequestResponseType;
  63527. /** @hidden */
  63528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63529. /** @hidden */
  63530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63531. /**
  63532. * Cancels any network activity
  63533. */
  63534. abort(): void;
  63535. /**
  63536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63537. * @param body defines an optional request body
  63538. */
  63539. send(body?: Document | BodyInit | null): void;
  63540. /**
  63541. * Sets the request method, request URL
  63542. * @param method defines the method to use (GET, POST, etc..)
  63543. * @param url defines the url to connect with
  63544. */
  63545. open(method: string, url: string): void;
  63546. }
  63547. }
  63548. declare module BABYLON {
  63549. /**
  63550. * Class used to evalaute queries containing `and` and `or` operators
  63551. */
  63552. export class AndOrNotEvaluator {
  63553. /**
  63554. * Evaluate a query
  63555. * @param query defines the query to evaluate
  63556. * @param evaluateCallback defines the callback used to filter result
  63557. * @returns true if the query matches
  63558. */
  63559. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63560. private static _HandleParenthesisContent;
  63561. private static _SimplifyNegation;
  63562. }
  63563. }
  63564. declare module BABYLON {
  63565. /**
  63566. * Class used to store custom tags
  63567. */
  63568. export class Tags {
  63569. /**
  63570. * Adds support for tags on the given object
  63571. * @param obj defines the object to use
  63572. */
  63573. static EnableFor(obj: any): void;
  63574. /**
  63575. * Removes tags support
  63576. * @param obj defines the object to use
  63577. */
  63578. static DisableFor(obj: any): void;
  63579. /**
  63580. * Gets a boolean indicating if the given object has tags
  63581. * @param obj defines the object to use
  63582. * @returns a boolean
  63583. */
  63584. static HasTags(obj: any): boolean;
  63585. /**
  63586. * Gets the tags available on a given object
  63587. * @param obj defines the object to use
  63588. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63589. * @returns the tags
  63590. */
  63591. static GetTags(obj: any, asString?: boolean): any;
  63592. /**
  63593. * Adds tags to an object
  63594. * @param obj defines the object to use
  63595. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63596. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63597. */
  63598. static AddTagsTo(obj: any, tagsString: string): void;
  63599. /**
  63600. * @hidden
  63601. */
  63602. static _AddTagTo(obj: any, tag: string): void;
  63603. /**
  63604. * Removes specific tags from a specific object
  63605. * @param obj defines the object to use
  63606. * @param tagsString defines the tags to remove
  63607. */
  63608. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63609. /**
  63610. * @hidden
  63611. */
  63612. static _RemoveTagFrom(obj: any, tag: string): void;
  63613. /**
  63614. * Defines if tags hosted on an object match a given query
  63615. * @param obj defines the object to use
  63616. * @param tagsQuery defines the tag query
  63617. * @returns a boolean
  63618. */
  63619. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63620. }
  63621. }
  63622. declare module BABYLON {
  63623. /**
  63624. * Manages the defines for the Material
  63625. */
  63626. export class MaterialDefines {
  63627. private _keys;
  63628. private _isDirty;
  63629. /** @hidden */
  63630. _renderId: number;
  63631. /** @hidden */
  63632. _areLightsDirty: boolean;
  63633. /** @hidden */
  63634. _areAttributesDirty: boolean;
  63635. /** @hidden */
  63636. _areTexturesDirty: boolean;
  63637. /** @hidden */
  63638. _areFresnelDirty: boolean;
  63639. /** @hidden */
  63640. _areMiscDirty: boolean;
  63641. /** @hidden */
  63642. _areImageProcessingDirty: boolean;
  63643. /** @hidden */
  63644. _normals: boolean;
  63645. /** @hidden */
  63646. _uvs: boolean;
  63647. /** @hidden */
  63648. _needNormals: boolean;
  63649. /** @hidden */
  63650. _needUVs: boolean;
  63651. /**
  63652. * Specifies if the material needs to be re-calculated
  63653. */
  63654. readonly isDirty: boolean;
  63655. /**
  63656. * Marks the material to indicate that it has been re-calculated
  63657. */
  63658. markAsProcessed(): void;
  63659. /**
  63660. * Marks the material to indicate that it needs to be re-calculated
  63661. */
  63662. markAsUnprocessed(): void;
  63663. /**
  63664. * Marks the material to indicate all of its defines need to be re-calculated
  63665. */
  63666. markAllAsDirty(): void;
  63667. /**
  63668. * Marks the material to indicate that image processing needs to be re-calculated
  63669. */
  63670. markAsImageProcessingDirty(): void;
  63671. /**
  63672. * Marks the material to indicate the lights need to be re-calculated
  63673. */
  63674. markAsLightDirty(): void;
  63675. /**
  63676. * Marks the attribute state as changed
  63677. */
  63678. markAsAttributesDirty(): void;
  63679. /**
  63680. * Marks the texture state as changed
  63681. */
  63682. markAsTexturesDirty(): void;
  63683. /**
  63684. * Marks the fresnel state as changed
  63685. */
  63686. markAsFresnelDirty(): void;
  63687. /**
  63688. * Marks the misc state as changed
  63689. */
  63690. markAsMiscDirty(): void;
  63691. /**
  63692. * Rebuilds the material defines
  63693. */
  63694. rebuild(): void;
  63695. /**
  63696. * Specifies if two material defines are equal
  63697. * @param other - A material define instance to compare to
  63698. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63699. */
  63700. isEqual(other: MaterialDefines): boolean;
  63701. /**
  63702. * Clones this instance's defines to another instance
  63703. * @param other - material defines to clone values to
  63704. */
  63705. cloneTo(other: MaterialDefines): void;
  63706. /**
  63707. * Resets the material define values
  63708. */
  63709. reset(): void;
  63710. /**
  63711. * Converts the material define values to a string
  63712. * @returns - String of material define information
  63713. */
  63714. toString(): string;
  63715. }
  63716. }
  63717. declare module BABYLON {
  63718. /**
  63719. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63720. */
  63721. export class PerformanceMonitor {
  63722. private _enabled;
  63723. private _rollingFrameTime;
  63724. private _lastFrameTimeMs;
  63725. /**
  63726. * constructor
  63727. * @param frameSampleSize The number of samples required to saturate the sliding window
  63728. */
  63729. constructor(frameSampleSize?: number);
  63730. /**
  63731. * Samples current frame
  63732. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63733. */
  63734. sampleFrame(timeMs?: number): void;
  63735. /**
  63736. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63737. */
  63738. readonly averageFrameTime: number;
  63739. /**
  63740. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63741. */
  63742. readonly averageFrameTimeVariance: number;
  63743. /**
  63744. * Returns the frame time of the most recent frame
  63745. */
  63746. readonly instantaneousFrameTime: number;
  63747. /**
  63748. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63749. */
  63750. readonly averageFPS: number;
  63751. /**
  63752. * Returns the average framerate in frames per second using the most recent frame time
  63753. */
  63754. readonly instantaneousFPS: number;
  63755. /**
  63756. * Returns true if enough samples have been taken to completely fill the sliding window
  63757. */
  63758. readonly isSaturated: boolean;
  63759. /**
  63760. * Enables contributions to the sliding window sample set
  63761. */
  63762. enable(): void;
  63763. /**
  63764. * Disables contributions to the sliding window sample set
  63765. * Samples will not be interpolated over the disabled period
  63766. */
  63767. disable(): void;
  63768. /**
  63769. * Returns true if sampling is enabled
  63770. */
  63771. readonly isEnabled: boolean;
  63772. /**
  63773. * Resets performance monitor
  63774. */
  63775. reset(): void;
  63776. }
  63777. /**
  63778. * RollingAverage
  63779. *
  63780. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63781. */
  63782. export class RollingAverage {
  63783. /**
  63784. * Current average
  63785. */
  63786. average: number;
  63787. /**
  63788. * Current variance
  63789. */
  63790. variance: number;
  63791. protected _samples: Array<number>;
  63792. protected _sampleCount: number;
  63793. protected _pos: number;
  63794. protected _m2: number;
  63795. /**
  63796. * constructor
  63797. * @param length The number of samples required to saturate the sliding window
  63798. */
  63799. constructor(length: number);
  63800. /**
  63801. * Adds a sample to the sample set
  63802. * @param v The sample value
  63803. */
  63804. add(v: number): void;
  63805. /**
  63806. * Returns previously added values or null if outside of history or outside the sliding window domain
  63807. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63808. * @return Value previously recorded with add() or null if outside of range
  63809. */
  63810. history(i: number): number;
  63811. /**
  63812. * Returns true if enough samples have been taken to completely fill the sliding window
  63813. * @return true if sample-set saturated
  63814. */
  63815. isSaturated(): boolean;
  63816. /**
  63817. * Resets the rolling average (equivalent to 0 samples taken so far)
  63818. */
  63819. reset(): void;
  63820. /**
  63821. * Wraps a value around the sample range boundaries
  63822. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63823. * @return Wrapped position in sample range
  63824. */
  63825. protected _wrapPosition(i: number): number;
  63826. }
  63827. }
  63828. declare module BABYLON {
  63829. /**
  63830. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63831. * The underlying implementation relies on an associative array to ensure the best performances.
  63832. * The value can be anything including 'null' but except 'undefined'
  63833. */
  63834. export class StringDictionary<T> {
  63835. /**
  63836. * This will clear this dictionary and copy the content from the 'source' one.
  63837. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63838. * @param source the dictionary to take the content from and copy to this dictionary
  63839. */
  63840. copyFrom(source: StringDictionary<T>): void;
  63841. /**
  63842. * Get a value based from its key
  63843. * @param key the given key to get the matching value from
  63844. * @return the value if found, otherwise undefined is returned
  63845. */
  63846. get(key: string): T | undefined;
  63847. /**
  63848. * Get a value from its key or add it if it doesn't exist.
  63849. * This method will ensure you that a given key/data will be present in the dictionary.
  63850. * @param key the given key to get the matching value from
  63851. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63852. * The factory will only be invoked if there's no data for the given key.
  63853. * @return the value corresponding to the key.
  63854. */
  63855. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63856. /**
  63857. * Get a value from its key if present in the dictionary otherwise add it
  63858. * @param key the key to get the value from
  63859. * @param val if there's no such key/value pair in the dictionary add it with this value
  63860. * @return the value corresponding to the key
  63861. */
  63862. getOrAdd(key: string, val: T): T;
  63863. /**
  63864. * Check if there's a given key in the dictionary
  63865. * @param key the key to check for
  63866. * @return true if the key is present, false otherwise
  63867. */
  63868. contains(key: string): boolean;
  63869. /**
  63870. * Add a new key and its corresponding value
  63871. * @param key the key to add
  63872. * @param value the value corresponding to the key
  63873. * @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
  63874. */
  63875. add(key: string, value: T): boolean;
  63876. /**
  63877. * Update a specific value associated to a key
  63878. * @param key defines the key to use
  63879. * @param value defines the value to store
  63880. * @returns true if the value was updated (or false if the key was not found)
  63881. */
  63882. set(key: string, value: T): boolean;
  63883. /**
  63884. * Get the element of the given key and remove it from the dictionary
  63885. * @param key defines the key to search
  63886. * @returns the value associated with the key or null if not found
  63887. */
  63888. getAndRemove(key: string): Nullable<T>;
  63889. /**
  63890. * Remove a key/value from the dictionary.
  63891. * @param key the key to remove
  63892. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63893. */
  63894. remove(key: string): boolean;
  63895. /**
  63896. * Clear the whole content of the dictionary
  63897. */
  63898. clear(): void;
  63899. /**
  63900. * Gets the current count
  63901. */
  63902. readonly count: number;
  63903. /**
  63904. * Execute a callback on each key/val of the dictionary.
  63905. * Note that you can remove any element in this dictionary in the callback implementation
  63906. * @param callback the callback to execute on a given key/value pair
  63907. */
  63908. forEach(callback: (key: string, val: T) => void): void;
  63909. /**
  63910. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63911. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63912. * Note that you can remove any element in this dictionary in the callback implementation
  63913. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63914. * @returns the first item
  63915. */
  63916. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63917. private _count;
  63918. private _data;
  63919. }
  63920. }
  63921. declare module BABYLON {
  63922. /**
  63923. * Helper class that provides a small promise polyfill
  63924. */
  63925. export class PromisePolyfill {
  63926. /**
  63927. * Static function used to check if the polyfill is required
  63928. * If this is the case then the function will inject the polyfill to window.Promise
  63929. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63930. */
  63931. static Apply(force?: boolean): void;
  63932. }
  63933. }
  63934. declare module BABYLON {
  63935. /**
  63936. * Class used to store data that will be store in GPU memory
  63937. */
  63938. export class Buffer {
  63939. private _engine;
  63940. private _buffer;
  63941. /** @hidden */
  63942. _data: Nullable<DataArray>;
  63943. private _updatable;
  63944. private _instanced;
  63945. /**
  63946. * Gets the byte stride.
  63947. */
  63948. readonly byteStride: number;
  63949. /**
  63950. * Constructor
  63951. * @param engine the engine
  63952. * @param data the data to use for this buffer
  63953. * @param updatable whether the data is updatable
  63954. * @param stride the stride (optional)
  63955. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63956. * @param instanced whether the buffer is instanced (optional)
  63957. * @param useBytes set to true if the stride in in bytes (optional)
  63958. */
  63959. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63960. /**
  63961. * Create a new VertexBuffer based on the current buffer
  63962. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63963. * @param offset defines offset in the buffer (0 by default)
  63964. * @param size defines the size in floats of attributes (position is 3 for instance)
  63965. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63966. * @param instanced defines if the vertex buffer contains indexed data
  63967. * @param useBytes defines if the offset and stride are in bytes
  63968. * @returns the new vertex buffer
  63969. */
  63970. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63971. /**
  63972. * Gets a boolean indicating if the Buffer is updatable?
  63973. * @returns true if the buffer is updatable
  63974. */
  63975. isUpdatable(): boolean;
  63976. /**
  63977. * Gets current buffer's data
  63978. * @returns a DataArray or null
  63979. */
  63980. getData(): Nullable<DataArray>;
  63981. /**
  63982. * Gets underlying native buffer
  63983. * @returns underlying native buffer
  63984. */
  63985. getBuffer(): Nullable<WebGLBuffer>;
  63986. /**
  63987. * Gets the stride in float32 units (i.e. byte stride / 4).
  63988. * May not be an integer if the byte stride is not divisible by 4.
  63989. * DEPRECATED. Use byteStride instead.
  63990. * @returns the stride in float32 units
  63991. */
  63992. getStrideSize(): number;
  63993. /**
  63994. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63995. * @param data defines the data to store
  63996. */
  63997. create(data?: Nullable<DataArray>): void;
  63998. /** @hidden */
  63999. _rebuild(): void;
  64000. /**
  64001. * Update current buffer data
  64002. * @param data defines the data to store
  64003. */
  64004. update(data: DataArray): void;
  64005. /**
  64006. * Updates the data directly.
  64007. * @param data the new data
  64008. * @param offset the new offset
  64009. * @param vertexCount the vertex count (optional)
  64010. * @param useBytes set to true if the offset is in bytes
  64011. */
  64012. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64013. /**
  64014. * Release all resources
  64015. */
  64016. dispose(): void;
  64017. }
  64018. /**
  64019. * Specialized buffer used to store vertex data
  64020. */
  64021. export class VertexBuffer {
  64022. /** @hidden */
  64023. _buffer: Buffer;
  64024. private _kind;
  64025. private _size;
  64026. private _ownsBuffer;
  64027. private _instanced;
  64028. private _instanceDivisor;
  64029. /**
  64030. * The byte type.
  64031. */
  64032. static readonly BYTE: number;
  64033. /**
  64034. * The unsigned byte type.
  64035. */
  64036. static readonly UNSIGNED_BYTE: number;
  64037. /**
  64038. * The short type.
  64039. */
  64040. static readonly SHORT: number;
  64041. /**
  64042. * The unsigned short type.
  64043. */
  64044. static readonly UNSIGNED_SHORT: number;
  64045. /**
  64046. * The integer type.
  64047. */
  64048. static readonly INT: number;
  64049. /**
  64050. * The unsigned integer type.
  64051. */
  64052. static readonly UNSIGNED_INT: number;
  64053. /**
  64054. * The float type.
  64055. */
  64056. static readonly FLOAT: number;
  64057. /**
  64058. * Gets or sets the instance divisor when in instanced mode
  64059. */
  64060. instanceDivisor: number;
  64061. /**
  64062. * Gets the byte stride.
  64063. */
  64064. readonly byteStride: number;
  64065. /**
  64066. * Gets the byte offset.
  64067. */
  64068. readonly byteOffset: number;
  64069. /**
  64070. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64071. */
  64072. readonly normalized: boolean;
  64073. /**
  64074. * Gets the data type of each component in the array.
  64075. */
  64076. readonly type: number;
  64077. /**
  64078. * Constructor
  64079. * @param engine the engine
  64080. * @param data the data to use for this vertex buffer
  64081. * @param kind the vertex buffer kind
  64082. * @param updatable whether the data is updatable
  64083. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64084. * @param stride the stride (optional)
  64085. * @param instanced whether the buffer is instanced (optional)
  64086. * @param offset the offset of the data (optional)
  64087. * @param size the number of components (optional)
  64088. * @param type the type of the component (optional)
  64089. * @param normalized whether the data contains normalized data (optional)
  64090. * @param useBytes set to true if stride and offset are in bytes (optional)
  64091. */
  64092. 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);
  64093. /** @hidden */
  64094. _rebuild(): void;
  64095. /**
  64096. * Returns the kind of the VertexBuffer (string)
  64097. * @returns a string
  64098. */
  64099. getKind(): string;
  64100. /**
  64101. * Gets a boolean indicating if the VertexBuffer is updatable?
  64102. * @returns true if the buffer is updatable
  64103. */
  64104. isUpdatable(): boolean;
  64105. /**
  64106. * Gets current buffer's data
  64107. * @returns a DataArray or null
  64108. */
  64109. getData(): Nullable<DataArray>;
  64110. /**
  64111. * Gets underlying native buffer
  64112. * @returns underlying native buffer
  64113. */
  64114. getBuffer(): Nullable<WebGLBuffer>;
  64115. /**
  64116. * Gets the stride in float32 units (i.e. byte stride / 4).
  64117. * May not be an integer if the byte stride is not divisible by 4.
  64118. * DEPRECATED. Use byteStride instead.
  64119. * @returns the stride in float32 units
  64120. */
  64121. getStrideSize(): number;
  64122. /**
  64123. * Returns the offset as a multiple of the type byte length.
  64124. * DEPRECATED. Use byteOffset instead.
  64125. * @returns the offset in bytes
  64126. */
  64127. getOffset(): number;
  64128. /**
  64129. * Returns the number of components per vertex attribute (integer)
  64130. * @returns the size in float
  64131. */
  64132. getSize(): number;
  64133. /**
  64134. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64135. * @returns true if this buffer is instanced
  64136. */
  64137. getIsInstanced(): boolean;
  64138. /**
  64139. * Returns the instancing divisor, zero for non-instanced (integer).
  64140. * @returns a number
  64141. */
  64142. getInstanceDivisor(): number;
  64143. /**
  64144. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64145. * @param data defines the data to store
  64146. */
  64147. create(data?: DataArray): void;
  64148. /**
  64149. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64150. * This function will create a new buffer if the current one is not updatable
  64151. * @param data defines the data to store
  64152. */
  64153. update(data: DataArray): void;
  64154. /**
  64155. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64156. * Returns the directly updated WebGLBuffer.
  64157. * @param data the new data
  64158. * @param offset the new offset
  64159. * @param useBytes set to true if the offset is in bytes
  64160. */
  64161. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64162. /**
  64163. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64164. */
  64165. dispose(): void;
  64166. /**
  64167. * Enumerates each value of this vertex buffer as numbers.
  64168. * @param count the number of values to enumerate
  64169. * @param callback the callback function called for each value
  64170. */
  64171. forEach(count: number, callback: (value: number, index: number) => void): void;
  64172. /**
  64173. * Positions
  64174. */
  64175. static readonly PositionKind: string;
  64176. /**
  64177. * Normals
  64178. */
  64179. static readonly NormalKind: string;
  64180. /**
  64181. * Tangents
  64182. */
  64183. static readonly TangentKind: string;
  64184. /**
  64185. * Texture coordinates
  64186. */
  64187. static readonly UVKind: string;
  64188. /**
  64189. * Texture coordinates 2
  64190. */
  64191. static readonly UV2Kind: string;
  64192. /**
  64193. * Texture coordinates 3
  64194. */
  64195. static readonly UV3Kind: string;
  64196. /**
  64197. * Texture coordinates 4
  64198. */
  64199. static readonly UV4Kind: string;
  64200. /**
  64201. * Texture coordinates 5
  64202. */
  64203. static readonly UV5Kind: string;
  64204. /**
  64205. * Texture coordinates 6
  64206. */
  64207. static readonly UV6Kind: string;
  64208. /**
  64209. * Colors
  64210. */
  64211. static readonly ColorKind: string;
  64212. /**
  64213. * Matrix indices (for bones)
  64214. */
  64215. static readonly MatricesIndicesKind: string;
  64216. /**
  64217. * Matrix weights (for bones)
  64218. */
  64219. static readonly MatricesWeightsKind: string;
  64220. /**
  64221. * Additional matrix indices (for bones)
  64222. */
  64223. static readonly MatricesIndicesExtraKind: string;
  64224. /**
  64225. * Additional matrix weights (for bones)
  64226. */
  64227. static readonly MatricesWeightsExtraKind: string;
  64228. /**
  64229. * Deduces the stride given a kind.
  64230. * @param kind The kind string to deduce
  64231. * @returns The deduced stride
  64232. */
  64233. static DeduceStride(kind: string): number;
  64234. /**
  64235. * Gets the byte length of the given type.
  64236. * @param type the type
  64237. * @returns the number of bytes
  64238. */
  64239. static GetTypeByteLength(type: number): number;
  64240. /**
  64241. * Enumerates each value of the given parameters as numbers.
  64242. * @param data the data to enumerate
  64243. * @param byteOffset the byte offset of the data
  64244. * @param byteStride the byte stride of the data
  64245. * @param componentCount the number of components per element
  64246. * @param componentType the type of the component
  64247. * @param count the total number of components
  64248. * @param normalized whether the data is normalized
  64249. * @param callback the callback function called for each value
  64250. */
  64251. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64252. private static _GetFloatValue;
  64253. }
  64254. }
  64255. declare module BABYLON {
  64256. /**
  64257. * Class representing spherical polynomial coefficients to the 3rd degree
  64258. */
  64259. export class SphericalPolynomial {
  64260. /**
  64261. * The x coefficients of the spherical polynomial
  64262. */
  64263. x: Vector3;
  64264. /**
  64265. * The y coefficients of the spherical polynomial
  64266. */
  64267. y: Vector3;
  64268. /**
  64269. * The z coefficients of the spherical polynomial
  64270. */
  64271. z: Vector3;
  64272. /**
  64273. * The xx coefficients of the spherical polynomial
  64274. */
  64275. xx: Vector3;
  64276. /**
  64277. * The yy coefficients of the spherical polynomial
  64278. */
  64279. yy: Vector3;
  64280. /**
  64281. * The zz coefficients of the spherical polynomial
  64282. */
  64283. zz: Vector3;
  64284. /**
  64285. * The xy coefficients of the spherical polynomial
  64286. */
  64287. xy: Vector3;
  64288. /**
  64289. * The yz coefficients of the spherical polynomial
  64290. */
  64291. yz: Vector3;
  64292. /**
  64293. * The zx coefficients of the spherical polynomial
  64294. */
  64295. zx: Vector3;
  64296. /**
  64297. * Adds an ambient color to the spherical polynomial
  64298. * @param color the color to add
  64299. */
  64300. addAmbient(color: Color3): void;
  64301. /**
  64302. * Scales the spherical polynomial by the given amount
  64303. * @param scale the amount to scale
  64304. */
  64305. scale(scale: number): void;
  64306. /**
  64307. * Gets the spherical polynomial from harmonics
  64308. * @param harmonics the spherical harmonics
  64309. * @returns the spherical polynomial
  64310. */
  64311. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64312. /**
  64313. * Constructs a spherical polynomial from an array.
  64314. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64315. * @returns the spherical polynomial
  64316. */
  64317. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64318. }
  64319. /**
  64320. * Class representing spherical harmonics coefficients to the 3rd degree
  64321. */
  64322. export class SphericalHarmonics {
  64323. /**
  64324. * The l0,0 coefficients of the spherical harmonics
  64325. */
  64326. l00: Vector3;
  64327. /**
  64328. * The l1,-1 coefficients of the spherical harmonics
  64329. */
  64330. l1_1: Vector3;
  64331. /**
  64332. * The l1,0 coefficients of the spherical harmonics
  64333. */
  64334. l10: Vector3;
  64335. /**
  64336. * The l1,1 coefficients of the spherical harmonics
  64337. */
  64338. l11: Vector3;
  64339. /**
  64340. * The l2,-2 coefficients of the spherical harmonics
  64341. */
  64342. l2_2: Vector3;
  64343. /**
  64344. * The l2,-1 coefficients of the spherical harmonics
  64345. */
  64346. l2_1: Vector3;
  64347. /**
  64348. * The l2,0 coefficients of the spherical harmonics
  64349. */
  64350. l20: Vector3;
  64351. /**
  64352. * The l2,1 coefficients of the spherical harmonics
  64353. */
  64354. l21: Vector3;
  64355. /**
  64356. * The l2,2 coefficients of the spherical harmonics
  64357. */
  64358. lL22: Vector3;
  64359. /**
  64360. * Adds a light to the spherical harmonics
  64361. * @param direction the direction of the light
  64362. * @param color the color of the light
  64363. * @param deltaSolidAngle the delta solid angle of the light
  64364. */
  64365. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64366. /**
  64367. * Scales the spherical harmonics by the given amount
  64368. * @param scale the amount to scale
  64369. */
  64370. scale(scale: number): void;
  64371. /**
  64372. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64373. *
  64374. * ```
  64375. * E_lm = A_l * L_lm
  64376. * ```
  64377. *
  64378. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64379. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64380. * the scaling factors are given in equation 9.
  64381. */
  64382. convertIncidentRadianceToIrradiance(): void;
  64383. /**
  64384. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64385. *
  64386. * ```
  64387. * L = (1/pi) * E * rho
  64388. * ```
  64389. *
  64390. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64391. */
  64392. convertIrradianceToLambertianRadiance(): void;
  64393. /**
  64394. * Gets the spherical harmonics from polynomial
  64395. * @param polynomial the spherical polynomial
  64396. * @returns the spherical harmonics
  64397. */
  64398. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64399. /**
  64400. * Constructs a spherical harmonics from an array.
  64401. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64402. * @returns the spherical harmonics
  64403. */
  64404. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64405. }
  64406. }
  64407. declare module BABYLON {
  64408. /**
  64409. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64410. */
  64411. export interface CubeMapInfo {
  64412. /**
  64413. * The pixel array for the front face.
  64414. * This is stored in format, left to right, up to down format.
  64415. */
  64416. front: Nullable<ArrayBufferView>;
  64417. /**
  64418. * The pixel array for the back face.
  64419. * This is stored in format, left to right, up to down format.
  64420. */
  64421. back: Nullable<ArrayBufferView>;
  64422. /**
  64423. * The pixel array for the left face.
  64424. * This is stored in format, left to right, up to down format.
  64425. */
  64426. left: Nullable<ArrayBufferView>;
  64427. /**
  64428. * The pixel array for the right face.
  64429. * This is stored in format, left to right, up to down format.
  64430. */
  64431. right: Nullable<ArrayBufferView>;
  64432. /**
  64433. * The pixel array for the up face.
  64434. * This is stored in format, left to right, up to down format.
  64435. */
  64436. up: Nullable<ArrayBufferView>;
  64437. /**
  64438. * The pixel array for the down face.
  64439. * This is stored in format, left to right, up to down format.
  64440. */
  64441. down: Nullable<ArrayBufferView>;
  64442. /**
  64443. * The size of the cubemap stored.
  64444. *
  64445. * Each faces will be size * size pixels.
  64446. */
  64447. size: number;
  64448. /**
  64449. * The format of the texture.
  64450. *
  64451. * RGBA, RGB.
  64452. */
  64453. format: number;
  64454. /**
  64455. * The type of the texture data.
  64456. *
  64457. * UNSIGNED_INT, FLOAT.
  64458. */
  64459. type: number;
  64460. /**
  64461. * Specifies whether the texture is in gamma space.
  64462. */
  64463. gammaSpace: boolean;
  64464. }
  64465. /**
  64466. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64467. */
  64468. export class PanoramaToCubeMapTools {
  64469. private static FACE_FRONT;
  64470. private static FACE_BACK;
  64471. private static FACE_RIGHT;
  64472. private static FACE_LEFT;
  64473. private static FACE_DOWN;
  64474. private static FACE_UP;
  64475. /**
  64476. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64477. *
  64478. * @param float32Array The source data.
  64479. * @param inputWidth The width of the input panorama.
  64480. * @param inputHeight The height of the input panorama.
  64481. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64482. * @return The cubemap data
  64483. */
  64484. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64485. private static CreateCubemapTexture;
  64486. private static CalcProjectionSpherical;
  64487. }
  64488. }
  64489. declare module BABYLON {
  64490. /**
  64491. * Helper class dealing with the extraction of spherical polynomial dataArray
  64492. * from a cube map.
  64493. */
  64494. export class CubeMapToSphericalPolynomialTools {
  64495. private static FileFaces;
  64496. /**
  64497. * Converts a texture to the according Spherical Polynomial data.
  64498. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64499. *
  64500. * @param texture The texture to extract the information from.
  64501. * @return The Spherical Polynomial data.
  64502. */
  64503. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64504. /**
  64505. * Converts a cubemap to the according Spherical Polynomial data.
  64506. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64507. *
  64508. * @param cubeInfo The Cube map to extract the information from.
  64509. * @return The Spherical Polynomial data.
  64510. */
  64511. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64512. }
  64513. }
  64514. declare module BABYLON {
  64515. /**
  64516. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64517. * during the life time of the application.
  64518. */
  64519. export class EngineStore {
  64520. /** Gets the list of created engines */
  64521. static Instances: Engine[];
  64522. /**
  64523. * Gets the latest created engine
  64524. */
  64525. static readonly LastCreatedEngine: Nullable<Engine>;
  64526. /**
  64527. * Gets the latest created scene
  64528. */
  64529. static readonly LastCreatedScene: Nullable<Scene>;
  64530. }
  64531. }
  64532. declare module BABYLON {
  64533. /**
  64534. * Define options used to create a render target texture
  64535. */
  64536. export class RenderTargetCreationOptions {
  64537. /**
  64538. * Specifies is mipmaps must be generated
  64539. */
  64540. generateMipMaps?: boolean;
  64541. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64542. generateDepthBuffer?: boolean;
  64543. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64544. generateStencilBuffer?: boolean;
  64545. /** Defines texture type (int by default) */
  64546. type?: number;
  64547. /** Defines sampling mode (trilinear by default) */
  64548. samplingMode?: number;
  64549. /** Defines format (RGBA by default) */
  64550. format?: number;
  64551. }
  64552. }
  64553. declare module BABYLON {
  64554. /**
  64555. * @hidden
  64556. **/
  64557. export class _AlphaState {
  64558. private _isAlphaBlendDirty;
  64559. private _isBlendFunctionParametersDirty;
  64560. private _isBlendEquationParametersDirty;
  64561. private _isBlendConstantsDirty;
  64562. private _alphaBlend;
  64563. private _blendFunctionParameters;
  64564. private _blendEquationParameters;
  64565. private _blendConstants;
  64566. /**
  64567. * Initializes the state.
  64568. */
  64569. constructor();
  64570. readonly isDirty: boolean;
  64571. alphaBlend: boolean;
  64572. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64573. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64574. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64575. reset(): void;
  64576. apply(gl: WebGLRenderingContext): void;
  64577. }
  64578. }
  64579. declare module BABYLON {
  64580. /**
  64581. * @hidden
  64582. **/
  64583. export class _DepthCullingState {
  64584. private _isDepthTestDirty;
  64585. private _isDepthMaskDirty;
  64586. private _isDepthFuncDirty;
  64587. private _isCullFaceDirty;
  64588. private _isCullDirty;
  64589. private _isZOffsetDirty;
  64590. private _isFrontFaceDirty;
  64591. private _depthTest;
  64592. private _depthMask;
  64593. private _depthFunc;
  64594. private _cull;
  64595. private _cullFace;
  64596. private _zOffset;
  64597. private _frontFace;
  64598. /**
  64599. * Initializes the state.
  64600. */
  64601. constructor();
  64602. readonly isDirty: boolean;
  64603. zOffset: number;
  64604. cullFace: Nullable<number>;
  64605. cull: Nullable<boolean>;
  64606. depthFunc: Nullable<number>;
  64607. depthMask: boolean;
  64608. depthTest: boolean;
  64609. frontFace: Nullable<number>;
  64610. reset(): void;
  64611. apply(gl: WebGLRenderingContext): void;
  64612. }
  64613. }
  64614. declare module BABYLON {
  64615. /**
  64616. * @hidden
  64617. **/
  64618. export class _StencilState {
  64619. /** 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 */
  64620. static readonly ALWAYS: number;
  64621. /** Passed to stencilOperation to specify that stencil value must be kept */
  64622. static readonly KEEP: number;
  64623. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64624. static readonly REPLACE: number;
  64625. private _isStencilTestDirty;
  64626. private _isStencilMaskDirty;
  64627. private _isStencilFuncDirty;
  64628. private _isStencilOpDirty;
  64629. private _stencilTest;
  64630. private _stencilMask;
  64631. private _stencilFunc;
  64632. private _stencilFuncRef;
  64633. private _stencilFuncMask;
  64634. private _stencilOpStencilFail;
  64635. private _stencilOpDepthFail;
  64636. private _stencilOpStencilDepthPass;
  64637. readonly isDirty: boolean;
  64638. stencilFunc: number;
  64639. stencilFuncRef: number;
  64640. stencilFuncMask: number;
  64641. stencilOpStencilFail: number;
  64642. stencilOpDepthFail: number;
  64643. stencilOpStencilDepthPass: number;
  64644. stencilMask: number;
  64645. stencilTest: boolean;
  64646. constructor();
  64647. reset(): void;
  64648. apply(gl: WebGLRenderingContext): void;
  64649. }
  64650. }
  64651. declare module BABYLON {
  64652. /**
  64653. * @hidden
  64654. **/
  64655. export class _TimeToken {
  64656. _startTimeQuery: Nullable<WebGLQuery>;
  64657. _endTimeQuery: Nullable<WebGLQuery>;
  64658. _timeElapsedQuery: Nullable<WebGLQuery>;
  64659. _timeElapsedQueryEnded: boolean;
  64660. }
  64661. }
  64662. declare module BABYLON {
  64663. /**
  64664. * Internal interface used to track InternalTexture already bound to the GL context
  64665. */
  64666. export interface IInternalTextureTracker {
  64667. /**
  64668. * Gets or set the previous tracker in the list
  64669. */
  64670. previous: Nullable<IInternalTextureTracker>;
  64671. /**
  64672. * Gets or set the next tracker in the list
  64673. */
  64674. next: Nullable<IInternalTextureTracker>;
  64675. }
  64676. /**
  64677. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64678. */
  64679. export class DummyInternalTextureTracker {
  64680. /**
  64681. * Gets or set the previous tracker in the list
  64682. */
  64683. previous: Nullable<IInternalTextureTracker>;
  64684. /**
  64685. * Gets or set the next tracker in the list
  64686. */
  64687. next: Nullable<IInternalTextureTracker>;
  64688. }
  64689. }
  64690. declare module BABYLON {
  64691. /**
  64692. * Class used to store data associated with WebGL texture data for the engine
  64693. * This class should not be used directly
  64694. */
  64695. export class InternalTexture implements IInternalTextureTracker {
  64696. /** hidden */
  64697. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64698. /**
  64699. * The source of the texture data is unknown
  64700. */
  64701. static DATASOURCE_UNKNOWN: number;
  64702. /**
  64703. * Texture data comes from an URL
  64704. */
  64705. static DATASOURCE_URL: number;
  64706. /**
  64707. * Texture data is only used for temporary storage
  64708. */
  64709. static DATASOURCE_TEMP: number;
  64710. /**
  64711. * Texture data comes from raw data (ArrayBuffer)
  64712. */
  64713. static DATASOURCE_RAW: number;
  64714. /**
  64715. * Texture content is dynamic (video or dynamic texture)
  64716. */
  64717. static DATASOURCE_DYNAMIC: number;
  64718. /**
  64719. * Texture content is generated by rendering to it
  64720. */
  64721. static DATASOURCE_RENDERTARGET: number;
  64722. /**
  64723. * Texture content is part of a multi render target process
  64724. */
  64725. static DATASOURCE_MULTIRENDERTARGET: number;
  64726. /**
  64727. * Texture data comes from a cube data file
  64728. */
  64729. static DATASOURCE_CUBE: number;
  64730. /**
  64731. * Texture data comes from a raw cube data
  64732. */
  64733. static DATASOURCE_CUBERAW: number;
  64734. /**
  64735. * Texture data come from a prefiltered cube data file
  64736. */
  64737. static DATASOURCE_CUBEPREFILTERED: number;
  64738. /**
  64739. * Texture content is raw 3D data
  64740. */
  64741. static DATASOURCE_RAW3D: number;
  64742. /**
  64743. * Texture content is a depth texture
  64744. */
  64745. static DATASOURCE_DEPTHTEXTURE: number;
  64746. /**
  64747. * Texture data comes from a raw cube data encoded with RGBD
  64748. */
  64749. static DATASOURCE_CUBERAW_RGBD: number;
  64750. /**
  64751. * Defines if the texture is ready
  64752. */
  64753. isReady: boolean;
  64754. /**
  64755. * Defines if the texture is a cube texture
  64756. */
  64757. isCube: boolean;
  64758. /**
  64759. * Defines if the texture contains 3D data
  64760. */
  64761. is3D: boolean;
  64762. /**
  64763. * Gets the URL used to load this texture
  64764. */
  64765. url: string;
  64766. /**
  64767. * Gets the sampling mode of the texture
  64768. */
  64769. samplingMode: number;
  64770. /**
  64771. * Gets a boolean indicating if the texture needs mipmaps generation
  64772. */
  64773. generateMipMaps: boolean;
  64774. /**
  64775. * Gets the number of samples used by the texture (WebGL2+ only)
  64776. */
  64777. samples: number;
  64778. /**
  64779. * Gets the type of the texture (int, float...)
  64780. */
  64781. type: number;
  64782. /**
  64783. * Gets the format of the texture (RGB, RGBA...)
  64784. */
  64785. format: number;
  64786. /**
  64787. * Observable called when the texture is loaded
  64788. */
  64789. onLoadedObservable: Observable<InternalTexture>;
  64790. /**
  64791. * Gets the width of the texture
  64792. */
  64793. width: number;
  64794. /**
  64795. * Gets the height of the texture
  64796. */
  64797. height: number;
  64798. /**
  64799. * Gets the depth of the texture
  64800. */
  64801. depth: number;
  64802. /**
  64803. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64804. */
  64805. baseWidth: number;
  64806. /**
  64807. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64808. */
  64809. baseHeight: number;
  64810. /**
  64811. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64812. */
  64813. baseDepth: number;
  64814. /**
  64815. * Gets a boolean indicating if the texture is inverted on Y axis
  64816. */
  64817. invertY: boolean;
  64818. /**
  64819. * Gets or set the previous tracker in the list
  64820. */
  64821. previous: Nullable<IInternalTextureTracker>;
  64822. /**
  64823. * Gets or set the next tracker in the list
  64824. */
  64825. next: Nullable<IInternalTextureTracker>;
  64826. /** @hidden */
  64827. _invertVScale: boolean;
  64828. /** @hidden */
  64829. _initialSlot: number;
  64830. /** @hidden */
  64831. _designatedSlot: number;
  64832. /** @hidden */
  64833. _dataSource: number;
  64834. /** @hidden */
  64835. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64836. /** @hidden */
  64837. _bufferView: Nullable<ArrayBufferView>;
  64838. /** @hidden */
  64839. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64840. /** @hidden */
  64841. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64842. /** @hidden */
  64843. _size: number;
  64844. /** @hidden */
  64845. _extension: string;
  64846. /** @hidden */
  64847. _files: Nullable<string[]>;
  64848. /** @hidden */
  64849. _workingCanvas: HTMLCanvasElement;
  64850. /** @hidden */
  64851. _workingContext: CanvasRenderingContext2D;
  64852. /** @hidden */
  64853. _framebuffer: Nullable<WebGLFramebuffer>;
  64854. /** @hidden */
  64855. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64856. /** @hidden */
  64857. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64858. /** @hidden */
  64859. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64860. /** @hidden */
  64861. _attachments: Nullable<number[]>;
  64862. /** @hidden */
  64863. _cachedCoordinatesMode: Nullable<number>;
  64864. /** @hidden */
  64865. _cachedWrapU: Nullable<number>;
  64866. /** @hidden */
  64867. _cachedWrapV: Nullable<number>;
  64868. /** @hidden */
  64869. _cachedWrapR: Nullable<number>;
  64870. /** @hidden */
  64871. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64872. /** @hidden */
  64873. _isDisabled: boolean;
  64874. /** @hidden */
  64875. _compression: Nullable<string>;
  64876. /** @hidden */
  64877. _generateStencilBuffer: boolean;
  64878. /** @hidden */
  64879. _generateDepthBuffer: boolean;
  64880. /** @hidden */
  64881. _comparisonFunction: number;
  64882. /** @hidden */
  64883. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64884. /** @hidden */
  64885. _lodGenerationScale: number;
  64886. /** @hidden */
  64887. _lodGenerationOffset: number;
  64888. /** @hidden */
  64889. _lodTextureHigh: BaseTexture;
  64890. /** @hidden */
  64891. _lodTextureMid: BaseTexture;
  64892. /** @hidden */
  64893. _lodTextureLow: BaseTexture;
  64894. /** @hidden */
  64895. _isRGBD: boolean;
  64896. /** @hidden */
  64897. _webGLTexture: Nullable<WebGLTexture>;
  64898. /** @hidden */
  64899. _references: number;
  64900. private _engine;
  64901. /**
  64902. * Gets the Engine the texture belongs to.
  64903. * @returns The babylon engine
  64904. */
  64905. getEngine(): Engine;
  64906. /**
  64907. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64908. */
  64909. readonly dataSource: number;
  64910. /**
  64911. * Creates a new InternalTexture
  64912. * @param engine defines the engine to use
  64913. * @param dataSource defines the type of data that will be used
  64914. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64915. */
  64916. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64917. /**
  64918. * Increments the number of references (ie. the number of Texture that point to it)
  64919. */
  64920. incrementReferences(): void;
  64921. /**
  64922. * Change the size of the texture (not the size of the content)
  64923. * @param width defines the new width
  64924. * @param height defines the new height
  64925. * @param depth defines the new depth (1 by default)
  64926. */
  64927. updateSize(width: int, height: int, depth?: int): void;
  64928. /** @hidden */
  64929. _rebuild(): void;
  64930. /** @hidden */
  64931. _swapAndDie(target: InternalTexture): void;
  64932. /**
  64933. * Dispose the current allocated resources
  64934. */
  64935. dispose(): void;
  64936. }
  64937. }
  64938. declare module BABYLON {
  64939. /**
  64940. * This represents the main contract an easing function should follow.
  64941. * Easing functions are used throughout the animation system.
  64942. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64943. */
  64944. export interface IEasingFunction {
  64945. /**
  64946. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64947. * of the easing function.
  64948. * The link below provides some of the most common examples of easing functions.
  64949. * @see https://easings.net/
  64950. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64951. * @returns the corresponding value on the curve defined by the easing function
  64952. */
  64953. ease(gradient: number): number;
  64954. }
  64955. /**
  64956. * Base class used for every default easing function.
  64957. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64958. */
  64959. export class EasingFunction implements IEasingFunction {
  64960. /**
  64961. * Interpolation follows the mathematical formula associated with the easing function.
  64962. */
  64963. static readonly EASINGMODE_EASEIN: number;
  64964. /**
  64965. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64966. */
  64967. static readonly EASINGMODE_EASEOUT: number;
  64968. /**
  64969. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64970. */
  64971. static readonly EASINGMODE_EASEINOUT: number;
  64972. private _easingMode;
  64973. /**
  64974. * Sets the easing mode of the current function.
  64975. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64976. */
  64977. setEasingMode(easingMode: number): void;
  64978. /**
  64979. * Gets the current easing mode.
  64980. * @returns the easing mode
  64981. */
  64982. getEasingMode(): number;
  64983. /**
  64984. * @hidden
  64985. */
  64986. easeInCore(gradient: number): number;
  64987. /**
  64988. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64989. * of the easing function.
  64990. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64991. * @returns the corresponding value on the curve defined by the easing function
  64992. */
  64993. ease(gradient: number): number;
  64994. }
  64995. /**
  64996. * Easing function with a circle shape (see link below).
  64997. * @see https://easings.net/#easeInCirc
  64998. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64999. */
  65000. export class CircleEase extends EasingFunction implements IEasingFunction {
  65001. /** @hidden */
  65002. easeInCore(gradient: number): number;
  65003. }
  65004. /**
  65005. * Easing function with a ease back shape (see link below).
  65006. * @see https://easings.net/#easeInBack
  65007. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65008. */
  65009. export class BackEase extends EasingFunction implements IEasingFunction {
  65010. /** Defines the amplitude of the function */
  65011. amplitude: number;
  65012. /**
  65013. * Instantiates a back ease easing
  65014. * @see https://easings.net/#easeInBack
  65015. * @param amplitude Defines the amplitude of the function
  65016. */
  65017. constructor(
  65018. /** Defines the amplitude of the function */
  65019. amplitude?: number);
  65020. /** @hidden */
  65021. easeInCore(gradient: number): number;
  65022. }
  65023. /**
  65024. * Easing function with a bouncing shape (see link below).
  65025. * @see https://easings.net/#easeInBounce
  65026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65027. */
  65028. export class BounceEase extends EasingFunction implements IEasingFunction {
  65029. /** Defines the number of bounces */
  65030. bounces: number;
  65031. /** Defines the amplitude of the bounce */
  65032. bounciness: number;
  65033. /**
  65034. * Instantiates a bounce easing
  65035. * @see https://easings.net/#easeInBounce
  65036. * @param bounces Defines the number of bounces
  65037. * @param bounciness Defines the amplitude of the bounce
  65038. */
  65039. constructor(
  65040. /** Defines the number of bounces */
  65041. bounces?: number,
  65042. /** Defines the amplitude of the bounce */
  65043. bounciness?: number);
  65044. /** @hidden */
  65045. easeInCore(gradient: number): number;
  65046. }
  65047. /**
  65048. * Easing function with a power of 3 shape (see link below).
  65049. * @see https://easings.net/#easeInCubic
  65050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65051. */
  65052. export class CubicEase extends EasingFunction implements IEasingFunction {
  65053. /** @hidden */
  65054. easeInCore(gradient: number): number;
  65055. }
  65056. /**
  65057. * Easing function with an elastic shape (see link below).
  65058. * @see https://easings.net/#easeInElastic
  65059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65060. */
  65061. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65062. /** Defines the number of oscillations*/
  65063. oscillations: number;
  65064. /** Defines the amplitude of the oscillations*/
  65065. springiness: number;
  65066. /**
  65067. * Instantiates an elastic easing function
  65068. * @see https://easings.net/#easeInElastic
  65069. * @param oscillations Defines the number of oscillations
  65070. * @param springiness Defines the amplitude of the oscillations
  65071. */
  65072. constructor(
  65073. /** Defines the number of oscillations*/
  65074. oscillations?: number,
  65075. /** Defines the amplitude of the oscillations*/
  65076. springiness?: number);
  65077. /** @hidden */
  65078. easeInCore(gradient: number): number;
  65079. }
  65080. /**
  65081. * Easing function with an exponential shape (see link below).
  65082. * @see https://easings.net/#easeInExpo
  65083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65084. */
  65085. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65086. /** Defines the exponent of the function */
  65087. exponent: number;
  65088. /**
  65089. * Instantiates an exponential easing function
  65090. * @see https://easings.net/#easeInExpo
  65091. * @param exponent Defines the exponent of the function
  65092. */
  65093. constructor(
  65094. /** Defines the exponent of the function */
  65095. exponent?: number);
  65096. /** @hidden */
  65097. easeInCore(gradient: number): number;
  65098. }
  65099. /**
  65100. * Easing function with a power shape (see link below).
  65101. * @see https://easings.net/#easeInQuad
  65102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65103. */
  65104. export class PowerEase extends EasingFunction implements IEasingFunction {
  65105. /** Defines the power of the function */
  65106. power: number;
  65107. /**
  65108. * Instantiates an power base easing function
  65109. * @see https://easings.net/#easeInQuad
  65110. * @param power Defines the power of the function
  65111. */
  65112. constructor(
  65113. /** Defines the power of the function */
  65114. power?: number);
  65115. /** @hidden */
  65116. easeInCore(gradient: number): number;
  65117. }
  65118. /**
  65119. * Easing function with a power of 2 shape (see link below).
  65120. * @see https://easings.net/#easeInQuad
  65121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65122. */
  65123. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65124. /** @hidden */
  65125. easeInCore(gradient: number): number;
  65126. }
  65127. /**
  65128. * Easing function with a power of 4 shape (see link below).
  65129. * @see https://easings.net/#easeInQuart
  65130. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65131. */
  65132. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65133. /** @hidden */
  65134. easeInCore(gradient: number): number;
  65135. }
  65136. /**
  65137. * Easing function with a power of 5 shape (see link below).
  65138. * @see https://easings.net/#easeInQuint
  65139. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65140. */
  65141. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65142. /** @hidden */
  65143. easeInCore(gradient: number): number;
  65144. }
  65145. /**
  65146. * Easing function with a sin shape (see link below).
  65147. * @see https://easings.net/#easeInSine
  65148. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65149. */
  65150. export class SineEase extends EasingFunction implements IEasingFunction {
  65151. /** @hidden */
  65152. easeInCore(gradient: number): number;
  65153. }
  65154. /**
  65155. * Easing function with a bezier shape (see link below).
  65156. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65157. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65158. */
  65159. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65160. /** Defines the x component of the start tangent in the bezier curve */
  65161. x1: number;
  65162. /** Defines the y component of the start tangent in the bezier curve */
  65163. y1: number;
  65164. /** Defines the x component of the end tangent in the bezier curve */
  65165. x2: number;
  65166. /** Defines the y component of the end tangent in the bezier curve */
  65167. y2: number;
  65168. /**
  65169. * Instantiates a bezier function
  65170. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65171. * @param x1 Defines the x component of the start tangent in the bezier curve
  65172. * @param y1 Defines the y component of the start tangent in the bezier curve
  65173. * @param x2 Defines the x component of the end tangent in the bezier curve
  65174. * @param y2 Defines the y component of the end tangent in the bezier curve
  65175. */
  65176. constructor(
  65177. /** Defines the x component of the start tangent in the bezier curve */
  65178. x1?: number,
  65179. /** Defines the y component of the start tangent in the bezier curve */
  65180. y1?: number,
  65181. /** Defines the x component of the end tangent in the bezier curve */
  65182. x2?: number,
  65183. /** Defines the y component of the end tangent in the bezier curve */
  65184. y2?: number);
  65185. /** @hidden */
  65186. easeInCore(gradient: number): number;
  65187. }
  65188. }
  65189. declare module BABYLON {
  65190. /**
  65191. * Defines an interface which represents an animation key frame
  65192. */
  65193. export interface IAnimationKey {
  65194. /**
  65195. * Frame of the key frame
  65196. */
  65197. frame: number;
  65198. /**
  65199. * Value at the specifies key frame
  65200. */
  65201. value: any;
  65202. /**
  65203. * The input tangent for the cubic hermite spline
  65204. */
  65205. inTangent?: any;
  65206. /**
  65207. * The output tangent for the cubic hermite spline
  65208. */
  65209. outTangent?: any;
  65210. /**
  65211. * The animation interpolation type
  65212. */
  65213. interpolation?: AnimationKeyInterpolation;
  65214. }
  65215. /**
  65216. * Enum for the animation key frame interpolation type
  65217. */
  65218. export enum AnimationKeyInterpolation {
  65219. /**
  65220. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65221. */
  65222. STEP = 1
  65223. }
  65224. }
  65225. declare module BABYLON {
  65226. /**
  65227. * Represents the range of an animation
  65228. */
  65229. export class AnimationRange {
  65230. /**The name of the animation range**/
  65231. name: string;
  65232. /**The starting frame of the animation */
  65233. from: number;
  65234. /**The ending frame of the animation*/
  65235. to: number;
  65236. /**
  65237. * Initializes the range of an animation
  65238. * @param name The name of the animation range
  65239. * @param from The starting frame of the animation
  65240. * @param to The ending frame of the animation
  65241. */
  65242. constructor(
  65243. /**The name of the animation range**/
  65244. name: string,
  65245. /**The starting frame of the animation */
  65246. from: number,
  65247. /**The ending frame of the animation*/
  65248. to: number);
  65249. /**
  65250. * Makes a copy of the animation range
  65251. * @returns A copy of the animation range
  65252. */
  65253. clone(): AnimationRange;
  65254. }
  65255. }
  65256. declare module BABYLON {
  65257. /**
  65258. * Composed of a frame, and an action function
  65259. */
  65260. export class AnimationEvent {
  65261. /** The frame for which the event is triggered **/
  65262. frame: number;
  65263. /** The event to perform when triggered **/
  65264. action: (currentFrame: number) => void;
  65265. /** Specifies if the event should be triggered only once**/
  65266. onlyOnce?: boolean | undefined;
  65267. /**
  65268. * Specifies if the animation event is done
  65269. */
  65270. isDone: boolean;
  65271. /**
  65272. * Initializes the animation event
  65273. * @param frame The frame for which the event is triggered
  65274. * @param action The event to perform when triggered
  65275. * @param onlyOnce Specifies if the event should be triggered only once
  65276. */
  65277. constructor(
  65278. /** The frame for which the event is triggered **/
  65279. frame: number,
  65280. /** The event to perform when triggered **/
  65281. action: (currentFrame: number) => void,
  65282. /** Specifies if the event should be triggered only once**/
  65283. onlyOnce?: boolean | undefined);
  65284. /** @hidden */
  65285. _clone(): AnimationEvent;
  65286. }
  65287. }
  65288. declare module BABYLON {
  65289. /**
  65290. * Interface used to define a behavior
  65291. */
  65292. export interface Behavior<T> {
  65293. /** gets or sets behavior's name */
  65294. name: string;
  65295. /**
  65296. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65297. */
  65298. init(): void;
  65299. /**
  65300. * Called when the behavior is attached to a target
  65301. * @param target defines the target where the behavior is attached to
  65302. */
  65303. attach(target: T): void;
  65304. /**
  65305. * Called when the behavior is detached from its target
  65306. */
  65307. detach(): void;
  65308. }
  65309. /**
  65310. * Interface implemented by classes supporting behaviors
  65311. */
  65312. export interface IBehaviorAware<T> {
  65313. /**
  65314. * Attach a behavior
  65315. * @param behavior defines the behavior to attach
  65316. * @returns the current host
  65317. */
  65318. addBehavior(behavior: Behavior<T>): T;
  65319. /**
  65320. * Remove a behavior from the current object
  65321. * @param behavior defines the behavior to detach
  65322. * @returns the current host
  65323. */
  65324. removeBehavior(behavior: Behavior<T>): T;
  65325. /**
  65326. * Gets a behavior using its name to search
  65327. * @param name defines the name to search
  65328. * @returns the behavior or null if not found
  65329. */
  65330. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65331. }
  65332. }
  65333. declare module BABYLON {
  65334. /**
  65335. * @hidden
  65336. */
  65337. export class IntersectionInfo {
  65338. bu: Nullable<number>;
  65339. bv: Nullable<number>;
  65340. distance: number;
  65341. faceId: number;
  65342. subMeshId: number;
  65343. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65344. }
  65345. }
  65346. declare module BABYLON {
  65347. /**
  65348. * Class used to store bounding sphere information
  65349. */
  65350. export class BoundingSphere {
  65351. /**
  65352. * Gets the center of the bounding sphere in local space
  65353. */
  65354. readonly center: Vector3;
  65355. /**
  65356. * Radius of the bounding sphere in local space
  65357. */
  65358. radius: number;
  65359. /**
  65360. * Gets the center of the bounding sphere in world space
  65361. */
  65362. readonly centerWorld: Vector3;
  65363. /**
  65364. * Radius of the bounding sphere in world space
  65365. */
  65366. radiusWorld: number;
  65367. /**
  65368. * Gets the minimum vector in local space
  65369. */
  65370. readonly minimum: Vector3;
  65371. /**
  65372. * Gets the maximum vector in local space
  65373. */
  65374. readonly maximum: Vector3;
  65375. private _worldMatrix;
  65376. private static readonly TmpVector3;
  65377. /**
  65378. * Creates a new bounding sphere
  65379. * @param min defines the minimum vector (in local space)
  65380. * @param max defines the maximum vector (in local space)
  65381. * @param worldMatrix defines the new world matrix
  65382. */
  65383. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65384. /**
  65385. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65386. * @param min defines the new minimum vector (in local space)
  65387. * @param max defines the new maximum vector (in local space)
  65388. * @param worldMatrix defines the new world matrix
  65389. */
  65390. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65391. /**
  65392. * Scale the current bounding sphere by applying a scale factor
  65393. * @param factor defines the scale factor to apply
  65394. * @returns the current bounding box
  65395. */
  65396. scale(factor: number): BoundingSphere;
  65397. /**
  65398. * Gets the world matrix of the bounding box
  65399. * @returns a matrix
  65400. */
  65401. getWorldMatrix(): DeepImmutable<Matrix>;
  65402. /** @hidden */
  65403. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65404. /**
  65405. * Tests if the bounding sphere is intersecting the frustum planes
  65406. * @param frustumPlanes defines the frustum planes to test
  65407. * @returns true if there is an intersection
  65408. */
  65409. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65410. /**
  65411. * Tests if the bounding sphere center is in between the frustum planes.
  65412. * Used for optimistic fast inclusion.
  65413. * @param frustumPlanes defines the frustum planes to test
  65414. * @returns true if the sphere center is in between the frustum planes
  65415. */
  65416. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65417. /**
  65418. * Tests if a point is inside the bounding sphere
  65419. * @param point defines the point to test
  65420. * @returns true if the point is inside the bounding sphere
  65421. */
  65422. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65423. /**
  65424. * Checks if two sphere intersct
  65425. * @param sphere0 sphere 0
  65426. * @param sphere1 sphere 1
  65427. * @returns true if the speres intersect
  65428. */
  65429. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65430. }
  65431. }
  65432. declare module BABYLON {
  65433. /**
  65434. * Class used to store bounding box information
  65435. */
  65436. export class BoundingBox implements ICullable {
  65437. /**
  65438. * Gets the 8 vectors representing the bounding box in local space
  65439. */
  65440. readonly vectors: Vector3[];
  65441. /**
  65442. * Gets the center of the bounding box in local space
  65443. */
  65444. readonly center: Vector3;
  65445. /**
  65446. * Gets the center of the bounding box in world space
  65447. */
  65448. readonly centerWorld: Vector3;
  65449. /**
  65450. * Gets the extend size in local space
  65451. */
  65452. readonly extendSize: Vector3;
  65453. /**
  65454. * Gets the extend size in world space
  65455. */
  65456. readonly extendSizeWorld: Vector3;
  65457. /**
  65458. * Gets the OBB (object bounding box) directions
  65459. */
  65460. readonly directions: Vector3[];
  65461. /**
  65462. * Gets the 8 vectors representing the bounding box in world space
  65463. */
  65464. readonly vectorsWorld: Vector3[];
  65465. /**
  65466. * Gets the minimum vector in world space
  65467. */
  65468. readonly minimumWorld: Vector3;
  65469. /**
  65470. * Gets the maximum vector in world space
  65471. */
  65472. readonly maximumWorld: Vector3;
  65473. /**
  65474. * Gets the minimum vector in local space
  65475. */
  65476. readonly minimum: Vector3;
  65477. /**
  65478. * Gets the maximum vector in local space
  65479. */
  65480. readonly maximum: Vector3;
  65481. private _worldMatrix;
  65482. private static readonly TmpVector3;
  65483. /**
  65484. * @hidden
  65485. */
  65486. _tag: number;
  65487. /**
  65488. * Creates a new bounding box
  65489. * @param min defines the minimum vector (in local space)
  65490. * @param max defines the maximum vector (in local space)
  65491. * @param worldMatrix defines the new world matrix
  65492. */
  65493. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65494. /**
  65495. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65496. * @param min defines the new minimum vector (in local space)
  65497. * @param max defines the new maximum vector (in local space)
  65498. * @param worldMatrix defines the new world matrix
  65499. */
  65500. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65501. /**
  65502. * Scale the current bounding box by applying a scale factor
  65503. * @param factor defines the scale factor to apply
  65504. * @returns the current bounding box
  65505. */
  65506. scale(factor: number): BoundingBox;
  65507. /**
  65508. * Gets the world matrix of the bounding box
  65509. * @returns a matrix
  65510. */
  65511. getWorldMatrix(): DeepImmutable<Matrix>;
  65512. /** @hidden */
  65513. _update(world: DeepImmutable<Matrix>): void;
  65514. /**
  65515. * Tests if the bounding box is intersecting the frustum planes
  65516. * @param frustumPlanes defines the frustum planes to test
  65517. * @returns true if there is an intersection
  65518. */
  65519. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65520. /**
  65521. * Tests if the bounding box is entirely inside the frustum planes
  65522. * @param frustumPlanes defines the frustum planes to test
  65523. * @returns true if there is an inclusion
  65524. */
  65525. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65526. /**
  65527. * Tests if a point is inside the bounding box
  65528. * @param point defines the point to test
  65529. * @returns true if the point is inside the bounding box
  65530. */
  65531. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65532. /**
  65533. * Tests if the bounding box intersects with a bounding sphere
  65534. * @param sphere defines the sphere to test
  65535. * @returns true if there is an intersection
  65536. */
  65537. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65538. /**
  65539. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65540. * @param min defines the min vector to use
  65541. * @param max defines the max vector to use
  65542. * @returns true if there is an intersection
  65543. */
  65544. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65545. /**
  65546. * Tests if two bounding boxes are intersections
  65547. * @param box0 defines the first box to test
  65548. * @param box1 defines the second box to test
  65549. * @returns true if there is an intersection
  65550. */
  65551. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65552. /**
  65553. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65554. * @param minPoint defines the minimum vector of the bounding box
  65555. * @param maxPoint defines the maximum vector of the bounding box
  65556. * @param sphereCenter defines the sphere center
  65557. * @param sphereRadius defines the sphere radius
  65558. * @returns true if there is an intersection
  65559. */
  65560. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65561. /**
  65562. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65563. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65564. * @param frustumPlanes defines the frustum planes to test
  65565. * @return true if there is an inclusion
  65566. */
  65567. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65568. /**
  65569. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65570. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65571. * @param frustumPlanes defines the frustum planes to test
  65572. * @return true if there is an intersection
  65573. */
  65574. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65575. }
  65576. }
  65577. declare module BABYLON {
  65578. /** @hidden */
  65579. export class Collider {
  65580. /** Define if a collision was found */
  65581. collisionFound: boolean;
  65582. /**
  65583. * Define last intersection point in local space
  65584. */
  65585. intersectionPoint: Vector3;
  65586. /**
  65587. * Define last collided mesh
  65588. */
  65589. collidedMesh: Nullable<AbstractMesh>;
  65590. private _collisionPoint;
  65591. private _planeIntersectionPoint;
  65592. private _tempVector;
  65593. private _tempVector2;
  65594. private _tempVector3;
  65595. private _tempVector4;
  65596. private _edge;
  65597. private _baseToVertex;
  65598. private _destinationPoint;
  65599. private _slidePlaneNormal;
  65600. private _displacementVector;
  65601. /** @hidden */
  65602. _radius: Vector3;
  65603. /** @hidden */
  65604. _retry: number;
  65605. private _velocity;
  65606. private _basePoint;
  65607. private _epsilon;
  65608. /** @hidden */
  65609. _velocityWorldLength: number;
  65610. /** @hidden */
  65611. _basePointWorld: Vector3;
  65612. private _velocityWorld;
  65613. private _normalizedVelocity;
  65614. /** @hidden */
  65615. _initialVelocity: Vector3;
  65616. /** @hidden */
  65617. _initialPosition: Vector3;
  65618. private _nearestDistance;
  65619. private _collisionMask;
  65620. collisionMask: number;
  65621. /**
  65622. * Gets the plane normal used to compute the sliding response (in local space)
  65623. */
  65624. readonly slidePlaneNormal: Vector3;
  65625. /** @hidden */
  65626. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65627. /** @hidden */
  65628. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65629. /** @hidden */
  65630. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65631. /** @hidden */
  65632. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65633. /** @hidden */
  65634. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65635. /** @hidden */
  65636. _getResponse(pos: Vector3, vel: Vector3): void;
  65637. }
  65638. }
  65639. declare module BABYLON {
  65640. /**
  65641. * Interface for cullable objects
  65642. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65643. */
  65644. export interface ICullable {
  65645. /**
  65646. * Checks if the object or part of the object is in the frustum
  65647. * @param frustumPlanes Camera near/planes
  65648. * @returns true if the object is in frustum otherwise false
  65649. */
  65650. isInFrustum(frustumPlanes: Plane[]): boolean;
  65651. /**
  65652. * Checks if a cullable object (mesh...) is in the camera frustum
  65653. * Unlike isInFrustum this cheks the full bounding box
  65654. * @param frustumPlanes Camera near/planes
  65655. * @returns true if the object is in frustum otherwise false
  65656. */
  65657. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65658. }
  65659. /**
  65660. * Info for a bounding data of a mesh
  65661. */
  65662. export class BoundingInfo implements ICullable {
  65663. /**
  65664. * Bounding box for the mesh
  65665. */
  65666. readonly boundingBox: BoundingBox;
  65667. /**
  65668. * Bounding sphere for the mesh
  65669. */
  65670. readonly boundingSphere: BoundingSphere;
  65671. private _isLocked;
  65672. private static readonly TmpVector3;
  65673. /**
  65674. * Constructs bounding info
  65675. * @param minimum min vector of the bounding box/sphere
  65676. * @param maximum max vector of the bounding box/sphere
  65677. * @param worldMatrix defines the new world matrix
  65678. */
  65679. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65680. /**
  65681. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65682. * @param min defines the new minimum vector (in local space)
  65683. * @param max defines the new maximum vector (in local space)
  65684. * @param worldMatrix defines the new world matrix
  65685. */
  65686. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65687. /**
  65688. * min vector of the bounding box/sphere
  65689. */
  65690. readonly minimum: Vector3;
  65691. /**
  65692. * max vector of the bounding box/sphere
  65693. */
  65694. readonly maximum: Vector3;
  65695. /**
  65696. * If the info is locked and won't be updated to avoid perf overhead
  65697. */
  65698. isLocked: boolean;
  65699. /**
  65700. * Updates the bounding sphere and box
  65701. * @param world world matrix to be used to update
  65702. */
  65703. update(world: DeepImmutable<Matrix>): void;
  65704. /**
  65705. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65706. * @param center New center of the bounding info
  65707. * @param extend New extend of the bounding info
  65708. * @returns the current bounding info
  65709. */
  65710. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65711. /**
  65712. * Scale the current bounding info by applying a scale factor
  65713. * @param factor defines the scale factor to apply
  65714. * @returns the current bounding info
  65715. */
  65716. scale(factor: number): BoundingInfo;
  65717. /**
  65718. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65719. * @param frustumPlanes defines the frustum to test
  65720. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65721. * @returns true if the bounding info is in the frustum planes
  65722. */
  65723. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65724. /**
  65725. * Gets the world distance between the min and max points of the bounding box
  65726. */
  65727. readonly diagonalLength: number;
  65728. /**
  65729. * Checks if a cullable object (mesh...) is in the camera frustum
  65730. * Unlike isInFrustum this cheks the full bounding box
  65731. * @param frustumPlanes Camera near/planes
  65732. * @returns true if the object is in frustum otherwise false
  65733. */
  65734. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65735. /** @hidden */
  65736. _checkCollision(collider: Collider): boolean;
  65737. /**
  65738. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65739. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65740. * @param point the point to check intersection with
  65741. * @returns if the point intersects
  65742. */
  65743. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65744. /**
  65745. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65746. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65747. * @param boundingInfo the bounding info to check intersection with
  65748. * @param precise if the intersection should be done using OBB
  65749. * @returns if the bounding info intersects
  65750. */
  65751. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65752. }
  65753. }
  65754. declare module BABYLON {
  65755. /**
  65756. * Defines an array and its length.
  65757. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65758. */
  65759. export interface ISmartArrayLike<T> {
  65760. /**
  65761. * The data of the array.
  65762. */
  65763. data: Array<T>;
  65764. /**
  65765. * The active length of the array.
  65766. */
  65767. length: number;
  65768. }
  65769. /**
  65770. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65771. */
  65772. export class SmartArray<T> implements ISmartArrayLike<T> {
  65773. /**
  65774. * The full set of data from the array.
  65775. */
  65776. data: Array<T>;
  65777. /**
  65778. * The active length of the array.
  65779. */
  65780. length: number;
  65781. protected _id: number;
  65782. /**
  65783. * Instantiates a Smart Array.
  65784. * @param capacity defines the default capacity of the array.
  65785. */
  65786. constructor(capacity: number);
  65787. /**
  65788. * Pushes a value at the end of the active data.
  65789. * @param value defines the object to push in the array.
  65790. */
  65791. push(value: T): void;
  65792. /**
  65793. * Iterates over the active data and apply the lambda to them.
  65794. * @param func defines the action to apply on each value.
  65795. */
  65796. forEach(func: (content: T) => void): void;
  65797. /**
  65798. * Sorts the full sets of data.
  65799. * @param compareFn defines the comparison function to apply.
  65800. */
  65801. sort(compareFn: (a: T, b: T) => number): void;
  65802. /**
  65803. * Resets the active data to an empty array.
  65804. */
  65805. reset(): void;
  65806. /**
  65807. * Releases all the data from the array as well as the array.
  65808. */
  65809. dispose(): void;
  65810. /**
  65811. * Concats the active data with a given array.
  65812. * @param array defines the data to concatenate with.
  65813. */
  65814. concat(array: any): void;
  65815. /**
  65816. * Returns the position of a value in the active data.
  65817. * @param value defines the value to find the index for
  65818. * @returns the index if found in the active data otherwise -1
  65819. */
  65820. indexOf(value: T): number;
  65821. /**
  65822. * Returns whether an element is part of the active data.
  65823. * @param value defines the value to look for
  65824. * @returns true if found in the active data otherwise false
  65825. */
  65826. contains(value: T): boolean;
  65827. private static _GlobalId;
  65828. }
  65829. /**
  65830. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65831. * The data in this array can only be present once
  65832. */
  65833. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65834. private _duplicateId;
  65835. /**
  65836. * Pushes a value at the end of the active data.
  65837. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65838. * @param value defines the object to push in the array.
  65839. */
  65840. push(value: T): void;
  65841. /**
  65842. * Pushes a value at the end of the active data.
  65843. * If the data is already present, it won t be added again
  65844. * @param value defines the object to push in the array.
  65845. * @returns true if added false if it was already present
  65846. */
  65847. pushNoDuplicate(value: T): boolean;
  65848. /**
  65849. * Resets the active data to an empty array.
  65850. */
  65851. reset(): void;
  65852. /**
  65853. * Concats the active data with a given array.
  65854. * This ensures no dupplicate will be present in the result.
  65855. * @param array defines the data to concatenate with.
  65856. */
  65857. concatWithNoDuplicate(array: any): void;
  65858. }
  65859. }
  65860. declare module BABYLON {
  65861. /**
  65862. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65863. * separate meshes. This can be use to improve performances.
  65864. * @see http://doc.babylonjs.com/how_to/multi_materials
  65865. */
  65866. export class MultiMaterial extends Material {
  65867. private _subMaterials;
  65868. /**
  65869. * Gets or Sets the list of Materials used within the multi material.
  65870. * They need to be ordered according to the submeshes order in the associated mesh
  65871. */
  65872. subMaterials: Nullable<Material>[];
  65873. /**
  65874. * Function used to align with Node.getChildren()
  65875. * @returns the list of Materials used within the multi material
  65876. */
  65877. getChildren(): Nullable<Material>[];
  65878. /**
  65879. * Instantiates a new Multi Material
  65880. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65881. * separate meshes. This can be use to improve performances.
  65882. * @see http://doc.babylonjs.com/how_to/multi_materials
  65883. * @param name Define the name in the scene
  65884. * @param scene Define the scene the material belongs to
  65885. */
  65886. constructor(name: string, scene: Scene);
  65887. private _hookArray;
  65888. /**
  65889. * Get one of the submaterial by its index in the submaterials array
  65890. * @param index The index to look the sub material at
  65891. * @returns The Material if the index has been defined
  65892. */
  65893. getSubMaterial(index: number): Nullable<Material>;
  65894. /**
  65895. * Get the list of active textures for the whole sub materials list.
  65896. * @returns All the textures that will be used during the rendering
  65897. */
  65898. getActiveTextures(): BaseTexture[];
  65899. /**
  65900. * Gets the current class name of the material e.g. "MultiMaterial"
  65901. * Mainly use in serialization.
  65902. * @returns the class name
  65903. */
  65904. getClassName(): string;
  65905. /**
  65906. * Checks if the material is ready to render the requested sub mesh
  65907. * @param mesh Define the mesh the submesh belongs to
  65908. * @param subMesh Define the sub mesh to look readyness for
  65909. * @param useInstances Define whether or not the material is used with instances
  65910. * @returns true if ready, otherwise false
  65911. */
  65912. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65913. /**
  65914. * Clones the current material and its related sub materials
  65915. * @param name Define the name of the newly cloned material
  65916. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65917. * @returns the cloned material
  65918. */
  65919. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65920. /**
  65921. * Serializes the materials into a JSON representation.
  65922. * @returns the JSON representation
  65923. */
  65924. serialize(): any;
  65925. /**
  65926. * Dispose the material and release its associated resources
  65927. * @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)
  65928. * @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)
  65929. * @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)
  65930. */
  65931. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65932. /**
  65933. * Creates a MultiMaterial from parsed MultiMaterial data.
  65934. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65935. * @param scene defines the hosting scene
  65936. * @returns a new MultiMaterial
  65937. */
  65938. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65939. }
  65940. }
  65941. declare module BABYLON {
  65942. /**
  65943. * Class used to represent data loading progression
  65944. */
  65945. export class SceneLoaderFlags {
  65946. private static _ForceFullSceneLoadingForIncremental;
  65947. private static _ShowLoadingScreen;
  65948. private static _CleanBoneMatrixWeights;
  65949. private static _loggingLevel;
  65950. /**
  65951. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65952. */
  65953. static ForceFullSceneLoadingForIncremental: boolean;
  65954. /**
  65955. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65956. */
  65957. static ShowLoadingScreen: boolean;
  65958. /**
  65959. * Defines the current logging level (while loading the scene)
  65960. * @ignorenaming
  65961. */
  65962. static loggingLevel: number;
  65963. /**
  65964. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65965. */
  65966. static CleanBoneMatrixWeights: boolean;
  65967. }
  65968. }
  65969. declare module BABYLON {
  65970. /**
  65971. * 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.
  65972. * @see https://doc.babylonjs.com/how_to/transformnode
  65973. */
  65974. export class TransformNode extends Node {
  65975. /**
  65976. * Object will not rotate to face the camera
  65977. */
  65978. static BILLBOARDMODE_NONE: number;
  65979. /**
  65980. * Object will rotate to face the camera but only on the x axis
  65981. */
  65982. static BILLBOARDMODE_X: number;
  65983. /**
  65984. * Object will rotate to face the camera but only on the y axis
  65985. */
  65986. static BILLBOARDMODE_Y: number;
  65987. /**
  65988. * Object will rotate to face the camera but only on the z axis
  65989. */
  65990. static BILLBOARDMODE_Z: number;
  65991. /**
  65992. * Object will rotate to face the camera
  65993. */
  65994. static BILLBOARDMODE_ALL: number;
  65995. private _forward;
  65996. private _forwardInverted;
  65997. private _up;
  65998. private _right;
  65999. private _rightInverted;
  66000. private _position;
  66001. private _rotation;
  66002. private _rotationQuaternion;
  66003. protected _scaling: Vector3;
  66004. protected _isDirty: boolean;
  66005. private _transformToBoneReferal;
  66006. /**
  66007. * Set the billboard mode. Default is 0.
  66008. *
  66009. * | Value | Type | Description |
  66010. * | --- | --- | --- |
  66011. * | 0 | BILLBOARDMODE_NONE | |
  66012. * | 1 | BILLBOARDMODE_X | |
  66013. * | 2 | BILLBOARDMODE_Y | |
  66014. * | 4 | BILLBOARDMODE_Z | |
  66015. * | 7 | BILLBOARDMODE_ALL | |
  66016. *
  66017. */
  66018. billboardMode: number;
  66019. /**
  66020. * 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
  66021. */
  66022. scalingDeterminant: number;
  66023. /**
  66024. * Sets the distance of the object to max, often used by skybox
  66025. */
  66026. infiniteDistance: boolean;
  66027. /**
  66028. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66029. * By default the system will update normals to compensate
  66030. */
  66031. ignoreNonUniformScaling: boolean;
  66032. /** @hidden */
  66033. _poseMatrix: Matrix;
  66034. /** @hidden */
  66035. _localMatrix: Matrix;
  66036. private _absolutePosition;
  66037. private _pivotMatrix;
  66038. private _pivotMatrixInverse;
  66039. protected _postMultiplyPivotMatrix: boolean;
  66040. private _tempMatrix;
  66041. private _tempMatrix2;
  66042. protected _isWorldMatrixFrozen: boolean;
  66043. /** @hidden */
  66044. _indexInSceneTransformNodesArray: number;
  66045. /**
  66046. * An event triggered after the world matrix is updated
  66047. */
  66048. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66049. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66050. /**
  66051. * Gets a string identifying the name of the class
  66052. * @returns "TransformNode" string
  66053. */
  66054. getClassName(): string;
  66055. /**
  66056. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66057. */
  66058. position: Vector3;
  66059. /**
  66060. * 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)).
  66061. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66062. */
  66063. rotation: Vector3;
  66064. /**
  66065. * 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)).
  66066. */
  66067. scaling: Vector3;
  66068. /**
  66069. * 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).
  66070. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66071. */
  66072. rotationQuaternion: Nullable<Quaternion>;
  66073. /**
  66074. * The forward direction of that transform in world space.
  66075. */
  66076. readonly forward: Vector3;
  66077. /**
  66078. * The up direction of that transform in world space.
  66079. */
  66080. readonly up: Vector3;
  66081. /**
  66082. * The right direction of that transform in world space.
  66083. */
  66084. readonly right: Vector3;
  66085. /**
  66086. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66087. * @param matrix the matrix to copy the pose from
  66088. * @returns this TransformNode.
  66089. */
  66090. updatePoseMatrix(matrix: Matrix): TransformNode;
  66091. /**
  66092. * Returns the mesh Pose matrix.
  66093. * @returns the pose matrix
  66094. */
  66095. getPoseMatrix(): Matrix;
  66096. /** @hidden */
  66097. _isSynchronized(): boolean;
  66098. /** @hidden */
  66099. _initCache(): void;
  66100. /**
  66101. * Flag the transform node as dirty (Forcing it to update everything)
  66102. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66103. * @returns this transform node
  66104. */
  66105. markAsDirty(property: string): TransformNode;
  66106. /**
  66107. * Returns the current mesh absolute position.
  66108. * Returns a Vector3.
  66109. */
  66110. readonly absolutePosition: Vector3;
  66111. /**
  66112. * Sets a new matrix to apply before all other transformation
  66113. * @param matrix defines the transform matrix
  66114. * @returns the current TransformNode
  66115. */
  66116. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66117. /**
  66118. * Sets a new pivot matrix to the current node
  66119. * @param matrix defines the new pivot matrix to use
  66120. * @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
  66121. * @returns the current TransformNode
  66122. */
  66123. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66124. /**
  66125. * Returns the mesh pivot matrix.
  66126. * Default : Identity.
  66127. * @returns the matrix
  66128. */
  66129. getPivotMatrix(): Matrix;
  66130. /**
  66131. * Prevents the World matrix to be computed any longer.
  66132. * @returns the TransformNode.
  66133. */
  66134. freezeWorldMatrix(): TransformNode;
  66135. /**
  66136. * Allows back the World matrix computation.
  66137. * @returns the TransformNode.
  66138. */
  66139. unfreezeWorldMatrix(): this;
  66140. /**
  66141. * True if the World matrix has been frozen.
  66142. */
  66143. readonly isWorldMatrixFrozen: boolean;
  66144. /**
  66145. * Retuns the mesh absolute position in the World.
  66146. * @returns a Vector3.
  66147. */
  66148. getAbsolutePosition(): Vector3;
  66149. /**
  66150. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66151. * @param absolutePosition the absolute position to set
  66152. * @returns the TransformNode.
  66153. */
  66154. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66155. /**
  66156. * Sets the mesh position in its local space.
  66157. * @param vector3 the position to set in localspace
  66158. * @returns the TransformNode.
  66159. */
  66160. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66161. /**
  66162. * Returns the mesh position in the local space from the current World matrix values.
  66163. * @returns a new Vector3.
  66164. */
  66165. getPositionExpressedInLocalSpace(): Vector3;
  66166. /**
  66167. * Translates the mesh along the passed Vector3 in its local space.
  66168. * @param vector3 the distance to translate in localspace
  66169. * @returns the TransformNode.
  66170. */
  66171. locallyTranslate(vector3: Vector3): TransformNode;
  66172. private static _lookAtVectorCache;
  66173. /**
  66174. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66175. * @param targetPoint the position (must be in same space as current mesh) to look at
  66176. * @param yawCor optional yaw (y-axis) correction in radians
  66177. * @param pitchCor optional pitch (x-axis) correction in radians
  66178. * @param rollCor optional roll (z-axis) correction in radians
  66179. * @param space the choosen space of the target
  66180. * @returns the TransformNode.
  66181. */
  66182. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66183. /**
  66184. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66185. * This Vector3 is expressed in the World space.
  66186. * @param localAxis axis to rotate
  66187. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66188. */
  66189. getDirection(localAxis: Vector3): Vector3;
  66190. /**
  66191. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66192. * localAxis is expressed in the mesh local space.
  66193. * result is computed in the Wordl space from the mesh World matrix.
  66194. * @param localAxis axis to rotate
  66195. * @param result the resulting transformnode
  66196. * @returns this TransformNode.
  66197. */
  66198. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66199. /**
  66200. * Sets this transform node rotation to the given local axis.
  66201. * @param localAxis the axis in local space
  66202. * @param yawCor optional yaw (y-axis) correction in radians
  66203. * @param pitchCor optional pitch (x-axis) correction in radians
  66204. * @param rollCor optional roll (z-axis) correction in radians
  66205. * @returns this TransformNode
  66206. */
  66207. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66208. /**
  66209. * Sets a new pivot point to the current node
  66210. * @param point defines the new pivot point to use
  66211. * @param space defines if the point is in world or local space (local by default)
  66212. * @returns the current TransformNode
  66213. */
  66214. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66215. /**
  66216. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66217. * @returns the pivot point
  66218. */
  66219. getPivotPoint(): Vector3;
  66220. /**
  66221. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66222. * @param result the vector3 to store the result
  66223. * @returns this TransformNode.
  66224. */
  66225. getPivotPointToRef(result: Vector3): TransformNode;
  66226. /**
  66227. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66228. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66229. */
  66230. getAbsolutePivotPoint(): Vector3;
  66231. /**
  66232. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66233. * @param result vector3 to store the result
  66234. * @returns this TransformNode.
  66235. */
  66236. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66237. /**
  66238. * Defines the passed node as the parent of the current node.
  66239. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66240. * @see https://doc.babylonjs.com/how_to/parenting
  66241. * @param node the node ot set as the parent
  66242. * @returns this TransformNode.
  66243. */
  66244. setParent(node: Nullable<Node>): TransformNode;
  66245. private _nonUniformScaling;
  66246. /**
  66247. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66248. */
  66249. readonly nonUniformScaling: boolean;
  66250. /** @hidden */
  66251. _updateNonUniformScalingState(value: boolean): boolean;
  66252. /**
  66253. * Attach the current TransformNode to another TransformNode associated with a bone
  66254. * @param bone Bone affecting the TransformNode
  66255. * @param affectedTransformNode TransformNode associated with the bone
  66256. * @returns this object
  66257. */
  66258. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66259. /**
  66260. * Detach the transform node if its associated with a bone
  66261. * @returns this object
  66262. */
  66263. detachFromBone(): TransformNode;
  66264. private static _rotationAxisCache;
  66265. /**
  66266. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66267. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66268. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66269. * The passed axis is also normalized.
  66270. * @param axis the axis to rotate around
  66271. * @param amount the amount to rotate in radians
  66272. * @param space Space to rotate in (Default: local)
  66273. * @returns the TransformNode.
  66274. */
  66275. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66276. /**
  66277. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66278. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66279. * The passed axis is also normalized. .
  66280. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66281. * @param point the point to rotate around
  66282. * @param axis the axis to rotate around
  66283. * @param amount the amount to rotate in radians
  66284. * @returns the TransformNode
  66285. */
  66286. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66287. /**
  66288. * Translates the mesh along the axis vector for the passed distance in the given space.
  66289. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66290. * @param axis the axis to translate in
  66291. * @param distance the distance to translate
  66292. * @param space Space to rotate in (Default: local)
  66293. * @returns the TransformNode.
  66294. */
  66295. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66296. /**
  66297. * Adds a rotation step to the mesh current rotation.
  66298. * x, y, z are Euler angles expressed in radians.
  66299. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66300. * This means this rotation is made in the mesh local space only.
  66301. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66302. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66303. * ```javascript
  66304. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66305. * ```
  66306. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66307. * 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.
  66308. * @param x Rotation to add
  66309. * @param y Rotation to add
  66310. * @param z Rotation to add
  66311. * @returns the TransformNode.
  66312. */
  66313. addRotation(x: number, y: number, z: number): TransformNode;
  66314. /**
  66315. * Computes the world matrix of the node
  66316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66317. * @returns the world matrix
  66318. */
  66319. computeWorldMatrix(force?: boolean): Matrix;
  66320. protected _afterComputeWorldMatrix(): void;
  66321. /**
  66322. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66323. * @param func callback function to add
  66324. *
  66325. * @returns the TransformNode.
  66326. */
  66327. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66328. /**
  66329. * Removes a registered callback function.
  66330. * @param func callback function to remove
  66331. * @returns the TransformNode.
  66332. */
  66333. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66334. /**
  66335. * Gets the position of the current mesh in camera space
  66336. * @param camera defines the camera to use
  66337. * @returns a position
  66338. */
  66339. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66340. /**
  66341. * Returns the distance from the mesh to the active camera
  66342. * @param camera defines the camera to use
  66343. * @returns the distance
  66344. */
  66345. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66346. /**
  66347. * Clone the current transform node
  66348. * @param name Name of the new clone
  66349. * @param newParent New parent for the clone
  66350. * @param doNotCloneChildren Do not clone children hierarchy
  66351. * @returns the new transform node
  66352. */
  66353. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66354. /**
  66355. * Serializes the objects information.
  66356. * @param currentSerializationObject defines the object to serialize in
  66357. * @returns the serialized object
  66358. */
  66359. serialize(currentSerializationObject?: any): any;
  66360. /**
  66361. * Returns a new TransformNode object parsed from the source provided.
  66362. * @param parsedTransformNode is the source.
  66363. * @param scene the scne the object belongs to
  66364. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66365. * @returns a new TransformNode object parsed from the source provided.
  66366. */
  66367. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66368. /**
  66369. * Get all child-transformNodes of this node
  66370. * @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
  66371. * @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
  66372. * @returns an array of TransformNode
  66373. */
  66374. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66375. /**
  66376. * Releases resources associated with this transform node.
  66377. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66378. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66379. */
  66380. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66381. }
  66382. }
  66383. declare module BABYLON {
  66384. /**
  66385. * Class used to override all child animations of a given target
  66386. */
  66387. export class AnimationPropertiesOverride {
  66388. /**
  66389. * Gets or sets a value indicating if animation blending must be used
  66390. */
  66391. enableBlending: boolean;
  66392. /**
  66393. * Gets or sets the blending speed to use when enableBlending is true
  66394. */
  66395. blendingSpeed: number;
  66396. /**
  66397. * Gets or sets the default loop mode to use
  66398. */
  66399. loopMode: number;
  66400. }
  66401. }
  66402. declare module BABYLON {
  66403. /**
  66404. * Class used to store bone information
  66405. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66406. */
  66407. export class Bone extends Node {
  66408. /**
  66409. * defines the bone name
  66410. */
  66411. name: string;
  66412. private static _tmpVecs;
  66413. private static _tmpQuat;
  66414. private static _tmpMats;
  66415. /**
  66416. * Gets the list of child bones
  66417. */
  66418. children: Bone[];
  66419. /** Gets the animations associated with this bone */
  66420. animations: Animation[];
  66421. /**
  66422. * Gets or sets bone length
  66423. */
  66424. length: number;
  66425. /**
  66426. * @hidden Internal only
  66427. * Set this value to map this bone to a different index in the transform matrices
  66428. * Set this value to -1 to exclude the bone from the transform matrices
  66429. */
  66430. _index: Nullable<number>;
  66431. private _skeleton;
  66432. private _localMatrix;
  66433. private _restPose;
  66434. private _baseMatrix;
  66435. private _absoluteTransform;
  66436. private _invertedAbsoluteTransform;
  66437. private _parent;
  66438. private _scalingDeterminant;
  66439. private _worldTransform;
  66440. private _localScaling;
  66441. private _localRotation;
  66442. private _localPosition;
  66443. private _needToDecompose;
  66444. private _needToCompose;
  66445. /** @hidden */
  66446. _linkedTransformNode: Nullable<TransformNode>;
  66447. /** @hidden */
  66448. /** @hidden */
  66449. _matrix: Matrix;
  66450. /**
  66451. * Create a new bone
  66452. * @param name defines the bone name
  66453. * @param skeleton defines the parent skeleton
  66454. * @param parentBone defines the parent (can be null if the bone is the root)
  66455. * @param localMatrix defines the local matrix
  66456. * @param restPose defines the rest pose matrix
  66457. * @param baseMatrix defines the base matrix
  66458. * @param index defines index of the bone in the hiearchy
  66459. */
  66460. constructor(
  66461. /**
  66462. * defines the bone name
  66463. */
  66464. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66465. /**
  66466. * Gets the current object class name.
  66467. * @return the class name
  66468. */
  66469. getClassName(): string;
  66470. /**
  66471. * Gets the parent skeleton
  66472. * @returns a skeleton
  66473. */
  66474. getSkeleton(): Skeleton;
  66475. /**
  66476. * Gets parent bone
  66477. * @returns a bone or null if the bone is the root of the bone hierarchy
  66478. */
  66479. getParent(): Nullable<Bone>;
  66480. /**
  66481. * Returns an array containing the root bones
  66482. * @returns an array containing the root bones
  66483. */
  66484. getChildren(): Array<Bone>;
  66485. /**
  66486. * Sets the parent bone
  66487. * @param parent defines the parent (can be null if the bone is the root)
  66488. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66489. */
  66490. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66491. /**
  66492. * Gets the local matrix
  66493. * @returns a matrix
  66494. */
  66495. getLocalMatrix(): Matrix;
  66496. /**
  66497. * Gets the base matrix (initial matrix which remains unchanged)
  66498. * @returns a matrix
  66499. */
  66500. getBaseMatrix(): Matrix;
  66501. /**
  66502. * Gets the rest pose matrix
  66503. * @returns a matrix
  66504. */
  66505. getRestPose(): Matrix;
  66506. /**
  66507. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66508. */
  66509. getWorldMatrix(): Matrix;
  66510. /**
  66511. * Sets the local matrix to rest pose matrix
  66512. */
  66513. returnToRest(): void;
  66514. /**
  66515. * Gets the inverse of the absolute transform matrix.
  66516. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66517. * @returns a matrix
  66518. */
  66519. getInvertedAbsoluteTransform(): Matrix;
  66520. /**
  66521. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66522. * @returns a matrix
  66523. */
  66524. getAbsoluteTransform(): Matrix;
  66525. /**
  66526. * Links with the given transform node.
  66527. * The local matrix of this bone is copied from the transform node every frame.
  66528. * @param transformNode defines the transform node to link to
  66529. */
  66530. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66531. /** Gets or sets current position (in local space) */
  66532. position: Vector3;
  66533. /** Gets or sets current rotation (in local space) */
  66534. rotation: Vector3;
  66535. /** Gets or sets current rotation quaternion (in local space) */
  66536. rotationQuaternion: Quaternion;
  66537. /** Gets or sets current scaling (in local space) */
  66538. scaling: Vector3;
  66539. /**
  66540. * Gets the animation properties override
  66541. */
  66542. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66543. private _decompose;
  66544. private _compose;
  66545. /**
  66546. * Update the base and local matrices
  66547. * @param matrix defines the new base or local matrix
  66548. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66549. * @param updateLocalMatrix defines if the local matrix should be updated
  66550. */
  66551. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66552. /** @hidden */
  66553. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66554. /**
  66555. * Flag the bone as dirty (Forcing it to update everything)
  66556. */
  66557. markAsDirty(): void;
  66558. private _markAsDirtyAndCompose;
  66559. private _markAsDirtyAndDecompose;
  66560. /**
  66561. * Translate the bone in local or world space
  66562. * @param vec The amount to translate the bone
  66563. * @param space The space that the translation is in
  66564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66565. */
  66566. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66567. /**
  66568. * Set the postion of the bone in local or world space
  66569. * @param position The position to set the bone
  66570. * @param space The space that the position is in
  66571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66572. */
  66573. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66574. /**
  66575. * Set the absolute position of the bone (world space)
  66576. * @param position The position to set the bone
  66577. * @param mesh The mesh that this bone is attached to
  66578. */
  66579. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66580. /**
  66581. * Scale the bone on the x, y and z axes (in local space)
  66582. * @param x The amount to scale the bone on the x axis
  66583. * @param y The amount to scale the bone on the y axis
  66584. * @param z The amount to scale the bone on the z axis
  66585. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66586. */
  66587. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66588. /**
  66589. * Set the bone scaling in local space
  66590. * @param scale defines the scaling vector
  66591. */
  66592. setScale(scale: Vector3): void;
  66593. /**
  66594. * Gets the current scaling in local space
  66595. * @returns the current scaling vector
  66596. */
  66597. getScale(): Vector3;
  66598. /**
  66599. * Gets the current scaling in local space and stores it in a target vector
  66600. * @param result defines the target vector
  66601. */
  66602. getScaleToRef(result: Vector3): void;
  66603. /**
  66604. * Set the yaw, pitch, and roll of the bone in local or world space
  66605. * @param yaw The rotation of the bone on the y axis
  66606. * @param pitch The rotation of the bone on the x axis
  66607. * @param roll The rotation of the bone on the z axis
  66608. * @param space The space that the axes of rotation are in
  66609. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66610. */
  66611. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66612. /**
  66613. * Add a rotation to the bone on an axis in local or world space
  66614. * @param axis The axis to rotate the bone on
  66615. * @param amount The amount to rotate the bone
  66616. * @param space The space that the axis is in
  66617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66618. */
  66619. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66620. /**
  66621. * Set the rotation of the bone to a particular axis angle in local or world space
  66622. * @param axis The axis to rotate the bone on
  66623. * @param angle The angle that the bone should be rotated to
  66624. * @param space The space that the axis is in
  66625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66626. */
  66627. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66628. /**
  66629. * Set the euler rotation of the bone in local of world space
  66630. * @param rotation The euler rotation that the bone should be set to
  66631. * @param space The space that the rotation is in
  66632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66633. */
  66634. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66635. /**
  66636. * Set the quaternion rotation of the bone in local of world space
  66637. * @param quat The quaternion rotation that the bone should be set to
  66638. * @param space The space that the rotation is in
  66639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66640. */
  66641. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66642. /**
  66643. * Set the rotation matrix of the bone in local of world space
  66644. * @param rotMat The rotation matrix that the bone should be set to
  66645. * @param space The space that the rotation is in
  66646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66647. */
  66648. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66649. private _rotateWithMatrix;
  66650. private _getNegativeRotationToRef;
  66651. /**
  66652. * Get the position of the bone in local or world space
  66653. * @param space The space that the returned position is in
  66654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66655. * @returns The position of the bone
  66656. */
  66657. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66658. /**
  66659. * Copy the position of the bone to a vector3 in local or world space
  66660. * @param space The space that the returned position is in
  66661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66662. * @param result The vector3 to copy the position to
  66663. */
  66664. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66665. /**
  66666. * Get the absolute position of the bone (world space)
  66667. * @param mesh The mesh that this bone is attached to
  66668. * @returns The absolute position of the bone
  66669. */
  66670. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66671. /**
  66672. * Copy the absolute position of the bone (world space) to the result param
  66673. * @param mesh The mesh that this bone is attached to
  66674. * @param result The vector3 to copy the absolute position to
  66675. */
  66676. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66677. /**
  66678. * Compute the absolute transforms of this bone and its children
  66679. */
  66680. computeAbsoluteTransforms(): void;
  66681. /**
  66682. * Get the world direction from an axis that is in the local space of the bone
  66683. * @param localAxis The local direction that is used to compute the world direction
  66684. * @param mesh The mesh that this bone is attached to
  66685. * @returns The world direction
  66686. */
  66687. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66688. /**
  66689. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66690. * @param localAxis The local direction that is used to compute the world direction
  66691. * @param mesh The mesh that this bone is attached to
  66692. * @param result The vector3 that the world direction will be copied to
  66693. */
  66694. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66695. /**
  66696. * Get the euler rotation of the bone in local or world space
  66697. * @param space The space that the rotation should be in
  66698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66699. * @returns The euler rotation
  66700. */
  66701. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66702. /**
  66703. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66704. * @param space The space that the rotation should be in
  66705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66706. * @param result The vector3 that the rotation should be copied to
  66707. */
  66708. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66709. /**
  66710. * Get the quaternion rotation of the bone in either local or world space
  66711. * @param space The space that the rotation should be in
  66712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66713. * @returns The quaternion rotation
  66714. */
  66715. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66716. /**
  66717. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66718. * @param space The space that the rotation should be in
  66719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66720. * @param result The quaternion that the rotation should be copied to
  66721. */
  66722. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66723. /**
  66724. * Get the rotation matrix of the bone in local or world space
  66725. * @param space The space that the rotation should be in
  66726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66727. * @returns The rotation matrix
  66728. */
  66729. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66730. /**
  66731. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66732. * @param space The space that the rotation should be in
  66733. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66734. * @param result The quaternion that the rotation should be copied to
  66735. */
  66736. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66737. /**
  66738. * Get the world position of a point that is in the local space of the bone
  66739. * @param position The local position
  66740. * @param mesh The mesh that this bone is attached to
  66741. * @returns The world position
  66742. */
  66743. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66744. /**
  66745. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66746. * @param position The local position
  66747. * @param mesh The mesh that this bone is attached to
  66748. * @param result The vector3 that the world position should be copied to
  66749. */
  66750. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66751. /**
  66752. * Get the local position of a point that is in world space
  66753. * @param position The world position
  66754. * @param mesh The mesh that this bone is attached to
  66755. * @returns The local position
  66756. */
  66757. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66758. /**
  66759. * Get the local position of a point that is in world space and copy it to the result param
  66760. * @param position The world position
  66761. * @param mesh The mesh that this bone is attached to
  66762. * @param result The vector3 that the local position should be copied to
  66763. */
  66764. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66765. }
  66766. }
  66767. declare module BABYLON {
  66768. /**
  66769. * Enum that determines the text-wrapping mode to use.
  66770. */
  66771. export enum InspectableType {
  66772. /**
  66773. * Checkbox for booleans
  66774. */
  66775. Checkbox = 0,
  66776. /**
  66777. * Sliders for numbers
  66778. */
  66779. Slider = 1,
  66780. /**
  66781. * Vector3
  66782. */
  66783. Vector3 = 2,
  66784. /**
  66785. * Quaternions
  66786. */
  66787. Quaternion = 3,
  66788. /**
  66789. * Color3
  66790. */
  66791. Color3 = 4
  66792. }
  66793. /**
  66794. * Interface used to define custom inspectable properties.
  66795. * This interface is used by the inspector to display custom property grids
  66796. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66797. */
  66798. export interface IInspectable {
  66799. /**
  66800. * Gets the label to display
  66801. */
  66802. label: string;
  66803. /**
  66804. * Gets the name of the property to edit
  66805. */
  66806. propertyName: string;
  66807. /**
  66808. * Gets the type of the editor to use
  66809. */
  66810. type: InspectableType;
  66811. /**
  66812. * Gets the minimum value of the property when using in "slider" mode
  66813. */
  66814. min?: number;
  66815. /**
  66816. * Gets the maximum value of the property when using in "slider" mode
  66817. */
  66818. max?: number;
  66819. /**
  66820. * Gets the setp to use when using in "slider" mode
  66821. */
  66822. step?: number;
  66823. }
  66824. }
  66825. declare module BABYLON {
  66826. /**
  66827. * Class for creating a cube texture
  66828. */
  66829. export class CubeTexture extends BaseTexture {
  66830. private _delayedOnLoad;
  66831. /**
  66832. * The url of the texture
  66833. */
  66834. url: string;
  66835. /**
  66836. * Gets or sets the center of the bounding box associated with the cube texture.
  66837. * It must define where the camera used to render the texture was set
  66838. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66839. */
  66840. boundingBoxPosition: Vector3;
  66841. private _boundingBoxSize;
  66842. /**
  66843. * Gets or sets the size of the bounding box associated with the cube texture
  66844. * When defined, the cubemap will switch to local mode
  66845. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66846. * @example https://www.babylonjs-playground.com/#RNASML
  66847. */
  66848. /**
  66849. * Returns the bounding box size
  66850. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66851. */
  66852. boundingBoxSize: Vector3;
  66853. protected _rotationY: number;
  66854. /**
  66855. * Sets texture matrix rotation angle around Y axis in radians.
  66856. */
  66857. /**
  66858. * Gets texture matrix rotation angle around Y axis radians.
  66859. */
  66860. rotationY: number;
  66861. /**
  66862. * Are mip maps generated for this texture or not.
  66863. */
  66864. readonly noMipmap: boolean;
  66865. private _noMipmap;
  66866. private _files;
  66867. private _extensions;
  66868. private _textureMatrix;
  66869. private _format;
  66870. private _createPolynomials;
  66871. /** @hidden */
  66872. _prefiltered: boolean;
  66873. /**
  66874. * Creates a cube texture from an array of image urls
  66875. * @param files defines an array of image urls
  66876. * @param scene defines the hosting scene
  66877. * @param noMipmap specifies if mip maps are not used
  66878. * @returns a cube texture
  66879. */
  66880. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66881. /**
  66882. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66883. * @param url defines the url of the prefiltered texture
  66884. * @param scene defines the scene the texture is attached to
  66885. * @param forcedExtension defines the extension of the file if different from the url
  66886. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66887. * @return the prefiltered texture
  66888. */
  66889. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66890. /**
  66891. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66892. * as prefiltered data.
  66893. * @param rootUrl defines the url of the texture or the root name of the six images
  66894. * @param scene defines the scene the texture is attached to
  66895. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66896. * @param noMipmap defines if mipmaps should be created or not
  66897. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66898. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66899. * @param onError defines a callback triggered in case of error during load
  66900. * @param format defines the internal format to use for the texture once loaded
  66901. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66902. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66903. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66904. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66905. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66906. * @return the cube texture
  66907. */
  66908. 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);
  66909. /**
  66910. * Get the current class name of the texture useful for serialization or dynamic coding.
  66911. * @returns "CubeTexture"
  66912. */
  66913. getClassName(): string;
  66914. /**
  66915. * Update the url (and optional buffer) of this texture if url was null during construction.
  66916. * @param url the url of the texture
  66917. * @param forcedExtension defines the extension to use
  66918. * @param onLoad callback called when the texture is loaded (defaults to null)
  66919. */
  66920. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66921. /**
  66922. * Delays loading of the cube texture
  66923. * @param forcedExtension defines the extension to use
  66924. */
  66925. delayLoad(forcedExtension?: string): void;
  66926. /**
  66927. * Returns the reflection texture matrix
  66928. * @returns the reflection texture matrix
  66929. */
  66930. getReflectionTextureMatrix(): Matrix;
  66931. /**
  66932. * Sets the reflection texture matrix
  66933. * @param value Reflection texture matrix
  66934. */
  66935. setReflectionTextureMatrix(value: Matrix): void;
  66936. /**
  66937. * Parses text to create a cube texture
  66938. * @param parsedTexture define the serialized text to read from
  66939. * @param scene defines the hosting scene
  66940. * @param rootUrl defines the root url of the cube texture
  66941. * @returns a cube texture
  66942. */
  66943. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66944. /**
  66945. * Makes a clone, or deep copy, of the cube texture
  66946. * @returns a new cube texture
  66947. */
  66948. clone(): CubeTexture;
  66949. }
  66950. }
  66951. declare module BABYLON {
  66952. /** @hidden */
  66953. export var postprocessVertexShader: {
  66954. name: string;
  66955. shader: string;
  66956. };
  66957. }
  66958. declare module BABYLON {
  66959. /**
  66960. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66961. * This is the base of the follow, arc rotate cameras and Free camera
  66962. * @see http://doc.babylonjs.com/features/cameras
  66963. */
  66964. export class TargetCamera extends Camera {
  66965. private static _RigCamTransformMatrix;
  66966. private static _TargetTransformMatrix;
  66967. private static _TargetFocalPoint;
  66968. /**
  66969. * Define the current direction the camera is moving to
  66970. */
  66971. cameraDirection: Vector3;
  66972. /**
  66973. * Define the current rotation the camera is rotating to
  66974. */
  66975. cameraRotation: Vector2;
  66976. /**
  66977. * When set, the up vector of the camera will be updated by the rotation of the camera
  66978. */
  66979. updateUpVectorFromRotation: boolean;
  66980. private _tmpQuaternion;
  66981. /**
  66982. * Define the current rotation of the camera
  66983. */
  66984. rotation: Vector3;
  66985. /**
  66986. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66987. */
  66988. rotationQuaternion: Quaternion;
  66989. /**
  66990. * Define the current speed of the camera
  66991. */
  66992. speed: number;
  66993. /**
  66994. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66995. * around all axis.
  66996. */
  66997. noRotationConstraint: boolean;
  66998. /**
  66999. * Define the current target of the camera as an object or a position.
  67000. */
  67001. lockedTarget: any;
  67002. /** @hidden */
  67003. _currentTarget: Vector3;
  67004. /** @hidden */
  67005. _initialFocalDistance: number;
  67006. /** @hidden */
  67007. _viewMatrix: Matrix;
  67008. /** @hidden */
  67009. _camMatrix: Matrix;
  67010. /** @hidden */
  67011. _cameraTransformMatrix: Matrix;
  67012. /** @hidden */
  67013. _cameraRotationMatrix: Matrix;
  67014. /** @hidden */
  67015. _referencePoint: Vector3;
  67016. /** @hidden */
  67017. _transformedReferencePoint: Vector3;
  67018. protected _globalCurrentTarget: Vector3;
  67019. protected _globalCurrentUpVector: Vector3;
  67020. /** @hidden */
  67021. _reset: () => void;
  67022. private _defaultUp;
  67023. /**
  67024. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67025. * This is the base of the follow, arc rotate cameras and Free camera
  67026. * @see http://doc.babylonjs.com/features/cameras
  67027. * @param name Defines the name of the camera in the scene
  67028. * @param position Defines the start position of the camera in the scene
  67029. * @param scene Defines the scene the camera belongs to
  67030. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67031. */
  67032. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67033. /**
  67034. * Gets the position in front of the camera at a given distance.
  67035. * @param distance The distance from the camera we want the position to be
  67036. * @returns the position
  67037. */
  67038. getFrontPosition(distance: number): Vector3;
  67039. /** @hidden */
  67040. _getLockedTargetPosition(): Nullable<Vector3>;
  67041. private _storedPosition;
  67042. private _storedRotation;
  67043. private _storedRotationQuaternion;
  67044. /**
  67045. * Store current camera state of the camera (fov, position, rotation, etc..)
  67046. * @returns the camera
  67047. */
  67048. storeState(): Camera;
  67049. /**
  67050. * Restored camera state. You must call storeState() first
  67051. * @returns whether it was successful or not
  67052. * @hidden
  67053. */
  67054. _restoreStateValues(): boolean;
  67055. /** @hidden */
  67056. _initCache(): void;
  67057. /** @hidden */
  67058. _updateCache(ignoreParentClass?: boolean): void;
  67059. /** @hidden */
  67060. _isSynchronizedViewMatrix(): boolean;
  67061. /** @hidden */
  67062. _computeLocalCameraSpeed(): number;
  67063. /**
  67064. * Defines the target the camera should look at.
  67065. * This will automatically adapt alpha beta and radius to fit within the new target.
  67066. * @param target Defines the new target as a Vector or a mesh
  67067. */
  67068. setTarget(target: Vector3): void;
  67069. /**
  67070. * Return the current target position of the camera. This value is expressed in local space.
  67071. * @returns the target position
  67072. */
  67073. getTarget(): Vector3;
  67074. /** @hidden */
  67075. _decideIfNeedsToMove(): boolean;
  67076. /** @hidden */
  67077. _updatePosition(): void;
  67078. /** @hidden */
  67079. _checkInputs(): void;
  67080. protected _updateCameraRotationMatrix(): void;
  67081. /**
  67082. * 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)
  67083. * @returns the current camera
  67084. */
  67085. private _rotateUpVectorWithCameraRotationMatrix;
  67086. private _cachedRotationZ;
  67087. private _cachedQuaternionRotationZ;
  67088. /** @hidden */
  67089. _getViewMatrix(): Matrix;
  67090. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67091. /**
  67092. * @hidden
  67093. */
  67094. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67095. /**
  67096. * @hidden
  67097. */
  67098. _updateRigCameras(): void;
  67099. private _getRigCamPositionAndTarget;
  67100. /**
  67101. * Gets the current object class name.
  67102. * @return the class name
  67103. */
  67104. getClassName(): string;
  67105. }
  67106. }
  67107. declare module BABYLON {
  67108. /**
  67109. * @ignore
  67110. * This is a list of all the different input types that are available in the application.
  67111. * Fo instance: ArcRotateCameraGamepadInput...
  67112. */
  67113. export var CameraInputTypes: {};
  67114. /**
  67115. * This is the contract to implement in order to create a new input class.
  67116. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67117. */
  67118. export interface ICameraInput<TCamera extends Camera> {
  67119. /**
  67120. * Defines the camera the input is attached to.
  67121. */
  67122. camera: Nullable<TCamera>;
  67123. /**
  67124. * Gets the class name of the current intput.
  67125. * @returns the class name
  67126. */
  67127. getClassName(): string;
  67128. /**
  67129. * Get the friendly name associated with the input class.
  67130. * @returns the input friendly name
  67131. */
  67132. getSimpleName(): string;
  67133. /**
  67134. * Attach the input controls to a specific dom element to get the input from.
  67135. * @param element Defines the element the controls should be listened from
  67136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67137. */
  67138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67139. /**
  67140. * Detach the current controls from the specified dom element.
  67141. * @param element Defines the element to stop listening the inputs from
  67142. */
  67143. detachControl(element: Nullable<HTMLElement>): void;
  67144. /**
  67145. * Update the current camera state depending on the inputs that have been used this frame.
  67146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67147. */
  67148. checkInputs?: () => void;
  67149. }
  67150. /**
  67151. * Represents a map of input types to input instance or input index to input instance.
  67152. */
  67153. export interface CameraInputsMap<TCamera extends Camera> {
  67154. /**
  67155. * Accessor to the input by input type.
  67156. */
  67157. [name: string]: ICameraInput<TCamera>;
  67158. /**
  67159. * Accessor to the input by input index.
  67160. */
  67161. [idx: number]: ICameraInput<TCamera>;
  67162. }
  67163. /**
  67164. * This represents the input manager used within a camera.
  67165. * It helps dealing with all the different kind of input attached to a camera.
  67166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67167. */
  67168. export class CameraInputsManager<TCamera extends Camera> {
  67169. /**
  67170. * Defines the list of inputs attahed to the camera.
  67171. */
  67172. attached: CameraInputsMap<TCamera>;
  67173. /**
  67174. * Defines the dom element the camera is collecting inputs from.
  67175. * This is null if the controls have not been attached.
  67176. */
  67177. attachedElement: Nullable<HTMLElement>;
  67178. /**
  67179. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67180. */
  67181. noPreventDefault: boolean;
  67182. /**
  67183. * Defined the camera the input manager belongs to.
  67184. */
  67185. camera: TCamera;
  67186. /**
  67187. * Update the current camera state depending on the inputs that have been used this frame.
  67188. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67189. */
  67190. checkInputs: () => void;
  67191. /**
  67192. * Instantiate a new Camera Input Manager.
  67193. * @param camera Defines the camera the input manager blongs to
  67194. */
  67195. constructor(camera: TCamera);
  67196. /**
  67197. * Add an input method to a camera
  67198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67199. * @param input camera input method
  67200. */
  67201. add(input: ICameraInput<TCamera>): void;
  67202. /**
  67203. * Remove a specific input method from a camera
  67204. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67205. * @param inputToRemove camera input method
  67206. */
  67207. remove(inputToRemove: ICameraInput<TCamera>): void;
  67208. /**
  67209. * Remove a specific input type from a camera
  67210. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67211. * @param inputType the type of the input to remove
  67212. */
  67213. removeByType(inputType: string): void;
  67214. private _addCheckInputs;
  67215. /**
  67216. * Attach the input controls to the currently attached dom element to listen the events from.
  67217. * @param input Defines the input to attach
  67218. */
  67219. attachInput(input: ICameraInput<TCamera>): void;
  67220. /**
  67221. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67222. * @param element Defines the dom element to collect the events from
  67223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67224. */
  67225. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67226. /**
  67227. * Detach the current manager inputs controls from a specific dom element.
  67228. * @param element Defines the dom element to collect the events from
  67229. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67230. */
  67231. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67232. /**
  67233. * Rebuild the dynamic inputCheck function from the current list of
  67234. * defined inputs in the manager.
  67235. */
  67236. rebuildInputCheck(): void;
  67237. /**
  67238. * Remove all attached input methods from a camera
  67239. */
  67240. clear(): void;
  67241. /**
  67242. * Serialize the current input manager attached to a camera.
  67243. * This ensures than once parsed,
  67244. * the input associated to the camera will be identical to the current ones
  67245. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67246. */
  67247. serialize(serializedCamera: any): void;
  67248. /**
  67249. * Parses an input manager serialized JSON to restore the previous list of inputs
  67250. * and states associated to a camera.
  67251. * @param parsedCamera Defines the JSON to parse
  67252. */
  67253. parse(parsedCamera: any): void;
  67254. }
  67255. }
  67256. declare module BABYLON {
  67257. /**
  67258. * Gather the list of keyboard event types as constants.
  67259. */
  67260. export class KeyboardEventTypes {
  67261. /**
  67262. * The keydown event is fired when a key becomes active (pressed).
  67263. */
  67264. static readonly KEYDOWN: number;
  67265. /**
  67266. * The keyup event is fired when a key has been released.
  67267. */
  67268. static readonly KEYUP: number;
  67269. }
  67270. /**
  67271. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67272. */
  67273. export class KeyboardInfo {
  67274. /**
  67275. * Defines the type of event (KeyboardEventTypes)
  67276. */
  67277. type: number;
  67278. /**
  67279. * Defines the related dom event
  67280. */
  67281. event: KeyboardEvent;
  67282. /**
  67283. * Instantiates a new keyboard info.
  67284. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67285. * @param type Defines the type of event (KeyboardEventTypes)
  67286. * @param event Defines the related dom event
  67287. */
  67288. constructor(
  67289. /**
  67290. * Defines the type of event (KeyboardEventTypes)
  67291. */
  67292. type: number,
  67293. /**
  67294. * Defines the related dom event
  67295. */
  67296. event: KeyboardEvent);
  67297. }
  67298. /**
  67299. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67300. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67301. */
  67302. export class KeyboardInfoPre extends KeyboardInfo {
  67303. /**
  67304. * Defines the type of event (KeyboardEventTypes)
  67305. */
  67306. type: number;
  67307. /**
  67308. * Defines the related dom event
  67309. */
  67310. event: KeyboardEvent;
  67311. /**
  67312. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67313. */
  67314. skipOnPointerObservable: boolean;
  67315. /**
  67316. * Instantiates a new keyboard pre info.
  67317. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67318. * @param type Defines the type of event (KeyboardEventTypes)
  67319. * @param event Defines the related dom event
  67320. */
  67321. constructor(
  67322. /**
  67323. * Defines the type of event (KeyboardEventTypes)
  67324. */
  67325. type: number,
  67326. /**
  67327. * Defines the related dom event
  67328. */
  67329. event: KeyboardEvent);
  67330. }
  67331. }
  67332. declare module BABYLON {
  67333. /**
  67334. * Manage the keyboard inputs to control the movement of a free camera.
  67335. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67336. */
  67337. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67338. /**
  67339. * Defines the camera the input is attached to.
  67340. */
  67341. camera: FreeCamera;
  67342. /**
  67343. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67344. */
  67345. keysUp: number[];
  67346. /**
  67347. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67348. */
  67349. keysDown: number[];
  67350. /**
  67351. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67352. */
  67353. keysLeft: number[];
  67354. /**
  67355. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67356. */
  67357. keysRight: number[];
  67358. private _keys;
  67359. private _onCanvasBlurObserver;
  67360. private _onKeyboardObserver;
  67361. private _engine;
  67362. private _scene;
  67363. /**
  67364. * Attach the input controls to a specific dom element to get the input from.
  67365. * @param element Defines the element the controls should be listened from
  67366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67367. */
  67368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67369. /**
  67370. * Detach the current controls from the specified dom element.
  67371. * @param element Defines the element to stop listening the inputs from
  67372. */
  67373. detachControl(element: Nullable<HTMLElement>): void;
  67374. /**
  67375. * Update the current camera state depending on the inputs that have been used this frame.
  67376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67377. */
  67378. checkInputs(): void;
  67379. /**
  67380. * Gets the class name of the current intput.
  67381. * @returns the class name
  67382. */
  67383. getClassName(): string;
  67384. /** @hidden */
  67385. _onLostFocus(): void;
  67386. /**
  67387. * Get the friendly name associated with the input class.
  67388. * @returns the input friendly name
  67389. */
  67390. getSimpleName(): string;
  67391. }
  67392. }
  67393. declare module BABYLON {
  67394. /**
  67395. * Interface describing all the common properties and methods a shadow light needs to implement.
  67396. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67397. * as well as binding the different shadow properties to the effects.
  67398. */
  67399. export interface IShadowLight extends Light {
  67400. /**
  67401. * The light id in the scene (used in scene.findLighById for instance)
  67402. */
  67403. id: string;
  67404. /**
  67405. * The position the shdow will be casted from.
  67406. */
  67407. position: Vector3;
  67408. /**
  67409. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67410. */
  67411. direction: Vector3;
  67412. /**
  67413. * The transformed position. Position of the light in world space taking parenting in account.
  67414. */
  67415. transformedPosition: Vector3;
  67416. /**
  67417. * The transformed direction. Direction of the light in world space taking parenting in account.
  67418. */
  67419. transformedDirection: Vector3;
  67420. /**
  67421. * The friendly name of the light in the scene.
  67422. */
  67423. name: string;
  67424. /**
  67425. * Defines the shadow projection clipping minimum z value.
  67426. */
  67427. shadowMinZ: number;
  67428. /**
  67429. * Defines the shadow projection clipping maximum z value.
  67430. */
  67431. shadowMaxZ: number;
  67432. /**
  67433. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67434. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67435. */
  67436. computeTransformedInformation(): boolean;
  67437. /**
  67438. * Gets the scene the light belongs to.
  67439. * @returns The scene
  67440. */
  67441. getScene(): Scene;
  67442. /**
  67443. * Callback defining a custom Projection Matrix Builder.
  67444. * This can be used to override the default projection matrix computation.
  67445. */
  67446. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67447. /**
  67448. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67449. * @param matrix The materix to updated with the projection information
  67450. * @param viewMatrix The transform matrix of the light
  67451. * @param renderList The list of mesh to render in the map
  67452. * @returns The current light
  67453. */
  67454. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67455. /**
  67456. * Gets the current depth scale used in ESM.
  67457. * @returns The scale
  67458. */
  67459. getDepthScale(): number;
  67460. /**
  67461. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67462. * @returns true if a cube texture needs to be use
  67463. */
  67464. needCube(): boolean;
  67465. /**
  67466. * Detects if the projection matrix requires to be recomputed this frame.
  67467. * @returns true if it requires to be recomputed otherwise, false.
  67468. */
  67469. needProjectionMatrixCompute(): boolean;
  67470. /**
  67471. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67472. */
  67473. forceProjectionMatrixCompute(): void;
  67474. /**
  67475. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67476. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67477. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67478. */
  67479. getShadowDirection(faceIndex?: number): Vector3;
  67480. /**
  67481. * Gets the minZ used for shadow according to both the scene and the light.
  67482. * @param activeCamera The camera we are returning the min for
  67483. * @returns the depth min z
  67484. */
  67485. getDepthMinZ(activeCamera: Camera): number;
  67486. /**
  67487. * Gets the maxZ used for shadow according to both the scene and the light.
  67488. * @param activeCamera The camera we are returning the max for
  67489. * @returns the depth max z
  67490. */
  67491. getDepthMaxZ(activeCamera: Camera): number;
  67492. }
  67493. /**
  67494. * Base implementation IShadowLight
  67495. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67496. */
  67497. export abstract class ShadowLight extends Light implements IShadowLight {
  67498. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67499. protected _position: Vector3;
  67500. protected _setPosition(value: Vector3): void;
  67501. /**
  67502. * Sets the position the shadow will be casted from. Also use as the light position for both
  67503. * point and spot lights.
  67504. */
  67505. /**
  67506. * Sets the position the shadow will be casted from. Also use as the light position for both
  67507. * point and spot lights.
  67508. */
  67509. position: Vector3;
  67510. protected _direction: Vector3;
  67511. protected _setDirection(value: Vector3): void;
  67512. /**
  67513. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67514. * Also use as the light direction on spot and directional lights.
  67515. */
  67516. /**
  67517. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67518. * Also use as the light direction on spot and directional lights.
  67519. */
  67520. direction: Vector3;
  67521. private _shadowMinZ;
  67522. /**
  67523. * Gets the shadow projection clipping minimum z value.
  67524. */
  67525. /**
  67526. * Sets the shadow projection clipping minimum z value.
  67527. */
  67528. shadowMinZ: number;
  67529. private _shadowMaxZ;
  67530. /**
  67531. * Sets the shadow projection clipping maximum z value.
  67532. */
  67533. /**
  67534. * Gets the shadow projection clipping maximum z value.
  67535. */
  67536. shadowMaxZ: number;
  67537. /**
  67538. * Callback defining a custom Projection Matrix Builder.
  67539. * This can be used to override the default projection matrix computation.
  67540. */
  67541. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67542. /**
  67543. * The transformed position. Position of the light in world space taking parenting in account.
  67544. */
  67545. transformedPosition: Vector3;
  67546. /**
  67547. * The transformed direction. Direction of the light in world space taking parenting in account.
  67548. */
  67549. transformedDirection: Vector3;
  67550. private _needProjectionMatrixCompute;
  67551. /**
  67552. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67553. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67554. */
  67555. computeTransformedInformation(): boolean;
  67556. /**
  67557. * Return the depth scale used for the shadow map.
  67558. * @returns the depth scale.
  67559. */
  67560. getDepthScale(): number;
  67561. /**
  67562. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67563. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67564. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67565. */
  67566. getShadowDirection(faceIndex?: number): Vector3;
  67567. /**
  67568. * Returns the ShadowLight absolute position in the World.
  67569. * @returns the position vector in world space
  67570. */
  67571. getAbsolutePosition(): Vector3;
  67572. /**
  67573. * Sets the ShadowLight direction toward the passed target.
  67574. * @param target The point to target in local space
  67575. * @returns the updated ShadowLight direction
  67576. */
  67577. setDirectionToTarget(target: Vector3): Vector3;
  67578. /**
  67579. * Returns the light rotation in euler definition.
  67580. * @returns the x y z rotation in local space.
  67581. */
  67582. getRotation(): Vector3;
  67583. /**
  67584. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67585. * @returns true if a cube texture needs to be use
  67586. */
  67587. needCube(): boolean;
  67588. /**
  67589. * Detects if the projection matrix requires to be recomputed this frame.
  67590. * @returns true if it requires to be recomputed otherwise, false.
  67591. */
  67592. needProjectionMatrixCompute(): boolean;
  67593. /**
  67594. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67595. */
  67596. forceProjectionMatrixCompute(): void;
  67597. /** @hidden */
  67598. _initCache(): void;
  67599. /** @hidden */
  67600. _isSynchronized(): boolean;
  67601. /**
  67602. * Computes the world matrix of the node
  67603. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67604. * @returns the world matrix
  67605. */
  67606. computeWorldMatrix(force?: boolean): Matrix;
  67607. /**
  67608. * Gets the minZ used for shadow according to both the scene and the light.
  67609. * @param activeCamera The camera we are returning the min for
  67610. * @returns the depth min z
  67611. */
  67612. getDepthMinZ(activeCamera: Camera): number;
  67613. /**
  67614. * Gets the maxZ used for shadow according to both the scene and the light.
  67615. * @param activeCamera The camera we are returning the max for
  67616. * @returns the depth max z
  67617. */
  67618. getDepthMaxZ(activeCamera: Camera): number;
  67619. /**
  67620. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67621. * @param matrix The materix to updated with the projection information
  67622. * @param viewMatrix The transform matrix of the light
  67623. * @param renderList The list of mesh to render in the map
  67624. * @returns The current light
  67625. */
  67626. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67627. }
  67628. }
  67629. declare module BABYLON {
  67630. /**
  67631. * "Static Class" containing the most commonly used helper while dealing with material for
  67632. * rendering purpose.
  67633. *
  67634. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67635. *
  67636. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67637. */
  67638. export class MaterialHelper {
  67639. /**
  67640. * Bind the current view position to an effect.
  67641. * @param effect The effect to be bound
  67642. * @param scene The scene the eyes position is used from
  67643. */
  67644. static BindEyePosition(effect: Effect, scene: Scene): void;
  67645. /**
  67646. * Helps preparing the defines values about the UVs in used in the effect.
  67647. * UVs are shared as much as we can accross channels in the shaders.
  67648. * @param texture The texture we are preparing the UVs for
  67649. * @param defines The defines to update
  67650. * @param key The channel key "diffuse", "specular"... used in the shader
  67651. */
  67652. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67653. /**
  67654. * Binds a texture matrix value to its corrsponding uniform
  67655. * @param texture The texture to bind the matrix for
  67656. * @param uniformBuffer The uniform buffer receivin the data
  67657. * @param key The channel key "diffuse", "specular"... used in the shader
  67658. */
  67659. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67660. /**
  67661. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67662. * @param mesh defines the current mesh
  67663. * @param scene defines the current scene
  67664. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67665. * @param pointsCloud defines if point cloud rendering has to be turned on
  67666. * @param fogEnabled defines if fog has to be turned on
  67667. * @param alphaTest defines if alpha testing has to be turned on
  67668. * @param defines defines the current list of defines
  67669. */
  67670. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67671. /**
  67672. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67673. * @param scene defines the current scene
  67674. * @param engine defines the current engine
  67675. * @param defines specifies the list of active defines
  67676. * @param useInstances defines if instances have to be turned on
  67677. * @param useClipPlane defines if clip plane have to be turned on
  67678. */
  67679. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67680. /**
  67681. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67682. * @param mesh The mesh containing the geometry data we will draw
  67683. * @param defines The defines to update
  67684. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67685. * @param useBones Precise whether bones should be used or not (override mesh info)
  67686. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67687. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67688. * @returns false if defines are considered not dirty and have not been checked
  67689. */
  67690. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67691. /**
  67692. * Prepares the defines related to the light information passed in parameter
  67693. * @param scene The scene we are intending to draw
  67694. * @param mesh The mesh the effect is compiling for
  67695. * @param defines The defines to update
  67696. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67697. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67698. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67699. * @returns true if normals will be required for the rest of the effect
  67700. */
  67701. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67702. /**
  67703. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67704. * that won t be acctive due to defines being turned off.
  67705. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67706. * @param samplersList The samplers list
  67707. * @param defines The defines helping in the list generation
  67708. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67709. */
  67710. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67711. /**
  67712. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67713. * @param defines The defines to update while falling back
  67714. * @param fallbacks The authorized effect fallbacks
  67715. * @param maxSimultaneousLights The maximum number of lights allowed
  67716. * @param rank the current rank of the Effect
  67717. * @returns The newly affected rank
  67718. */
  67719. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67720. /**
  67721. * Prepares the list of attributes required for morph targets according to the effect defines.
  67722. * @param attribs The current list of supported attribs
  67723. * @param mesh The mesh to prepare the morph targets attributes for
  67724. * @param defines The current Defines of the effect
  67725. */
  67726. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67727. /**
  67728. * Prepares the list of attributes required for bones according to the effect defines.
  67729. * @param attribs The current list of supported attribs
  67730. * @param mesh The mesh to prepare the bones attributes for
  67731. * @param defines The current Defines of the effect
  67732. * @param fallbacks The current efffect fallback strategy
  67733. */
  67734. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67735. /**
  67736. * Prepares the list of attributes required for instances according to the effect defines.
  67737. * @param attribs The current list of supported attribs
  67738. * @param defines The current Defines of the effect
  67739. */
  67740. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67741. /**
  67742. * Binds the light shadow information to the effect for the given mesh.
  67743. * @param light The light containing the generator
  67744. * @param scene The scene the lights belongs to
  67745. * @param mesh The mesh we are binding the information to render
  67746. * @param lightIndex The light index in the effect used to render the mesh
  67747. * @param effect The effect we are binding the data to
  67748. */
  67749. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67750. /**
  67751. * Binds the light information to the effect.
  67752. * @param light The light containing the generator
  67753. * @param effect The effect we are binding the data to
  67754. * @param lightIndex The light index in the effect used to render
  67755. */
  67756. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67757. /**
  67758. * Binds the lights information from the scene to the effect for the given mesh.
  67759. * @param scene The scene the lights belongs to
  67760. * @param mesh The mesh we are binding the information to render
  67761. * @param effect The effect we are binding the data to
  67762. * @param defines The generated defines for the effect
  67763. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67764. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67765. */
  67766. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67767. private static _tempFogColor;
  67768. /**
  67769. * Binds the fog information from the scene to the effect for the given mesh.
  67770. * @param scene The scene the lights belongs to
  67771. * @param mesh The mesh we are binding the information to render
  67772. * @param effect The effect we are binding the data to
  67773. * @param linearSpace Defines if the fog effect is applied in linear space
  67774. */
  67775. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67776. /**
  67777. * Binds the bones information from the mesh to the effect.
  67778. * @param mesh The mesh we are binding the information to render
  67779. * @param effect The effect we are binding the data to
  67780. */
  67781. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67782. /**
  67783. * Binds the morph targets information from the mesh to the effect.
  67784. * @param abstractMesh The mesh we are binding the information to render
  67785. * @param effect The effect we are binding the data to
  67786. */
  67787. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67788. /**
  67789. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67790. * @param defines The generated defines used in the effect
  67791. * @param effect The effect we are binding the data to
  67792. * @param scene The scene we are willing to render with logarithmic scale for
  67793. */
  67794. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67795. /**
  67796. * Binds the clip plane information from the scene to the effect.
  67797. * @param scene The scene the clip plane information are extracted from
  67798. * @param effect The effect we are binding the data to
  67799. */
  67800. static BindClipPlane(effect: Effect, scene: Scene): void;
  67801. }
  67802. }
  67803. declare module BABYLON {
  67804. /** @hidden */
  67805. export var kernelBlurVaryingDeclaration: {
  67806. name: string;
  67807. shader: string;
  67808. };
  67809. }
  67810. declare module BABYLON {
  67811. /** @hidden */
  67812. export var kernelBlurFragment: {
  67813. name: string;
  67814. shader: string;
  67815. };
  67816. }
  67817. declare module BABYLON {
  67818. /** @hidden */
  67819. export var kernelBlurFragment2: {
  67820. name: string;
  67821. shader: string;
  67822. };
  67823. }
  67824. declare module BABYLON {
  67825. /** @hidden */
  67826. export var kernelBlurPixelShader: {
  67827. name: string;
  67828. shader: string;
  67829. };
  67830. }
  67831. declare module BABYLON {
  67832. /** @hidden */
  67833. export var kernelBlurVertex: {
  67834. name: string;
  67835. shader: string;
  67836. };
  67837. }
  67838. declare module BABYLON {
  67839. /** @hidden */
  67840. export var kernelBlurVertexShader: {
  67841. name: string;
  67842. shader: string;
  67843. };
  67844. }
  67845. declare module BABYLON {
  67846. /**
  67847. * The Blur Post Process which blurs an image based on a kernel and direction.
  67848. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67849. */
  67850. export class BlurPostProcess extends PostProcess {
  67851. /** The direction in which to blur the image. */
  67852. direction: Vector2;
  67853. private blockCompilation;
  67854. protected _kernel: number;
  67855. protected _idealKernel: number;
  67856. protected _packedFloat: boolean;
  67857. private _staticDefines;
  67858. /**
  67859. * Sets the length in pixels of the blur sample region
  67860. */
  67861. /**
  67862. * Gets the length in pixels of the blur sample region
  67863. */
  67864. kernel: number;
  67865. /**
  67866. * Sets wether or not the blur needs to unpack/repack floats
  67867. */
  67868. /**
  67869. * Gets wether or not the blur is unpacking/repacking floats
  67870. */
  67871. packedFloat: boolean;
  67872. /**
  67873. * Creates a new instance BlurPostProcess
  67874. * @param name The name of the effect.
  67875. * @param direction The direction in which to blur the image.
  67876. * @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.
  67877. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67878. * @param camera The camera to apply the render pass to.
  67879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67880. * @param engine The engine which the post process will be applied. (default: current engine)
  67881. * @param reusable If the post process can be reused on the same frame. (default: false)
  67882. * @param textureType Type of textures used when performing the post process. (default: 0)
  67883. * @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)
  67884. */
  67885. constructor(name: string,
  67886. /** The direction in which to blur the image. */
  67887. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67888. /**
  67889. * Updates the effect with the current post process compile time values and recompiles the shader.
  67890. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67891. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67892. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67893. * @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
  67894. * @param onCompiled Called when the shader has been compiled.
  67895. * @param onError Called if there is an error when compiling a shader.
  67896. */
  67897. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67898. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67899. /**
  67900. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67901. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67902. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67903. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67904. * The gaps between physical kernels are compensated for in the weighting of the samples
  67905. * @param idealKernel Ideal blur kernel.
  67906. * @return Nearest best kernel.
  67907. */
  67908. protected _nearestBestKernel(idealKernel: number): number;
  67909. /**
  67910. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67911. * @param x The point on the Gaussian distribution to sample.
  67912. * @return the value of the Gaussian function at x.
  67913. */
  67914. protected _gaussianWeight(x: number): number;
  67915. /**
  67916. * Generates a string that can be used as a floating point number in GLSL.
  67917. * @param x Value to print.
  67918. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67919. * @return GLSL float string.
  67920. */
  67921. protected _glslFloat(x: number, decimalFigures?: number): string;
  67922. }
  67923. }
  67924. declare module BABYLON {
  67925. /** @hidden */
  67926. export var shadowMapPixelShader: {
  67927. name: string;
  67928. shader: string;
  67929. };
  67930. }
  67931. declare module BABYLON {
  67932. /** @hidden */
  67933. export var bonesDeclaration: {
  67934. name: string;
  67935. shader: string;
  67936. };
  67937. }
  67938. declare module BABYLON {
  67939. /** @hidden */
  67940. export var morphTargetsVertexGlobalDeclaration: {
  67941. name: string;
  67942. shader: string;
  67943. };
  67944. }
  67945. declare module BABYLON {
  67946. /** @hidden */
  67947. export var morphTargetsVertexDeclaration: {
  67948. name: string;
  67949. shader: string;
  67950. };
  67951. }
  67952. declare module BABYLON {
  67953. /** @hidden */
  67954. export var instancesDeclaration: {
  67955. name: string;
  67956. shader: string;
  67957. };
  67958. }
  67959. declare module BABYLON {
  67960. /** @hidden */
  67961. export var helperFunctions: {
  67962. name: string;
  67963. shader: string;
  67964. };
  67965. }
  67966. declare module BABYLON {
  67967. /** @hidden */
  67968. export var morphTargetsVertex: {
  67969. name: string;
  67970. shader: string;
  67971. };
  67972. }
  67973. declare module BABYLON {
  67974. /** @hidden */
  67975. export var instancesVertex: {
  67976. name: string;
  67977. shader: string;
  67978. };
  67979. }
  67980. declare module BABYLON {
  67981. /** @hidden */
  67982. export var bonesVertex: {
  67983. name: string;
  67984. shader: string;
  67985. };
  67986. }
  67987. declare module BABYLON {
  67988. /** @hidden */
  67989. export var shadowMapVertexShader: {
  67990. name: string;
  67991. shader: string;
  67992. };
  67993. }
  67994. declare module BABYLON {
  67995. /** @hidden */
  67996. export var depthBoxBlurPixelShader: {
  67997. name: string;
  67998. shader: string;
  67999. };
  68000. }
  68001. declare module BABYLON {
  68002. /**
  68003. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68004. */
  68005. export interface ICustomShaderOptions {
  68006. /**
  68007. * Gets or sets the custom shader name to use
  68008. */
  68009. shaderName: string;
  68010. /**
  68011. * The list of attribute names used in the shader
  68012. */
  68013. attributes?: string[];
  68014. /**
  68015. * The list of unifrom names used in the shader
  68016. */
  68017. uniforms?: string[];
  68018. /**
  68019. * The list of sampler names used in the shader
  68020. */
  68021. samplers?: string[];
  68022. /**
  68023. * The list of defines used in the shader
  68024. */
  68025. defines?: string[];
  68026. }
  68027. /**
  68028. * Interface to implement to create a shadow generator compatible with BJS.
  68029. */
  68030. export interface IShadowGenerator {
  68031. /**
  68032. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68033. * @returns The render target texture if present otherwise, null
  68034. */
  68035. getShadowMap(): Nullable<RenderTargetTexture>;
  68036. /**
  68037. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68038. * @returns The render target texture if the shadow map is present otherwise, null
  68039. */
  68040. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68041. /**
  68042. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68043. * @param subMesh The submesh we want to render in the shadow map
  68044. * @param useInstances Defines wether will draw in the map using instances
  68045. * @returns true if ready otherwise, false
  68046. */
  68047. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68048. /**
  68049. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68050. * @param defines Defines of the material we want to update
  68051. * @param lightIndex Index of the light in the enabled light list of the material
  68052. */
  68053. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68054. /**
  68055. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68056. * defined in the generator but impacting the effect).
  68057. * It implies the unifroms available on the materials are the standard BJS ones.
  68058. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68059. * @param effect The effect we are binfing the information for
  68060. */
  68061. bindShadowLight(lightIndex: string, effect: Effect): void;
  68062. /**
  68063. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68064. * (eq to shadow prjection matrix * light transform matrix)
  68065. * @returns The transform matrix used to create the shadow map
  68066. */
  68067. getTransformMatrix(): Matrix;
  68068. /**
  68069. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68070. * Cube and 2D textures for instance.
  68071. */
  68072. recreateShadowMap(): void;
  68073. /**
  68074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68075. * @param onCompiled Callback triggered at the and of the effects compilation
  68076. * @param options Sets of optional options forcing the compilation with different modes
  68077. */
  68078. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68079. useInstances: boolean;
  68080. }>): void;
  68081. /**
  68082. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68083. * @param options Sets of optional options forcing the compilation with different modes
  68084. * @returns A promise that resolves when the compilation completes
  68085. */
  68086. forceCompilationAsync(options?: Partial<{
  68087. useInstances: boolean;
  68088. }>): Promise<void>;
  68089. /**
  68090. * Serializes the shadow generator setup to a json object.
  68091. * @returns The serialized JSON object
  68092. */
  68093. serialize(): any;
  68094. /**
  68095. * Disposes the Shadow map and related Textures and effects.
  68096. */
  68097. dispose(): void;
  68098. }
  68099. /**
  68100. * Default implementation IShadowGenerator.
  68101. * This is the main object responsible of generating shadows in the framework.
  68102. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68103. */
  68104. export class ShadowGenerator implements IShadowGenerator {
  68105. /**
  68106. * Shadow generator mode None: no filtering applied.
  68107. */
  68108. static readonly FILTER_NONE: number;
  68109. /**
  68110. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68111. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68112. */
  68113. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68114. /**
  68115. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68116. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68117. */
  68118. static readonly FILTER_POISSONSAMPLING: number;
  68119. /**
  68120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68121. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68122. */
  68123. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68124. /**
  68125. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68126. * edge artifacts on steep falloff.
  68127. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68128. */
  68129. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68130. /**
  68131. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68132. * edge artifacts on steep falloff.
  68133. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68134. */
  68135. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68136. /**
  68137. * Shadow generator mode PCF: Percentage Closer Filtering
  68138. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68139. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68140. */
  68141. static readonly FILTER_PCF: number;
  68142. /**
  68143. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68144. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68145. * Contact Hardening
  68146. */
  68147. static readonly FILTER_PCSS: number;
  68148. /**
  68149. * Reserved for PCF and PCSS
  68150. * Highest Quality.
  68151. *
  68152. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68153. *
  68154. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68155. */
  68156. static readonly QUALITY_HIGH: number;
  68157. /**
  68158. * Reserved for PCF and PCSS
  68159. * Good tradeoff for quality/perf cross devices
  68160. *
  68161. * Execute PCF on a 3*3 kernel.
  68162. *
  68163. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68164. */
  68165. static readonly QUALITY_MEDIUM: number;
  68166. /**
  68167. * Reserved for PCF and PCSS
  68168. * The lowest quality but the fastest.
  68169. *
  68170. * Execute PCF on a 1*1 kernel.
  68171. *
  68172. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68173. */
  68174. static readonly QUALITY_LOW: number;
  68175. /** Gets or sets the custom shader name to use */
  68176. customShaderOptions: ICustomShaderOptions;
  68177. /**
  68178. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68179. */
  68180. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68181. /**
  68182. * Observable triggered before a mesh is rendered in the shadow map.
  68183. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68184. */
  68185. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68186. private _bias;
  68187. /**
  68188. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68189. */
  68190. /**
  68191. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68192. */
  68193. bias: number;
  68194. private _normalBias;
  68195. /**
  68196. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68197. */
  68198. /**
  68199. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68200. */
  68201. normalBias: number;
  68202. private _blurBoxOffset;
  68203. /**
  68204. * Gets the blur box offset: offset applied during the blur pass.
  68205. * Only useful if useKernelBlur = false
  68206. */
  68207. /**
  68208. * Sets the blur box offset: offset applied during the blur pass.
  68209. * Only useful if useKernelBlur = false
  68210. */
  68211. blurBoxOffset: number;
  68212. private _blurScale;
  68213. /**
  68214. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68215. * 2 means half of the size.
  68216. */
  68217. /**
  68218. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68219. * 2 means half of the size.
  68220. */
  68221. blurScale: number;
  68222. private _blurKernel;
  68223. /**
  68224. * Gets the blur kernel: kernel size of the blur pass.
  68225. * Only useful if useKernelBlur = true
  68226. */
  68227. /**
  68228. * Sets the blur kernel: kernel size of the blur pass.
  68229. * Only useful if useKernelBlur = true
  68230. */
  68231. blurKernel: number;
  68232. private _useKernelBlur;
  68233. /**
  68234. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68235. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68236. */
  68237. /**
  68238. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68239. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68240. */
  68241. useKernelBlur: boolean;
  68242. private _depthScale;
  68243. /**
  68244. * Gets the depth scale used in ESM mode.
  68245. */
  68246. /**
  68247. * Sets the depth scale used in ESM mode.
  68248. * This can override the scale stored on the light.
  68249. */
  68250. depthScale: number;
  68251. private _filter;
  68252. /**
  68253. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68254. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68255. */
  68256. /**
  68257. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68258. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68259. */
  68260. filter: number;
  68261. /**
  68262. * Gets if the current filter is set to Poisson Sampling.
  68263. */
  68264. /**
  68265. * Sets the current filter to Poisson Sampling.
  68266. */
  68267. usePoissonSampling: boolean;
  68268. /**
  68269. * Gets if the current filter is set to ESM.
  68270. */
  68271. /**
  68272. * Sets the current filter is to ESM.
  68273. */
  68274. useExponentialShadowMap: boolean;
  68275. /**
  68276. * Gets if the current filter is set to filtered ESM.
  68277. */
  68278. /**
  68279. * Gets if the current filter is set to filtered ESM.
  68280. */
  68281. useBlurExponentialShadowMap: boolean;
  68282. /**
  68283. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68284. * exponential to prevent steep falloff artifacts).
  68285. */
  68286. /**
  68287. * Sets the current filter to "close ESM" (using the inverse of the
  68288. * exponential to prevent steep falloff artifacts).
  68289. */
  68290. useCloseExponentialShadowMap: boolean;
  68291. /**
  68292. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68293. * exponential to prevent steep falloff artifacts).
  68294. */
  68295. /**
  68296. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68297. * exponential to prevent steep falloff artifacts).
  68298. */
  68299. useBlurCloseExponentialShadowMap: boolean;
  68300. /**
  68301. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68302. */
  68303. /**
  68304. * Sets the current filter to "PCF" (percentage closer filtering).
  68305. */
  68306. usePercentageCloserFiltering: boolean;
  68307. private _filteringQuality;
  68308. /**
  68309. * Gets the PCF or PCSS Quality.
  68310. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68311. */
  68312. /**
  68313. * Sets the PCF or PCSS Quality.
  68314. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68315. */
  68316. filteringQuality: number;
  68317. /**
  68318. * Gets if the current filter is set to "PCSS" (contact hardening).
  68319. */
  68320. /**
  68321. * Sets the current filter to "PCSS" (contact hardening).
  68322. */
  68323. useContactHardeningShadow: boolean;
  68324. private _contactHardeningLightSizeUVRatio;
  68325. /**
  68326. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68327. * Using a ratio helps keeping shape stability independently of the map size.
  68328. *
  68329. * It does not account for the light projection as it was having too much
  68330. * instability during the light setup or during light position changes.
  68331. *
  68332. * Only valid if useContactHardeningShadow is true.
  68333. */
  68334. /**
  68335. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68336. * Using a ratio helps keeping shape stability independently of the map size.
  68337. *
  68338. * It does not account for the light projection as it was having too much
  68339. * instability during the light setup or during light position changes.
  68340. *
  68341. * Only valid if useContactHardeningShadow is true.
  68342. */
  68343. contactHardeningLightSizeUVRatio: number;
  68344. private _darkness;
  68345. /**
  68346. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68347. * 0 means strongest and 1 would means no shadow.
  68348. * @returns the darkness.
  68349. */
  68350. getDarkness(): number;
  68351. /**
  68352. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68353. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68354. * @returns the shadow generator allowing fluent coding.
  68355. */
  68356. setDarkness(darkness: number): ShadowGenerator;
  68357. private _transparencyShadow;
  68358. /**
  68359. * Sets the ability to have transparent shadow (boolean).
  68360. * @param transparent True if transparent else False
  68361. * @returns the shadow generator allowing fluent coding
  68362. */
  68363. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68364. private _shadowMap;
  68365. private _shadowMap2;
  68366. /**
  68367. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68368. * @returns The render target texture if present otherwise, null
  68369. */
  68370. getShadowMap(): Nullable<RenderTargetTexture>;
  68371. /**
  68372. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68373. * @returns The render target texture if the shadow map is present otherwise, null
  68374. */
  68375. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68376. /**
  68377. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68378. * @param mesh Mesh to add
  68379. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68380. * @returns the Shadow Generator itself
  68381. */
  68382. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68383. /**
  68384. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68385. * @param mesh Mesh to remove
  68386. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68387. * @returns the Shadow Generator itself
  68388. */
  68389. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68390. /**
  68391. * Controls the extent to which the shadows fade out at the edge of the frustum
  68392. * Used only by directionals and spots
  68393. */
  68394. frustumEdgeFalloff: number;
  68395. private _light;
  68396. /**
  68397. * Returns the associated light object.
  68398. * @returns the light generating the shadow
  68399. */
  68400. getLight(): IShadowLight;
  68401. /**
  68402. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68403. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68404. * It might on the other hand introduce peter panning.
  68405. */
  68406. forceBackFacesOnly: boolean;
  68407. private _scene;
  68408. private _lightDirection;
  68409. private _effect;
  68410. private _viewMatrix;
  68411. private _projectionMatrix;
  68412. private _transformMatrix;
  68413. private _cachedPosition;
  68414. private _cachedDirection;
  68415. private _cachedDefines;
  68416. private _currentRenderID;
  68417. private _boxBlurPostprocess;
  68418. private _kernelBlurXPostprocess;
  68419. private _kernelBlurYPostprocess;
  68420. private _blurPostProcesses;
  68421. private _mapSize;
  68422. private _currentFaceIndex;
  68423. private _currentFaceIndexCache;
  68424. private _textureType;
  68425. private _defaultTextureMatrix;
  68426. /** @hidden */
  68427. static _SceneComponentInitialization: (scene: Scene) => void;
  68428. /**
  68429. * Creates a ShadowGenerator object.
  68430. * A ShadowGenerator is the required tool to use the shadows.
  68431. * Each light casting shadows needs to use its own ShadowGenerator.
  68432. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68433. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68434. * @param light The light object generating the shadows.
  68435. * @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.
  68436. */
  68437. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68438. private _initializeGenerator;
  68439. private _initializeShadowMap;
  68440. private _initializeBlurRTTAndPostProcesses;
  68441. private _renderForShadowMap;
  68442. private _renderSubMeshForShadowMap;
  68443. private _applyFilterValues;
  68444. /**
  68445. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68446. * @param onCompiled Callback triggered at the and of the effects compilation
  68447. * @param options Sets of optional options forcing the compilation with different modes
  68448. */
  68449. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68450. useInstances: boolean;
  68451. }>): void;
  68452. /**
  68453. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68454. * @param options Sets of optional options forcing the compilation with different modes
  68455. * @returns A promise that resolves when the compilation completes
  68456. */
  68457. forceCompilationAsync(options?: Partial<{
  68458. useInstances: boolean;
  68459. }>): Promise<void>;
  68460. /**
  68461. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68462. * @param subMesh The submesh we want to render in the shadow map
  68463. * @param useInstances Defines wether will draw in the map using instances
  68464. * @returns true if ready otherwise, false
  68465. */
  68466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68467. /**
  68468. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68469. * @param defines Defines of the material we want to update
  68470. * @param lightIndex Index of the light in the enabled light list of the material
  68471. */
  68472. prepareDefines(defines: any, lightIndex: number): void;
  68473. /**
  68474. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68475. * defined in the generator but impacting the effect).
  68476. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68477. * @param effect The effect we are binfing the information for
  68478. */
  68479. bindShadowLight(lightIndex: string, effect: Effect): void;
  68480. /**
  68481. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68482. * (eq to shadow prjection matrix * light transform matrix)
  68483. * @returns The transform matrix used to create the shadow map
  68484. */
  68485. getTransformMatrix(): Matrix;
  68486. /**
  68487. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68488. * Cube and 2D textures for instance.
  68489. */
  68490. recreateShadowMap(): void;
  68491. private _disposeBlurPostProcesses;
  68492. private _disposeRTTandPostProcesses;
  68493. /**
  68494. * Disposes the ShadowGenerator.
  68495. * Returns nothing.
  68496. */
  68497. dispose(): void;
  68498. /**
  68499. * Serializes the shadow generator setup to a json object.
  68500. * @returns The serialized JSON object
  68501. */
  68502. serialize(): any;
  68503. /**
  68504. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68505. * @param parsedShadowGenerator The JSON object to parse
  68506. * @param scene The scene to create the shadow map for
  68507. * @returns The parsed shadow generator
  68508. */
  68509. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68510. }
  68511. }
  68512. declare module BABYLON {
  68513. /**
  68514. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68515. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68516. * 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.
  68517. */
  68518. export abstract class Light extends Node {
  68519. /**
  68520. * Falloff Default: light is falling off following the material specification:
  68521. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68522. */
  68523. static readonly FALLOFF_DEFAULT: number;
  68524. /**
  68525. * Falloff Physical: light is falling off following the inverse squared distance law.
  68526. */
  68527. static readonly FALLOFF_PHYSICAL: number;
  68528. /**
  68529. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68530. * to enhance interoperability with other engines.
  68531. */
  68532. static readonly FALLOFF_GLTF: number;
  68533. /**
  68534. * Falloff Standard: light is falling off like in the standard material
  68535. * to enhance interoperability with other materials.
  68536. */
  68537. static readonly FALLOFF_STANDARD: number;
  68538. /**
  68539. * If every light affecting the material is in this lightmapMode,
  68540. * material.lightmapTexture adds or multiplies
  68541. * (depends on material.useLightmapAsShadowmap)
  68542. * after every other light calculations.
  68543. */
  68544. static readonly LIGHTMAP_DEFAULT: number;
  68545. /**
  68546. * material.lightmapTexture as only diffuse lighting from this light
  68547. * adds only specular lighting from this light
  68548. * adds dynamic shadows
  68549. */
  68550. static readonly LIGHTMAP_SPECULAR: number;
  68551. /**
  68552. * material.lightmapTexture as only lighting
  68553. * no light calculation from this light
  68554. * only adds dynamic shadows from this light
  68555. */
  68556. static readonly LIGHTMAP_SHADOWSONLY: number;
  68557. /**
  68558. * Each light type uses the default quantity according to its type:
  68559. * point/spot lights use luminous intensity
  68560. * directional lights use illuminance
  68561. */
  68562. static readonly INTENSITYMODE_AUTOMATIC: number;
  68563. /**
  68564. * lumen (lm)
  68565. */
  68566. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68567. /**
  68568. * candela (lm/sr)
  68569. */
  68570. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68571. /**
  68572. * lux (lm/m^2)
  68573. */
  68574. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68575. /**
  68576. * nit (cd/m^2)
  68577. */
  68578. static readonly INTENSITYMODE_LUMINANCE: number;
  68579. /**
  68580. * Light type const id of the point light.
  68581. */
  68582. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68583. /**
  68584. * Light type const id of the directional light.
  68585. */
  68586. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68587. /**
  68588. * Light type const id of the spot light.
  68589. */
  68590. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68591. /**
  68592. * Light type const id of the hemispheric light.
  68593. */
  68594. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68595. /**
  68596. * Diffuse gives the basic color to an object.
  68597. */
  68598. diffuse: Color3;
  68599. /**
  68600. * Specular produces a highlight color on an object.
  68601. * Note: This is note affecting PBR materials.
  68602. */
  68603. specular: Color3;
  68604. /**
  68605. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68606. * falling off base on range or angle.
  68607. * This can be set to any values in Light.FALLOFF_x.
  68608. *
  68609. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68610. * other types of materials.
  68611. */
  68612. falloffType: number;
  68613. /**
  68614. * Strength of the light.
  68615. * Note: By default it is define in the framework own unit.
  68616. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68617. */
  68618. intensity: number;
  68619. private _range;
  68620. protected _inverseSquaredRange: number;
  68621. /**
  68622. * Defines how far from the source the light is impacting in scene units.
  68623. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68624. */
  68625. /**
  68626. * Defines how far from the source the light is impacting in scene units.
  68627. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68628. */
  68629. range: number;
  68630. /**
  68631. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68632. * of light.
  68633. */
  68634. private _photometricScale;
  68635. private _intensityMode;
  68636. /**
  68637. * Gets the photometric scale used to interpret the intensity.
  68638. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68639. */
  68640. /**
  68641. * Sets the photometric scale used to interpret the intensity.
  68642. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68643. */
  68644. intensityMode: number;
  68645. private _radius;
  68646. /**
  68647. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68648. */
  68649. /**
  68650. * sets the light radius used by PBR Materials to simulate soft area lights.
  68651. */
  68652. radius: number;
  68653. private _renderPriority;
  68654. /**
  68655. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68656. * exceeding the number allowed of the materials.
  68657. */
  68658. renderPriority: number;
  68659. private _shadowEnabled;
  68660. /**
  68661. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68662. * the current shadow generator.
  68663. */
  68664. /**
  68665. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68666. * the current shadow generator.
  68667. */
  68668. shadowEnabled: boolean;
  68669. private _includedOnlyMeshes;
  68670. /**
  68671. * Gets the only meshes impacted by this light.
  68672. */
  68673. /**
  68674. * Sets the only meshes impacted by this light.
  68675. */
  68676. includedOnlyMeshes: AbstractMesh[];
  68677. private _excludedMeshes;
  68678. /**
  68679. * Gets the meshes not impacted by this light.
  68680. */
  68681. /**
  68682. * Sets the meshes not impacted by this light.
  68683. */
  68684. excludedMeshes: AbstractMesh[];
  68685. private _excludeWithLayerMask;
  68686. /**
  68687. * Gets the layer id use to find what meshes are not impacted by the light.
  68688. * Inactive if 0
  68689. */
  68690. /**
  68691. * Sets the layer id use to find what meshes are not impacted by the light.
  68692. * Inactive if 0
  68693. */
  68694. excludeWithLayerMask: number;
  68695. private _includeOnlyWithLayerMask;
  68696. /**
  68697. * Gets the layer id use to find what meshes are impacted by the light.
  68698. * Inactive if 0
  68699. */
  68700. /**
  68701. * Sets the layer id use to find what meshes are impacted by the light.
  68702. * Inactive if 0
  68703. */
  68704. includeOnlyWithLayerMask: number;
  68705. private _lightmapMode;
  68706. /**
  68707. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68708. */
  68709. /**
  68710. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68711. */
  68712. lightmapMode: number;
  68713. /**
  68714. * Shadow generator associted to the light.
  68715. * @hidden Internal use only.
  68716. */
  68717. _shadowGenerator: Nullable<IShadowGenerator>;
  68718. /**
  68719. * @hidden Internal use only.
  68720. */
  68721. _excludedMeshesIds: string[];
  68722. /**
  68723. * @hidden Internal use only.
  68724. */
  68725. _includedOnlyMeshesIds: string[];
  68726. /**
  68727. * The current light unifom buffer.
  68728. * @hidden Internal use only.
  68729. */
  68730. _uniformBuffer: UniformBuffer;
  68731. /**
  68732. * Creates a Light object in the scene.
  68733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68734. * @param name The firendly name of the light
  68735. * @param scene The scene the light belongs too
  68736. */
  68737. constructor(name: string, scene: Scene);
  68738. protected abstract _buildUniformLayout(): void;
  68739. /**
  68740. * Sets the passed Effect "effect" with the Light information.
  68741. * @param effect The effect to update
  68742. * @param lightIndex The index of the light in the effect to update
  68743. * @returns The light
  68744. */
  68745. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68746. /**
  68747. * Returns the string "Light".
  68748. * @returns the class name
  68749. */
  68750. getClassName(): string;
  68751. /** @hidden */
  68752. readonly _isLight: boolean;
  68753. /**
  68754. * Converts the light information to a readable string for debug purpose.
  68755. * @param fullDetails Supports for multiple levels of logging within scene loading
  68756. * @returns the human readable light info
  68757. */
  68758. toString(fullDetails?: boolean): string;
  68759. /** @hidden */
  68760. protected _syncParentEnabledState(): void;
  68761. /**
  68762. * Set the enabled state of this node.
  68763. * @param value - the new enabled state
  68764. */
  68765. setEnabled(value: boolean): void;
  68766. /**
  68767. * Returns the Light associated shadow generator if any.
  68768. * @return the associated shadow generator.
  68769. */
  68770. getShadowGenerator(): Nullable<IShadowGenerator>;
  68771. /**
  68772. * Returns a Vector3, the absolute light position in the World.
  68773. * @returns the world space position of the light
  68774. */
  68775. getAbsolutePosition(): Vector3;
  68776. /**
  68777. * Specifies if the light will affect the passed mesh.
  68778. * @param mesh The mesh to test against the light
  68779. * @return true the mesh is affected otherwise, false.
  68780. */
  68781. canAffectMesh(mesh: AbstractMesh): boolean;
  68782. /**
  68783. * Sort function to order lights for rendering.
  68784. * @param a First Light object to compare to second.
  68785. * @param b Second Light object to compare first.
  68786. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68787. */
  68788. static CompareLightsPriority(a: Light, b: Light): number;
  68789. /**
  68790. * Releases resources associated with this node.
  68791. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68792. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68793. */
  68794. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68795. /**
  68796. * Returns the light type ID (integer).
  68797. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68798. */
  68799. getTypeID(): number;
  68800. /**
  68801. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68802. * @returns the scaled intensity in intensity mode unit
  68803. */
  68804. getScaledIntensity(): number;
  68805. /**
  68806. * Returns a new Light object, named "name", from the current one.
  68807. * @param name The name of the cloned light
  68808. * @returns the new created light
  68809. */
  68810. clone(name: string): Nullable<Light>;
  68811. /**
  68812. * Serializes the current light into a Serialization object.
  68813. * @returns the serialized object.
  68814. */
  68815. serialize(): any;
  68816. /**
  68817. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68818. * This new light is named "name" and added to the passed scene.
  68819. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68820. * @param name The friendly name of the light
  68821. * @param scene The scene the new light will belong to
  68822. * @returns the constructor function
  68823. */
  68824. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68825. /**
  68826. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68827. * @param parsedLight The JSON representation of the light
  68828. * @param scene The scene to create the parsed light in
  68829. * @returns the created light after parsing
  68830. */
  68831. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68832. private _hookArrayForExcluded;
  68833. private _hookArrayForIncludedOnly;
  68834. private _resyncMeshes;
  68835. /**
  68836. * Forces the meshes to update their light related information in their rendering used effects
  68837. * @hidden Internal Use Only
  68838. */
  68839. _markMeshesAsLightDirty(): void;
  68840. /**
  68841. * Recomputes the cached photometric scale if needed.
  68842. */
  68843. private _computePhotometricScale;
  68844. /**
  68845. * Returns the Photometric Scale according to the light type and intensity mode.
  68846. */
  68847. private _getPhotometricScale;
  68848. /**
  68849. * Reorder the light in the scene according to their defined priority.
  68850. * @hidden Internal Use Only
  68851. */
  68852. _reorderLightsInScene(): void;
  68853. /**
  68854. * Prepares the list of defines specific to the light type.
  68855. * @param defines the list of defines
  68856. * @param lightIndex defines the index of the light for the effect
  68857. */
  68858. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68859. }
  68860. }
  68861. declare module BABYLON {
  68862. /**
  68863. * Interface used to define Action
  68864. */
  68865. export interface IAction {
  68866. /**
  68867. * Trigger for the action
  68868. */
  68869. trigger: number;
  68870. /** Options of the trigger */
  68871. triggerOptions: any;
  68872. /**
  68873. * Gets the trigger parameters
  68874. * @returns the trigger parameters
  68875. */
  68876. getTriggerParameter(): any;
  68877. /**
  68878. * Internal only - executes current action event
  68879. * @hidden
  68880. */
  68881. _executeCurrent(evt?: ActionEvent): void;
  68882. /**
  68883. * Serialize placeholder for child classes
  68884. * @param parent of child
  68885. * @returns the serialized object
  68886. */
  68887. serialize(parent: any): any;
  68888. /**
  68889. * Internal only
  68890. * @hidden
  68891. */
  68892. _prepare(): void;
  68893. /**
  68894. * Internal only - manager for action
  68895. * @hidden
  68896. */
  68897. _actionManager: AbstractActionManager;
  68898. }
  68899. /**
  68900. * The action to be carried out following a trigger
  68901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68902. */
  68903. export class Action implements IAction {
  68904. /** the trigger, with or without parameters, for the action */
  68905. triggerOptions: any;
  68906. /**
  68907. * Trigger for the action
  68908. */
  68909. trigger: number;
  68910. /**
  68911. * Internal only - manager for action
  68912. * @hidden
  68913. */
  68914. _actionManager: ActionManager;
  68915. private _nextActiveAction;
  68916. private _child;
  68917. private _condition?;
  68918. private _triggerParameter;
  68919. /**
  68920. * An event triggered prior to action being executed.
  68921. */
  68922. onBeforeExecuteObservable: Observable<Action>;
  68923. /**
  68924. * Creates a new Action
  68925. * @param triggerOptions the trigger, with or without parameters, for the action
  68926. * @param condition an optional determinant of action
  68927. */
  68928. constructor(
  68929. /** the trigger, with or without parameters, for the action */
  68930. triggerOptions: any, condition?: Condition);
  68931. /**
  68932. * Internal only
  68933. * @hidden
  68934. */
  68935. _prepare(): void;
  68936. /**
  68937. * Gets the trigger parameters
  68938. * @returns the trigger parameters
  68939. */
  68940. getTriggerParameter(): any;
  68941. /**
  68942. * Internal only - executes current action event
  68943. * @hidden
  68944. */
  68945. _executeCurrent(evt?: ActionEvent): void;
  68946. /**
  68947. * Execute placeholder for child classes
  68948. * @param evt optional action event
  68949. */
  68950. execute(evt?: ActionEvent): void;
  68951. /**
  68952. * Skips to next active action
  68953. */
  68954. skipToNextActiveAction(): void;
  68955. /**
  68956. * Adds action to chain of actions, may be a DoNothingAction
  68957. * @param action defines the next action to execute
  68958. * @returns The action passed in
  68959. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68960. */
  68961. then(action: Action): Action;
  68962. /**
  68963. * Internal only
  68964. * @hidden
  68965. */
  68966. _getProperty(propertyPath: string): string;
  68967. /**
  68968. * Internal only
  68969. * @hidden
  68970. */
  68971. _getEffectiveTarget(target: any, propertyPath: string): any;
  68972. /**
  68973. * Serialize placeholder for child classes
  68974. * @param parent of child
  68975. * @returns the serialized object
  68976. */
  68977. serialize(parent: any): any;
  68978. /**
  68979. * Internal only called by serialize
  68980. * @hidden
  68981. */
  68982. protected _serialize(serializedAction: any, parent?: any): any;
  68983. /**
  68984. * Internal only
  68985. * @hidden
  68986. */
  68987. static _SerializeValueAsString: (value: any) => string;
  68988. /**
  68989. * Internal only
  68990. * @hidden
  68991. */
  68992. static _GetTargetProperty: (target: Scene | Node) => {
  68993. name: string;
  68994. targetType: string;
  68995. value: string;
  68996. };
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /**
  69001. * A Condition applied to an Action
  69002. */
  69003. export class Condition {
  69004. /**
  69005. * Internal only - manager for action
  69006. * @hidden
  69007. */
  69008. _actionManager: ActionManager;
  69009. /**
  69010. * Internal only
  69011. * @hidden
  69012. */
  69013. _evaluationId: number;
  69014. /**
  69015. * Internal only
  69016. * @hidden
  69017. */
  69018. _currentResult: boolean;
  69019. /**
  69020. * Creates a new Condition
  69021. * @param actionManager the manager of the action the condition is applied to
  69022. */
  69023. constructor(actionManager: ActionManager);
  69024. /**
  69025. * Check if the current condition is valid
  69026. * @returns a boolean
  69027. */
  69028. isValid(): boolean;
  69029. /**
  69030. * Internal only
  69031. * @hidden
  69032. */
  69033. _getProperty(propertyPath: string): string;
  69034. /**
  69035. * Internal only
  69036. * @hidden
  69037. */
  69038. _getEffectiveTarget(target: any, propertyPath: string): any;
  69039. /**
  69040. * Serialize placeholder for child classes
  69041. * @returns the serialized object
  69042. */
  69043. serialize(): any;
  69044. /**
  69045. * Internal only
  69046. * @hidden
  69047. */
  69048. protected _serialize(serializedCondition: any): any;
  69049. }
  69050. /**
  69051. * Defines specific conditional operators as extensions of Condition
  69052. */
  69053. export class ValueCondition extends Condition {
  69054. /** path to specify the property of the target the conditional operator uses */
  69055. propertyPath: string;
  69056. /** the value compared by the conditional operator against the current value of the property */
  69057. value: any;
  69058. /** the conditional operator, default ValueCondition.IsEqual */
  69059. operator: number;
  69060. /**
  69061. * Internal only
  69062. * @hidden
  69063. */
  69064. private static _IsEqual;
  69065. /**
  69066. * Internal only
  69067. * @hidden
  69068. */
  69069. private static _IsDifferent;
  69070. /**
  69071. * Internal only
  69072. * @hidden
  69073. */
  69074. private static _IsGreater;
  69075. /**
  69076. * Internal only
  69077. * @hidden
  69078. */
  69079. private static _IsLesser;
  69080. /**
  69081. * returns the number for IsEqual
  69082. */
  69083. static readonly IsEqual: number;
  69084. /**
  69085. * Returns the number for IsDifferent
  69086. */
  69087. static readonly IsDifferent: number;
  69088. /**
  69089. * Returns the number for IsGreater
  69090. */
  69091. static readonly IsGreater: number;
  69092. /**
  69093. * Returns the number for IsLesser
  69094. */
  69095. static readonly IsLesser: number;
  69096. /**
  69097. * Internal only The action manager for the condition
  69098. * @hidden
  69099. */
  69100. _actionManager: ActionManager;
  69101. /**
  69102. * Internal only
  69103. * @hidden
  69104. */
  69105. private _target;
  69106. /**
  69107. * Internal only
  69108. * @hidden
  69109. */
  69110. private _effectiveTarget;
  69111. /**
  69112. * Internal only
  69113. * @hidden
  69114. */
  69115. private _property;
  69116. /**
  69117. * Creates a new ValueCondition
  69118. * @param actionManager manager for the action the condition applies to
  69119. * @param target for the action
  69120. * @param propertyPath path to specify the property of the target the conditional operator uses
  69121. * @param value the value compared by the conditional operator against the current value of the property
  69122. * @param operator the conditional operator, default ValueCondition.IsEqual
  69123. */
  69124. constructor(actionManager: ActionManager, target: any,
  69125. /** path to specify the property of the target the conditional operator uses */
  69126. propertyPath: string,
  69127. /** the value compared by the conditional operator against the current value of the property */
  69128. value: any,
  69129. /** the conditional operator, default ValueCondition.IsEqual */
  69130. operator?: number);
  69131. /**
  69132. * Compares the given value with the property value for the specified conditional operator
  69133. * @returns the result of the comparison
  69134. */
  69135. isValid(): boolean;
  69136. /**
  69137. * Serialize the ValueCondition into a JSON compatible object
  69138. * @returns serialization object
  69139. */
  69140. serialize(): any;
  69141. /**
  69142. * Gets the name of the conditional operator for the ValueCondition
  69143. * @param operator the conditional operator
  69144. * @returns the name
  69145. */
  69146. static GetOperatorName(operator: number): string;
  69147. }
  69148. /**
  69149. * Defines a predicate condition as an extension of Condition
  69150. */
  69151. export class PredicateCondition extends Condition {
  69152. /** defines the predicate function used to validate the condition */
  69153. predicate: () => boolean;
  69154. /**
  69155. * Internal only - manager for action
  69156. * @hidden
  69157. */
  69158. _actionManager: ActionManager;
  69159. /**
  69160. * Creates a new PredicateCondition
  69161. * @param actionManager manager for the action the condition applies to
  69162. * @param predicate defines the predicate function used to validate the condition
  69163. */
  69164. constructor(actionManager: ActionManager,
  69165. /** defines the predicate function used to validate the condition */
  69166. predicate: () => boolean);
  69167. /**
  69168. * @returns the validity of the predicate condition
  69169. */
  69170. isValid(): boolean;
  69171. }
  69172. /**
  69173. * Defines a state condition as an extension of Condition
  69174. */
  69175. export class StateCondition extends Condition {
  69176. /** Value to compare with target state */
  69177. value: string;
  69178. /**
  69179. * Internal only - manager for action
  69180. * @hidden
  69181. */
  69182. _actionManager: ActionManager;
  69183. /**
  69184. * Internal only
  69185. * @hidden
  69186. */
  69187. private _target;
  69188. /**
  69189. * Creates a new StateCondition
  69190. * @param actionManager manager for the action the condition applies to
  69191. * @param target of the condition
  69192. * @param value to compare with target state
  69193. */
  69194. constructor(actionManager: ActionManager, target: any,
  69195. /** Value to compare with target state */
  69196. value: string);
  69197. /**
  69198. * Gets a boolean indicating if the current condition is met
  69199. * @returns the validity of the state
  69200. */
  69201. isValid(): boolean;
  69202. /**
  69203. * Serialize the StateCondition into a JSON compatible object
  69204. * @returns serialization object
  69205. */
  69206. serialize(): any;
  69207. }
  69208. }
  69209. declare module BABYLON {
  69210. /**
  69211. * This defines an action responsible to toggle a boolean once triggered.
  69212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69213. */
  69214. export class SwitchBooleanAction extends Action {
  69215. /**
  69216. * The path to the boolean property in the target object
  69217. */
  69218. propertyPath: string;
  69219. private _target;
  69220. private _effectiveTarget;
  69221. private _property;
  69222. /**
  69223. * Instantiate the action
  69224. * @param triggerOptions defines the trigger options
  69225. * @param target defines the object containing the boolean
  69226. * @param propertyPath defines the path to the boolean property in the target object
  69227. * @param condition defines the trigger related conditions
  69228. */
  69229. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69230. /** @hidden */
  69231. _prepare(): void;
  69232. /**
  69233. * Execute the action toggle the boolean value.
  69234. */
  69235. execute(): void;
  69236. /**
  69237. * Serializes the actions and its related information.
  69238. * @param parent defines the object to serialize in
  69239. * @returns the serialized object
  69240. */
  69241. serialize(parent: any): any;
  69242. }
  69243. /**
  69244. * This defines an action responsible to set a the state field of the target
  69245. * to a desired value once triggered.
  69246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69247. */
  69248. export class SetStateAction extends Action {
  69249. /**
  69250. * The value to store in the state field.
  69251. */
  69252. value: string;
  69253. private _target;
  69254. /**
  69255. * Instantiate the action
  69256. * @param triggerOptions defines the trigger options
  69257. * @param target defines the object containing the state property
  69258. * @param value defines the value to store in the state field
  69259. * @param condition defines the trigger related conditions
  69260. */
  69261. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69262. /**
  69263. * Execute the action and store the value on the target state property.
  69264. */
  69265. execute(): void;
  69266. /**
  69267. * Serializes the actions and its related information.
  69268. * @param parent defines the object to serialize in
  69269. * @returns the serialized object
  69270. */
  69271. serialize(parent: any): any;
  69272. }
  69273. /**
  69274. * This defines an action responsible to set a property of the target
  69275. * to a desired value once triggered.
  69276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69277. */
  69278. export class SetValueAction extends Action {
  69279. /**
  69280. * The path of the property to set in the target.
  69281. */
  69282. propertyPath: string;
  69283. /**
  69284. * The value to set in the property
  69285. */
  69286. value: any;
  69287. private _target;
  69288. private _effectiveTarget;
  69289. private _property;
  69290. /**
  69291. * Instantiate the action
  69292. * @param triggerOptions defines the trigger options
  69293. * @param target defines the object containing the property
  69294. * @param propertyPath defines the path of the property to set in the target
  69295. * @param value defines the value to set in the property
  69296. * @param condition defines the trigger related conditions
  69297. */
  69298. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69299. /** @hidden */
  69300. _prepare(): void;
  69301. /**
  69302. * Execute the action and set the targetted property to the desired value.
  69303. */
  69304. execute(): void;
  69305. /**
  69306. * Serializes the actions and its related information.
  69307. * @param parent defines the object to serialize in
  69308. * @returns the serialized object
  69309. */
  69310. serialize(parent: any): any;
  69311. }
  69312. /**
  69313. * This defines an action responsible to increment the target value
  69314. * to a desired value once triggered.
  69315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69316. */
  69317. export class IncrementValueAction extends Action {
  69318. /**
  69319. * The path of the property to increment in the target.
  69320. */
  69321. propertyPath: string;
  69322. /**
  69323. * The value we should increment the property by.
  69324. */
  69325. value: any;
  69326. private _target;
  69327. private _effectiveTarget;
  69328. private _property;
  69329. /**
  69330. * Instantiate the action
  69331. * @param triggerOptions defines the trigger options
  69332. * @param target defines the object containing the property
  69333. * @param propertyPath defines the path of the property to increment in the target
  69334. * @param value defines the value value we should increment the property by
  69335. * @param condition defines the trigger related conditions
  69336. */
  69337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69338. /** @hidden */
  69339. _prepare(): void;
  69340. /**
  69341. * Execute the action and increment the target of the value amount.
  69342. */
  69343. execute(): void;
  69344. /**
  69345. * Serializes the actions and its related information.
  69346. * @param parent defines the object to serialize in
  69347. * @returns the serialized object
  69348. */
  69349. serialize(parent: any): any;
  69350. }
  69351. /**
  69352. * This defines an action responsible to start an animation once triggered.
  69353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69354. */
  69355. export class PlayAnimationAction extends Action {
  69356. /**
  69357. * Where the animation should start (animation frame)
  69358. */
  69359. from: number;
  69360. /**
  69361. * Where the animation should stop (animation frame)
  69362. */
  69363. to: number;
  69364. /**
  69365. * Define if the animation should loop or stop after the first play.
  69366. */
  69367. loop?: boolean;
  69368. private _target;
  69369. /**
  69370. * Instantiate the action
  69371. * @param triggerOptions defines the trigger options
  69372. * @param target defines the target animation or animation name
  69373. * @param from defines from where the animation should start (animation frame)
  69374. * @param end defines where the animation should stop (animation frame)
  69375. * @param loop defines if the animation should loop or stop after the first play
  69376. * @param condition defines the trigger related conditions
  69377. */
  69378. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69379. /** @hidden */
  69380. _prepare(): void;
  69381. /**
  69382. * Execute the action and play the animation.
  69383. */
  69384. execute(): void;
  69385. /**
  69386. * Serializes the actions and its related information.
  69387. * @param parent defines the object to serialize in
  69388. * @returns the serialized object
  69389. */
  69390. serialize(parent: any): any;
  69391. }
  69392. /**
  69393. * This defines an action responsible to stop an animation once triggered.
  69394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69395. */
  69396. export class StopAnimationAction extends Action {
  69397. private _target;
  69398. /**
  69399. * Instantiate the action
  69400. * @param triggerOptions defines the trigger options
  69401. * @param target defines the target animation or animation name
  69402. * @param condition defines the trigger related conditions
  69403. */
  69404. constructor(triggerOptions: any, target: any, condition?: Condition);
  69405. /** @hidden */
  69406. _prepare(): void;
  69407. /**
  69408. * Execute the action and stop the animation.
  69409. */
  69410. execute(): void;
  69411. /**
  69412. * Serializes the actions and its related information.
  69413. * @param parent defines the object to serialize in
  69414. * @returns the serialized object
  69415. */
  69416. serialize(parent: any): any;
  69417. }
  69418. /**
  69419. * This defines an action responsible that does nothing once triggered.
  69420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69421. */
  69422. export class DoNothingAction extends Action {
  69423. /**
  69424. * Instantiate the action
  69425. * @param triggerOptions defines the trigger options
  69426. * @param condition defines the trigger related conditions
  69427. */
  69428. constructor(triggerOptions?: any, condition?: Condition);
  69429. /**
  69430. * Execute the action and do nothing.
  69431. */
  69432. execute(): void;
  69433. /**
  69434. * Serializes the actions and its related information.
  69435. * @param parent defines the object to serialize in
  69436. * @returns the serialized object
  69437. */
  69438. serialize(parent: any): any;
  69439. }
  69440. /**
  69441. * This defines an action responsible to trigger several actions once triggered.
  69442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69443. */
  69444. export class CombineAction extends Action {
  69445. /**
  69446. * The list of aggregated animations to run.
  69447. */
  69448. children: Action[];
  69449. /**
  69450. * Instantiate the action
  69451. * @param triggerOptions defines the trigger options
  69452. * @param children defines the list of aggregated animations to run
  69453. * @param condition defines the trigger related conditions
  69454. */
  69455. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69456. /** @hidden */
  69457. _prepare(): void;
  69458. /**
  69459. * Execute the action and executes all the aggregated actions.
  69460. */
  69461. execute(evt: ActionEvent): void;
  69462. /**
  69463. * Serializes the actions and its related information.
  69464. * @param parent defines the object to serialize in
  69465. * @returns the serialized object
  69466. */
  69467. serialize(parent: any): any;
  69468. }
  69469. /**
  69470. * This defines an action responsible to run code (external event) once triggered.
  69471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69472. */
  69473. export class ExecuteCodeAction extends Action {
  69474. /**
  69475. * The callback function to run.
  69476. */
  69477. func: (evt: ActionEvent) => void;
  69478. /**
  69479. * Instantiate the action
  69480. * @param triggerOptions defines the trigger options
  69481. * @param func defines the callback function to run
  69482. * @param condition defines the trigger related conditions
  69483. */
  69484. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69485. /**
  69486. * Execute the action and run the attached code.
  69487. */
  69488. execute(evt: ActionEvent): void;
  69489. }
  69490. /**
  69491. * This defines an action responsible to set the parent property of the target once triggered.
  69492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69493. */
  69494. export class SetParentAction extends Action {
  69495. private _parent;
  69496. private _target;
  69497. /**
  69498. * Instantiate the action
  69499. * @param triggerOptions defines the trigger options
  69500. * @param target defines the target containing the parent property
  69501. * @param parent defines from where the animation should start (animation frame)
  69502. * @param condition defines the trigger related conditions
  69503. */
  69504. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69505. /** @hidden */
  69506. _prepare(): void;
  69507. /**
  69508. * Execute the action and set the parent property.
  69509. */
  69510. execute(): void;
  69511. /**
  69512. * Serializes the actions and its related information.
  69513. * @param parent defines the object to serialize in
  69514. * @returns the serialized object
  69515. */
  69516. serialize(parent: any): any;
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. /**
  69521. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69522. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69524. */
  69525. export class ActionManager extends AbstractActionManager {
  69526. /**
  69527. * Nothing
  69528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69529. */
  69530. static readonly NothingTrigger: number;
  69531. /**
  69532. * On pick
  69533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69534. */
  69535. static readonly OnPickTrigger: number;
  69536. /**
  69537. * On left pick
  69538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69539. */
  69540. static readonly OnLeftPickTrigger: number;
  69541. /**
  69542. * On right pick
  69543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69544. */
  69545. static readonly OnRightPickTrigger: number;
  69546. /**
  69547. * On center pick
  69548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69549. */
  69550. static readonly OnCenterPickTrigger: number;
  69551. /**
  69552. * On pick down
  69553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69554. */
  69555. static readonly OnPickDownTrigger: number;
  69556. /**
  69557. * On double pick
  69558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69559. */
  69560. static readonly OnDoublePickTrigger: number;
  69561. /**
  69562. * On pick up
  69563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69564. */
  69565. static readonly OnPickUpTrigger: number;
  69566. /**
  69567. * On pick out.
  69568. * This trigger will only be raised if you also declared a OnPickDown
  69569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69570. */
  69571. static readonly OnPickOutTrigger: number;
  69572. /**
  69573. * On long press
  69574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69575. */
  69576. static readonly OnLongPressTrigger: number;
  69577. /**
  69578. * On pointer over
  69579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69580. */
  69581. static readonly OnPointerOverTrigger: number;
  69582. /**
  69583. * On pointer out
  69584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69585. */
  69586. static readonly OnPointerOutTrigger: number;
  69587. /**
  69588. * On every frame
  69589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69590. */
  69591. static readonly OnEveryFrameTrigger: number;
  69592. /**
  69593. * On intersection enter
  69594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69595. */
  69596. static readonly OnIntersectionEnterTrigger: number;
  69597. /**
  69598. * On intersection exit
  69599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69600. */
  69601. static readonly OnIntersectionExitTrigger: number;
  69602. /**
  69603. * On key down
  69604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69605. */
  69606. static readonly OnKeyDownTrigger: number;
  69607. /**
  69608. * On key up
  69609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69610. */
  69611. static readonly OnKeyUpTrigger: number;
  69612. private _scene;
  69613. /**
  69614. * Creates a new action manager
  69615. * @param scene defines the hosting scene
  69616. */
  69617. constructor(scene: Scene);
  69618. /**
  69619. * Releases all associated resources
  69620. */
  69621. dispose(): void;
  69622. /**
  69623. * Gets hosting scene
  69624. * @returns the hosting scene
  69625. */
  69626. getScene(): Scene;
  69627. /**
  69628. * Does this action manager handles actions of any of the given triggers
  69629. * @param triggers defines the triggers to be tested
  69630. * @return a boolean indicating whether one (or more) of the triggers is handled
  69631. */
  69632. hasSpecificTriggers(triggers: number[]): boolean;
  69633. /**
  69634. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69635. * speed.
  69636. * @param triggerA defines the trigger to be tested
  69637. * @param triggerB defines the trigger to be tested
  69638. * @return a boolean indicating whether one (or more) of the triggers is handled
  69639. */
  69640. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69641. /**
  69642. * Does this action manager handles actions of a given trigger
  69643. * @param trigger defines the trigger to be tested
  69644. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69645. * @return whether the trigger is handled
  69646. */
  69647. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69648. /**
  69649. * Does this action manager has pointer triggers
  69650. */
  69651. readonly hasPointerTriggers: boolean;
  69652. /**
  69653. * Does this action manager has pick triggers
  69654. */
  69655. readonly hasPickTriggers: boolean;
  69656. /**
  69657. * Registers an action to this action manager
  69658. * @param action defines the action to be registered
  69659. * @return the action amended (prepared) after registration
  69660. */
  69661. registerAction(action: IAction): Nullable<IAction>;
  69662. /**
  69663. * Unregisters an action to this action manager
  69664. * @param action defines the action to be unregistered
  69665. * @return a boolean indicating whether the action has been unregistered
  69666. */
  69667. unregisterAction(action: IAction): Boolean;
  69668. /**
  69669. * Process a specific trigger
  69670. * @param trigger defines the trigger to process
  69671. * @param evt defines the event details to be processed
  69672. */
  69673. processTrigger(trigger: number, evt?: IActionEvent): void;
  69674. /** @hidden */
  69675. _getEffectiveTarget(target: any, propertyPath: string): any;
  69676. /** @hidden */
  69677. _getProperty(propertyPath: string): string;
  69678. /**
  69679. * Serialize this manager to a JSON object
  69680. * @param name defines the property name to store this manager
  69681. * @returns a JSON representation of this manager
  69682. */
  69683. serialize(name: string): any;
  69684. /**
  69685. * Creates a new ActionManager from a JSON data
  69686. * @param parsedActions defines the JSON data to read from
  69687. * @param object defines the hosting mesh
  69688. * @param scene defines the hosting scene
  69689. */
  69690. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69691. /**
  69692. * Get a trigger name by index
  69693. * @param trigger defines the trigger index
  69694. * @returns a trigger name
  69695. */
  69696. static GetTriggerName(trigger: number): string;
  69697. }
  69698. }
  69699. declare module BABYLON {
  69700. /**
  69701. * Class representing a ray with position and direction
  69702. */
  69703. export class Ray {
  69704. /** origin point */
  69705. origin: Vector3;
  69706. /** direction */
  69707. direction: Vector3;
  69708. /** length of the ray */
  69709. length: number;
  69710. private static readonly TmpVector3;
  69711. private _tmpRay;
  69712. /**
  69713. * Creates a new ray
  69714. * @param origin origin point
  69715. * @param direction direction
  69716. * @param length length of the ray
  69717. */
  69718. constructor(
  69719. /** origin point */
  69720. origin: Vector3,
  69721. /** direction */
  69722. direction: Vector3,
  69723. /** length of the ray */
  69724. length?: number);
  69725. /**
  69726. * Checks if the ray intersects a box
  69727. * @param minimum bound of the box
  69728. * @param maximum bound of the box
  69729. * @param intersectionTreshold extra extend to be added to the box in all direction
  69730. * @returns if the box was hit
  69731. */
  69732. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69733. /**
  69734. * Checks if the ray intersects a box
  69735. * @param box the bounding box to check
  69736. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69737. * @returns if the box was hit
  69738. */
  69739. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69740. /**
  69741. * If the ray hits a sphere
  69742. * @param sphere the bounding sphere to check
  69743. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69744. * @returns true if it hits the sphere
  69745. */
  69746. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69747. /**
  69748. * If the ray hits a triange
  69749. * @param vertex0 triangle vertex
  69750. * @param vertex1 triangle vertex
  69751. * @param vertex2 triangle vertex
  69752. * @returns intersection information if hit
  69753. */
  69754. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69755. /**
  69756. * Checks if ray intersects a plane
  69757. * @param plane the plane to check
  69758. * @returns the distance away it was hit
  69759. */
  69760. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69761. /**
  69762. * Checks if ray intersects a mesh
  69763. * @param mesh the mesh to check
  69764. * @param fastCheck if only the bounding box should checked
  69765. * @returns picking info of the intersecton
  69766. */
  69767. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69768. /**
  69769. * Checks if ray intersects a mesh
  69770. * @param meshes the meshes to check
  69771. * @param fastCheck if only the bounding box should checked
  69772. * @param results array to store result in
  69773. * @returns Array of picking infos
  69774. */
  69775. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69776. private _comparePickingInfo;
  69777. private static smallnum;
  69778. private static rayl;
  69779. /**
  69780. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69781. * @param sega the first point of the segment to test the intersection against
  69782. * @param segb the second point of the segment to test the intersection against
  69783. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69784. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69785. */
  69786. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69787. /**
  69788. * Update the ray from viewport position
  69789. * @param x position
  69790. * @param y y position
  69791. * @param viewportWidth viewport width
  69792. * @param viewportHeight viewport height
  69793. * @param world world matrix
  69794. * @param view view matrix
  69795. * @param projection projection matrix
  69796. * @returns this ray updated
  69797. */
  69798. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69799. /**
  69800. * Creates a ray with origin and direction of 0,0,0
  69801. * @returns the new ray
  69802. */
  69803. static Zero(): Ray;
  69804. /**
  69805. * Creates a new ray from screen space and viewport
  69806. * @param x position
  69807. * @param y y position
  69808. * @param viewportWidth viewport width
  69809. * @param viewportHeight viewport height
  69810. * @param world world matrix
  69811. * @param view view matrix
  69812. * @param projection projection matrix
  69813. * @returns new ray
  69814. */
  69815. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69816. /**
  69817. * 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
  69818. * transformed to the given world matrix.
  69819. * @param origin The origin point
  69820. * @param end The end point
  69821. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69822. * @returns the new ray
  69823. */
  69824. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69825. /**
  69826. * Transforms a ray by a matrix
  69827. * @param ray ray to transform
  69828. * @param matrix matrix to apply
  69829. * @returns the resulting new ray
  69830. */
  69831. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69832. /**
  69833. * Transforms a ray by a matrix
  69834. * @param ray ray to transform
  69835. * @param matrix matrix to apply
  69836. * @param result ray to store result in
  69837. */
  69838. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69839. /**
  69840. * Unproject a ray from screen space to object space
  69841. * @param sourceX defines the screen space x coordinate to use
  69842. * @param sourceY defines the screen space y coordinate to use
  69843. * @param viewportWidth defines the current width of the viewport
  69844. * @param viewportHeight defines the current height of the viewport
  69845. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69846. * @param view defines the view matrix to use
  69847. * @param projection defines the projection matrix to use
  69848. */
  69849. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69850. }
  69851. /**
  69852. * Type used to define predicate used to select faces when a mesh intersection is detected
  69853. */
  69854. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69855. interface Scene {
  69856. /** @hidden */
  69857. _tempPickingRay: Nullable<Ray>;
  69858. /** @hidden */
  69859. _cachedRayForTransform: Ray;
  69860. /** @hidden */
  69861. _pickWithRayInverseMatrix: Matrix;
  69862. /** @hidden */
  69863. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69864. /** @hidden */
  69865. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69866. }
  69867. }
  69868. declare module BABYLON {
  69869. /**
  69870. * Groups all the scene component constants in one place to ease maintenance.
  69871. * @hidden
  69872. */
  69873. export class SceneComponentConstants {
  69874. static readonly NAME_EFFECTLAYER: string;
  69875. static readonly NAME_LAYER: string;
  69876. static readonly NAME_LENSFLARESYSTEM: string;
  69877. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69878. static readonly NAME_PARTICLESYSTEM: string;
  69879. static readonly NAME_GAMEPAD: string;
  69880. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69881. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69882. static readonly NAME_DEPTHRENDERER: string;
  69883. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69884. static readonly NAME_SPRITE: string;
  69885. static readonly NAME_OUTLINERENDERER: string;
  69886. static readonly NAME_PROCEDURALTEXTURE: string;
  69887. static readonly NAME_SHADOWGENERATOR: string;
  69888. static readonly NAME_OCTREE: string;
  69889. static readonly NAME_PHYSICSENGINE: string;
  69890. static readonly NAME_AUDIO: string;
  69891. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69892. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69893. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69894. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69895. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69896. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69897. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69898. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69899. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69900. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69901. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69902. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69903. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69904. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69905. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69906. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69907. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69908. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69909. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69910. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69911. static readonly STEP_AFTERRENDER_AUDIO: number;
  69912. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69913. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69914. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69915. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69916. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69917. static readonly STEP_POINTERMOVE_SPRITE: number;
  69918. static readonly STEP_POINTERDOWN_SPRITE: number;
  69919. static readonly STEP_POINTERUP_SPRITE: number;
  69920. }
  69921. /**
  69922. * This represents a scene component.
  69923. *
  69924. * This is used to decouple the dependency the scene is having on the different workloads like
  69925. * layers, post processes...
  69926. */
  69927. export interface ISceneComponent {
  69928. /**
  69929. * The name of the component. Each component must have a unique name.
  69930. */
  69931. name: string;
  69932. /**
  69933. * The scene the component belongs to.
  69934. */
  69935. scene: Scene;
  69936. /**
  69937. * Register the component to one instance of a scene.
  69938. */
  69939. register(): void;
  69940. /**
  69941. * Rebuilds the elements related to this component in case of
  69942. * context lost for instance.
  69943. */
  69944. rebuild(): void;
  69945. /**
  69946. * Disposes the component and the associated ressources.
  69947. */
  69948. dispose(): void;
  69949. }
  69950. /**
  69951. * This represents a SERIALIZABLE scene component.
  69952. *
  69953. * This extends Scene Component to add Serialization methods on top.
  69954. */
  69955. export interface ISceneSerializableComponent extends ISceneComponent {
  69956. /**
  69957. * Adds all the element from the container to the scene
  69958. * @param container the container holding the elements
  69959. */
  69960. addFromContainer(container: AbstractScene): void;
  69961. /**
  69962. * Removes all the elements in the container from the scene
  69963. * @param container contains the elements to remove
  69964. */
  69965. removeFromContainer(container: AbstractScene): void;
  69966. /**
  69967. * Serializes the component data to the specified json object
  69968. * @param serializationObject The object to serialize to
  69969. */
  69970. serialize(serializationObject: any): void;
  69971. }
  69972. /**
  69973. * Strong typing of a Mesh related stage step action
  69974. */
  69975. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69976. /**
  69977. * Strong typing of a Evaluate Sub Mesh related stage step action
  69978. */
  69979. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69980. /**
  69981. * Strong typing of a Active Mesh related stage step action
  69982. */
  69983. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69984. /**
  69985. * Strong typing of a Camera related stage step action
  69986. */
  69987. export type CameraStageAction = (camera: Camera) => void;
  69988. /**
  69989. * Strong typing of a Render Target related stage step action
  69990. */
  69991. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69992. /**
  69993. * Strong typing of a RenderingGroup related stage step action
  69994. */
  69995. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69996. /**
  69997. * Strong typing of a Mesh Render related stage step action
  69998. */
  69999. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70000. /**
  70001. * Strong typing of a simple stage step action
  70002. */
  70003. export type SimpleStageAction = () => void;
  70004. /**
  70005. * Strong typing of a render target action.
  70006. */
  70007. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70008. /**
  70009. * Strong typing of a pointer move action.
  70010. */
  70011. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70012. /**
  70013. * Strong typing of a pointer up/down action.
  70014. */
  70015. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70016. /**
  70017. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70018. * @hidden
  70019. */
  70020. export class Stage<T extends Function> extends Array<{
  70021. index: number;
  70022. component: ISceneComponent;
  70023. action: T;
  70024. }> {
  70025. /**
  70026. * Hide ctor from the rest of the world.
  70027. * @param items The items to add.
  70028. */
  70029. private constructor();
  70030. /**
  70031. * Creates a new Stage.
  70032. * @returns A new instance of a Stage
  70033. */
  70034. static Create<T extends Function>(): Stage<T>;
  70035. /**
  70036. * Registers a step in an ordered way in the targeted stage.
  70037. * @param index Defines the position to register the step in
  70038. * @param component Defines the component attached to the step
  70039. * @param action Defines the action to launch during the step
  70040. */
  70041. registerStep(index: number, component: ISceneComponent, action: T): void;
  70042. /**
  70043. * Clears all the steps from the stage.
  70044. */
  70045. clear(): void;
  70046. }
  70047. }
  70048. declare module BABYLON {
  70049. interface Scene {
  70050. /** @hidden */
  70051. _pointerOverSprite: Nullable<Sprite>;
  70052. /** @hidden */
  70053. _pickedDownSprite: Nullable<Sprite>;
  70054. /** @hidden */
  70055. _tempSpritePickingRay: Nullable<Ray>;
  70056. /**
  70057. * All of the sprite managers added to this scene
  70058. * @see http://doc.babylonjs.com/babylon101/sprites
  70059. */
  70060. spriteManagers: Array<ISpriteManager>;
  70061. /**
  70062. * An event triggered when sprites rendering is about to start
  70063. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70064. */
  70065. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70066. /**
  70067. * An event triggered when sprites rendering is done
  70068. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70069. */
  70070. onAfterSpritesRenderingObservable: Observable<Scene>;
  70071. /** @hidden */
  70072. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70073. /** Launch a ray to try to pick a sprite in the scene
  70074. * @param x position on screen
  70075. * @param y position on screen
  70076. * @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
  70077. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70078. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70079. * @returns a PickingInfo
  70080. */
  70081. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70082. /** Use the given ray to pick a sprite in the scene
  70083. * @param ray The ray (in world space) to use to pick meshes
  70084. * @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
  70085. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70086. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70087. * @returns a PickingInfo
  70088. */
  70089. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70090. /**
  70091. * Force the sprite under the pointer
  70092. * @param sprite defines the sprite to use
  70093. */
  70094. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70095. /**
  70096. * Gets the sprite under the pointer
  70097. * @returns a Sprite or null if no sprite is under the pointer
  70098. */
  70099. getPointerOverSprite(): Nullable<Sprite>;
  70100. }
  70101. /**
  70102. * Defines the sprite scene component responsible to manage sprites
  70103. * in a given scene.
  70104. */
  70105. export class SpriteSceneComponent implements ISceneComponent {
  70106. /**
  70107. * The component name helpfull to identify the component in the list of scene components.
  70108. */
  70109. readonly name: string;
  70110. /**
  70111. * The scene the component belongs to.
  70112. */
  70113. scene: Scene;
  70114. /** @hidden */
  70115. private _spritePredicate;
  70116. /**
  70117. * Creates a new instance of the component for the given scene
  70118. * @param scene Defines the scene to register the component in
  70119. */
  70120. constructor(scene: Scene);
  70121. /**
  70122. * Registers the component in a given scene
  70123. */
  70124. register(): void;
  70125. /**
  70126. * Rebuilds the elements related to this component in case of
  70127. * context lost for instance.
  70128. */
  70129. rebuild(): void;
  70130. /**
  70131. * Disposes the component and the associated ressources.
  70132. */
  70133. dispose(): void;
  70134. private _pickSpriteButKeepRay;
  70135. private _pointerMove;
  70136. private _pointerDown;
  70137. private _pointerUp;
  70138. }
  70139. }
  70140. declare module BABYLON {
  70141. /** @hidden */
  70142. export var fogFragmentDeclaration: {
  70143. name: string;
  70144. shader: string;
  70145. };
  70146. }
  70147. declare module BABYLON {
  70148. /** @hidden */
  70149. export var fogFragment: {
  70150. name: string;
  70151. shader: string;
  70152. };
  70153. }
  70154. declare module BABYLON {
  70155. /** @hidden */
  70156. export var spritesPixelShader: {
  70157. name: string;
  70158. shader: string;
  70159. };
  70160. }
  70161. declare module BABYLON {
  70162. /** @hidden */
  70163. export var fogVertexDeclaration: {
  70164. name: string;
  70165. shader: string;
  70166. };
  70167. }
  70168. declare module BABYLON {
  70169. /** @hidden */
  70170. export var spritesVertexShader: {
  70171. name: string;
  70172. shader: string;
  70173. };
  70174. }
  70175. declare module BABYLON {
  70176. /**
  70177. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70178. */
  70179. export interface ISpriteManager extends IDisposable {
  70180. /**
  70181. * Restricts the camera to viewing objects with the same layerMask.
  70182. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70183. */
  70184. layerMask: number;
  70185. /**
  70186. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70187. */
  70188. isPickable: boolean;
  70189. /**
  70190. * Specifies the rendering group id for this mesh (0 by default)
  70191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70192. */
  70193. renderingGroupId: number;
  70194. /**
  70195. * Defines the list of sprites managed by the manager.
  70196. */
  70197. sprites: Array<Sprite>;
  70198. /**
  70199. * Tests the intersection of a sprite with a specific ray.
  70200. * @param ray The ray we are sending to test the collision
  70201. * @param camera The camera space we are sending rays in
  70202. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70203. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70204. * @returns picking info or null.
  70205. */
  70206. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70207. /**
  70208. * Renders the list of sprites on screen.
  70209. */
  70210. render(): void;
  70211. }
  70212. /**
  70213. * Class used to manage multiple sprites on the same spritesheet
  70214. * @see http://doc.babylonjs.com/babylon101/sprites
  70215. */
  70216. export class SpriteManager implements ISpriteManager {
  70217. /** defines the manager's name */
  70218. name: string;
  70219. /** Gets the list of sprites */
  70220. sprites: Sprite[];
  70221. /** Gets or sets the rendering group id (0 by default) */
  70222. renderingGroupId: number;
  70223. /** Gets or sets camera layer mask */
  70224. layerMask: number;
  70225. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70226. fogEnabled: boolean;
  70227. /** Gets or sets a boolean indicating if the sprites are pickable */
  70228. isPickable: boolean;
  70229. /** Defines the default width of a cell in the spritesheet */
  70230. cellWidth: number;
  70231. /** Defines the default height of a cell in the spritesheet */
  70232. cellHeight: number;
  70233. /**
  70234. * An event triggered when the manager is disposed.
  70235. */
  70236. onDisposeObservable: Observable<SpriteManager>;
  70237. private _onDisposeObserver;
  70238. /**
  70239. * Callback called when the manager is disposed
  70240. */
  70241. onDispose: () => void;
  70242. private _capacity;
  70243. private _spriteTexture;
  70244. private _epsilon;
  70245. private _scene;
  70246. private _vertexData;
  70247. private _buffer;
  70248. private _vertexBuffers;
  70249. private _indexBuffer;
  70250. private _effectBase;
  70251. private _effectFog;
  70252. /**
  70253. * Gets or sets the spritesheet texture
  70254. */
  70255. texture: Texture;
  70256. /**
  70257. * Creates a new sprite manager
  70258. * @param name defines the manager's name
  70259. * @param imgUrl defines the sprite sheet url
  70260. * @param capacity defines the maximum allowed number of sprites
  70261. * @param cellSize defines the size of a sprite cell
  70262. * @param scene defines the hosting scene
  70263. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70264. * @param samplingMode defines the smapling mode to use with spritesheet
  70265. */
  70266. constructor(
  70267. /** defines the manager's name */
  70268. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70269. private _appendSpriteVertex;
  70270. /**
  70271. * Intersects the sprites with a ray
  70272. * @param ray defines the ray to intersect with
  70273. * @param camera defines the current active camera
  70274. * @param predicate defines a predicate used to select candidate sprites
  70275. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70276. * @returns null if no hit or a PickingInfo
  70277. */
  70278. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70279. /**
  70280. * Render all child sprites
  70281. */
  70282. render(): void;
  70283. /**
  70284. * Release associated resources
  70285. */
  70286. dispose(): void;
  70287. }
  70288. }
  70289. declare module BABYLON {
  70290. /**
  70291. * Class used to represent a sprite
  70292. * @see http://doc.babylonjs.com/babylon101/sprites
  70293. */
  70294. export class Sprite {
  70295. /** defines the name */
  70296. name: string;
  70297. /** Gets or sets the current world position */
  70298. position: Vector3;
  70299. /** Gets or sets the main color */
  70300. color: Color4;
  70301. /** Gets or sets the width */
  70302. width: number;
  70303. /** Gets or sets the height */
  70304. height: number;
  70305. /** Gets or sets rotation angle */
  70306. angle: number;
  70307. /** Gets or sets the cell index in the sprite sheet */
  70308. cellIndex: number;
  70309. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70310. invertU: number;
  70311. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70312. invertV: number;
  70313. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70314. disposeWhenFinishedAnimating: boolean;
  70315. /** Gets the list of attached animations */
  70316. animations: Animation[];
  70317. /** Gets or sets a boolean indicating if the sprite can be picked */
  70318. isPickable: boolean;
  70319. /**
  70320. * Gets or sets the associated action manager
  70321. */
  70322. actionManager: Nullable<ActionManager>;
  70323. private _animationStarted;
  70324. private _loopAnimation;
  70325. private _fromIndex;
  70326. private _toIndex;
  70327. private _delay;
  70328. private _direction;
  70329. private _manager;
  70330. private _time;
  70331. private _onAnimationEnd;
  70332. /**
  70333. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70334. */
  70335. isVisible: boolean;
  70336. /**
  70337. * Gets or sets the sprite size
  70338. */
  70339. size: number;
  70340. /**
  70341. * Creates a new Sprite
  70342. * @param name defines the name
  70343. * @param manager defines the manager
  70344. */
  70345. constructor(
  70346. /** defines the name */
  70347. name: string, manager: ISpriteManager);
  70348. /**
  70349. * Starts an animation
  70350. * @param from defines the initial key
  70351. * @param to defines the end key
  70352. * @param loop defines if the animation must loop
  70353. * @param delay defines the start delay (in ms)
  70354. * @param onAnimationEnd defines a callback to call when animation ends
  70355. */
  70356. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70357. /** Stops current animation (if any) */
  70358. stopAnimation(): void;
  70359. /** @hidden */
  70360. _animate(deltaTime: number): void;
  70361. /** Release associated resources */
  70362. dispose(): void;
  70363. }
  70364. }
  70365. declare module BABYLON {
  70366. /**
  70367. * Information about the result of picking within a scene
  70368. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70369. */
  70370. export class PickingInfo {
  70371. /** @hidden */
  70372. _pickingUnavailable: boolean;
  70373. /**
  70374. * If the pick collided with an object
  70375. */
  70376. hit: boolean;
  70377. /**
  70378. * Distance away where the pick collided
  70379. */
  70380. distance: number;
  70381. /**
  70382. * The location of pick collision
  70383. */
  70384. pickedPoint: Nullable<Vector3>;
  70385. /**
  70386. * The mesh corresponding the the pick collision
  70387. */
  70388. pickedMesh: Nullable<AbstractMesh>;
  70389. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70390. bu: number;
  70391. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70392. bv: number;
  70393. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70394. faceId: number;
  70395. /** Id of the the submesh that was picked */
  70396. subMeshId: number;
  70397. /** If a sprite was picked, this will be the sprite the pick collided with */
  70398. pickedSprite: Nullable<Sprite>;
  70399. /**
  70400. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70401. */
  70402. originMesh: Nullable<AbstractMesh>;
  70403. /**
  70404. * The ray that was used to perform the picking.
  70405. */
  70406. ray: Nullable<Ray>;
  70407. /**
  70408. * Gets the normal correspodning to the face the pick collided with
  70409. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70410. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70411. * @returns The normal correspodning to the face the pick collided with
  70412. */
  70413. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70414. /**
  70415. * Gets the texture coordinates of where the pick occured
  70416. * @returns the vector containing the coordnates of the texture
  70417. */
  70418. getTextureCoordinates(): Nullable<Vector2>;
  70419. }
  70420. }
  70421. declare module BABYLON {
  70422. /**
  70423. * Gather the list of pointer event types as constants.
  70424. */
  70425. export class PointerEventTypes {
  70426. /**
  70427. * 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.
  70428. */
  70429. static readonly POINTERDOWN: number;
  70430. /**
  70431. * The pointerup event is fired when a pointer is no longer active.
  70432. */
  70433. static readonly POINTERUP: number;
  70434. /**
  70435. * The pointermove event is fired when a pointer changes coordinates.
  70436. */
  70437. static readonly POINTERMOVE: number;
  70438. /**
  70439. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70440. */
  70441. static readonly POINTERWHEEL: number;
  70442. /**
  70443. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70444. */
  70445. static readonly POINTERPICK: number;
  70446. /**
  70447. * The pointertap event is fired when a the object has been touched and released without drag.
  70448. */
  70449. static readonly POINTERTAP: number;
  70450. /**
  70451. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70452. */
  70453. static readonly POINTERDOUBLETAP: number;
  70454. }
  70455. /**
  70456. * Base class of pointer info types.
  70457. */
  70458. export class PointerInfoBase {
  70459. /**
  70460. * Defines the type of event (PointerEventTypes)
  70461. */
  70462. type: number;
  70463. /**
  70464. * Defines the related dom event
  70465. */
  70466. event: PointerEvent | MouseWheelEvent;
  70467. /**
  70468. * Instantiates the base class of pointers info.
  70469. * @param type Defines the type of event (PointerEventTypes)
  70470. * @param event Defines the related dom event
  70471. */
  70472. constructor(
  70473. /**
  70474. * Defines the type of event (PointerEventTypes)
  70475. */
  70476. type: number,
  70477. /**
  70478. * Defines the related dom event
  70479. */
  70480. event: PointerEvent | MouseWheelEvent);
  70481. }
  70482. /**
  70483. * This class is used to store pointer related info for the onPrePointerObservable event.
  70484. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70485. */
  70486. export class PointerInfoPre extends PointerInfoBase {
  70487. /**
  70488. * Ray from a pointer if availible (eg. 6dof controller)
  70489. */
  70490. ray: Nullable<Ray>;
  70491. /**
  70492. * Defines the local position of the pointer on the canvas.
  70493. */
  70494. localPosition: Vector2;
  70495. /**
  70496. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70497. */
  70498. skipOnPointerObservable: boolean;
  70499. /**
  70500. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70501. * @param type Defines the type of event (PointerEventTypes)
  70502. * @param event Defines the related dom event
  70503. * @param localX Defines the local x coordinates of the pointer when the event occured
  70504. * @param localY Defines the local y coordinates of the pointer when the event occured
  70505. */
  70506. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70507. }
  70508. /**
  70509. * This type contains all the data related to a pointer event in Babylon.js.
  70510. * 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.
  70511. */
  70512. export class PointerInfo extends PointerInfoBase {
  70513. /**
  70514. * Defines the picking info associated to the info (if any)\
  70515. */
  70516. pickInfo: Nullable<PickingInfo>;
  70517. /**
  70518. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70519. * @param type Defines the type of event (PointerEventTypes)
  70520. * @param event Defines the related dom event
  70521. * @param pickInfo Defines the picking info associated to the info (if any)\
  70522. */
  70523. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70524. /**
  70525. * Defines the picking info associated to the info (if any)\
  70526. */
  70527. pickInfo: Nullable<PickingInfo>);
  70528. }
  70529. /**
  70530. * Data relating to a touch event on the screen.
  70531. */
  70532. export interface PointerTouch {
  70533. /**
  70534. * X coordinate of touch.
  70535. */
  70536. x: number;
  70537. /**
  70538. * Y coordinate of touch.
  70539. */
  70540. y: number;
  70541. /**
  70542. * Id of touch. Unique for each finger.
  70543. */
  70544. pointerId: number;
  70545. /**
  70546. * Event type passed from DOM.
  70547. */
  70548. type: any;
  70549. }
  70550. }
  70551. declare module BABYLON {
  70552. /**
  70553. * Manage the mouse inputs to control the movement of a free camera.
  70554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70555. */
  70556. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70557. /**
  70558. * Define if touch is enabled in the mouse input
  70559. */
  70560. touchEnabled: boolean;
  70561. /**
  70562. * Defines the camera the input is attached to.
  70563. */
  70564. camera: FreeCamera;
  70565. /**
  70566. * Defines the buttons associated with the input to handle camera move.
  70567. */
  70568. buttons: number[];
  70569. /**
  70570. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70571. */
  70572. angularSensibility: number;
  70573. private _pointerInput;
  70574. private _onMouseMove;
  70575. private _observer;
  70576. private previousPosition;
  70577. /**
  70578. * Manage the mouse inputs to control the movement of a free camera.
  70579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70580. * @param touchEnabled Defines if touch is enabled or not
  70581. */
  70582. constructor(
  70583. /**
  70584. * Define if touch is enabled in the mouse input
  70585. */
  70586. touchEnabled?: boolean);
  70587. /**
  70588. * Attach the input controls to a specific dom element to get the input from.
  70589. * @param element Defines the element the controls should be listened from
  70590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70591. */
  70592. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70593. /**
  70594. * Called on JS contextmenu event.
  70595. * Override this method to provide functionality.
  70596. */
  70597. protected onContextMenu(evt: PointerEvent): void;
  70598. /**
  70599. * Detach the current controls from the specified dom element.
  70600. * @param element Defines the element to stop listening the inputs from
  70601. */
  70602. detachControl(element: Nullable<HTMLElement>): void;
  70603. /**
  70604. * Gets the class name of the current intput.
  70605. * @returns the class name
  70606. */
  70607. getClassName(): string;
  70608. /**
  70609. * Get the friendly name associated with the input class.
  70610. * @returns the input friendly name
  70611. */
  70612. getSimpleName(): string;
  70613. }
  70614. }
  70615. declare module BABYLON {
  70616. /**
  70617. * Manage the touch inputs to control the movement of a free camera.
  70618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70619. */
  70620. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70621. /**
  70622. * Defines the camera the input is attached to.
  70623. */
  70624. camera: FreeCamera;
  70625. /**
  70626. * Defines the touch sensibility for rotation.
  70627. * The higher the faster.
  70628. */
  70629. touchAngularSensibility: number;
  70630. /**
  70631. * Defines the touch sensibility for move.
  70632. * The higher the faster.
  70633. */
  70634. touchMoveSensibility: number;
  70635. private _offsetX;
  70636. private _offsetY;
  70637. private _pointerPressed;
  70638. private _pointerInput;
  70639. private _observer;
  70640. private _onLostFocus;
  70641. /**
  70642. * Attach the input controls to a specific dom element to get the input from.
  70643. * @param element Defines the element the controls should be listened from
  70644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70645. */
  70646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70647. /**
  70648. * Detach the current controls from the specified dom element.
  70649. * @param element Defines the element to stop listening the inputs from
  70650. */
  70651. detachControl(element: Nullable<HTMLElement>): void;
  70652. /**
  70653. * Update the current camera state depending on the inputs that have been used this frame.
  70654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70655. */
  70656. checkInputs(): void;
  70657. /**
  70658. * Gets the class name of the current intput.
  70659. * @returns the class name
  70660. */
  70661. getClassName(): string;
  70662. /**
  70663. * Get the friendly name associated with the input class.
  70664. * @returns the input friendly name
  70665. */
  70666. getSimpleName(): string;
  70667. }
  70668. }
  70669. declare module BABYLON {
  70670. /**
  70671. * Default Inputs manager for the FreeCamera.
  70672. * It groups all the default supported inputs for ease of use.
  70673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70674. */
  70675. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70676. /**
  70677. * Instantiates a new FreeCameraInputsManager.
  70678. * @param camera Defines the camera the inputs belong to
  70679. */
  70680. constructor(camera: FreeCamera);
  70681. /**
  70682. * Add keyboard input support to the input manager.
  70683. * @returns the current input manager
  70684. */
  70685. addKeyboard(): FreeCameraInputsManager;
  70686. /**
  70687. * Add mouse input support to the input manager.
  70688. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70689. * @returns the current input manager
  70690. */
  70691. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70692. /**
  70693. * Add touch input support to the input manager.
  70694. * @returns the current input manager
  70695. */
  70696. addTouch(): FreeCameraInputsManager;
  70697. }
  70698. }
  70699. declare module BABYLON {
  70700. /**
  70701. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70702. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70703. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70704. */
  70705. export class FreeCamera extends TargetCamera {
  70706. /**
  70707. * Define the collision ellipsoid of the camera.
  70708. * This is helpful to simulate a camera body like the player body around the camera
  70709. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70710. */
  70711. ellipsoid: Vector3;
  70712. /**
  70713. * Define an offset for the position of the ellipsoid around the camera.
  70714. * This can be helpful to determine the center of the body near the gravity center of the body
  70715. * instead of its head.
  70716. */
  70717. ellipsoidOffset: Vector3;
  70718. /**
  70719. * Enable or disable collisions of the camera with the rest of the scene objects.
  70720. */
  70721. checkCollisions: boolean;
  70722. /**
  70723. * Enable or disable gravity on the camera.
  70724. */
  70725. applyGravity: boolean;
  70726. /**
  70727. * Define the input manager associated to the camera.
  70728. */
  70729. inputs: FreeCameraInputsManager;
  70730. /**
  70731. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70732. * Higher values reduce sensitivity.
  70733. */
  70734. /**
  70735. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70736. * Higher values reduce sensitivity.
  70737. */
  70738. angularSensibility: number;
  70739. /**
  70740. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70741. */
  70742. keysUp: number[];
  70743. /**
  70744. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70745. */
  70746. keysDown: number[];
  70747. /**
  70748. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70749. */
  70750. keysLeft: number[];
  70751. /**
  70752. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70753. */
  70754. keysRight: number[];
  70755. /**
  70756. * Event raised when the camera collide with a mesh in the scene.
  70757. */
  70758. onCollide: (collidedMesh: AbstractMesh) => void;
  70759. private _collider;
  70760. private _needMoveForGravity;
  70761. private _oldPosition;
  70762. private _diffPosition;
  70763. private _newPosition;
  70764. /** @hidden */
  70765. _localDirection: Vector3;
  70766. /** @hidden */
  70767. _transformedDirection: Vector3;
  70768. /**
  70769. * Instantiates a Free Camera.
  70770. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70771. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70773. * @param name Define the name of the camera in the scene
  70774. * @param position Define the start position of the camera in the scene
  70775. * @param scene Define the scene the camera belongs to
  70776. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70777. */
  70778. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70779. /**
  70780. * Attached controls to the current camera.
  70781. * @param element Defines the element the controls should be listened from
  70782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70783. */
  70784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70785. /**
  70786. * Detach the current controls from the camera.
  70787. * The camera will stop reacting to inputs.
  70788. * @param element Defines the element to stop listening the inputs from
  70789. */
  70790. detachControl(element: HTMLElement): void;
  70791. private _collisionMask;
  70792. /**
  70793. * Define a collision mask to limit the list of object the camera can collide with
  70794. */
  70795. collisionMask: number;
  70796. /** @hidden */
  70797. _collideWithWorld(displacement: Vector3): void;
  70798. private _onCollisionPositionChange;
  70799. /** @hidden */
  70800. _checkInputs(): void;
  70801. /** @hidden */
  70802. _decideIfNeedsToMove(): boolean;
  70803. /** @hidden */
  70804. _updatePosition(): void;
  70805. /**
  70806. * Destroy the camera and release the current resources hold by it.
  70807. */
  70808. dispose(): void;
  70809. /**
  70810. * Gets the current object class name.
  70811. * @return the class name
  70812. */
  70813. getClassName(): string;
  70814. }
  70815. }
  70816. declare module BABYLON {
  70817. /**
  70818. * Represents a gamepad control stick position
  70819. */
  70820. export class StickValues {
  70821. /**
  70822. * The x component of the control stick
  70823. */
  70824. x: number;
  70825. /**
  70826. * The y component of the control stick
  70827. */
  70828. y: number;
  70829. /**
  70830. * Initializes the gamepad x and y control stick values
  70831. * @param x The x component of the gamepad control stick value
  70832. * @param y The y component of the gamepad control stick value
  70833. */
  70834. constructor(
  70835. /**
  70836. * The x component of the control stick
  70837. */
  70838. x: number,
  70839. /**
  70840. * The y component of the control stick
  70841. */
  70842. y: number);
  70843. }
  70844. /**
  70845. * An interface which manages callbacks for gamepad button changes
  70846. */
  70847. export interface GamepadButtonChanges {
  70848. /**
  70849. * Called when a gamepad has been changed
  70850. */
  70851. changed: boolean;
  70852. /**
  70853. * Called when a gamepad press event has been triggered
  70854. */
  70855. pressChanged: boolean;
  70856. /**
  70857. * Called when a touch event has been triggered
  70858. */
  70859. touchChanged: boolean;
  70860. /**
  70861. * Called when a value has changed
  70862. */
  70863. valueChanged: boolean;
  70864. }
  70865. /**
  70866. * Represents a gamepad
  70867. */
  70868. export class Gamepad {
  70869. /**
  70870. * The id of the gamepad
  70871. */
  70872. id: string;
  70873. /**
  70874. * The index of the gamepad
  70875. */
  70876. index: number;
  70877. /**
  70878. * The browser gamepad
  70879. */
  70880. browserGamepad: any;
  70881. /**
  70882. * Specifies what type of gamepad this represents
  70883. */
  70884. type: number;
  70885. private _leftStick;
  70886. private _rightStick;
  70887. /** @hidden */
  70888. _isConnected: boolean;
  70889. private _leftStickAxisX;
  70890. private _leftStickAxisY;
  70891. private _rightStickAxisX;
  70892. private _rightStickAxisY;
  70893. /**
  70894. * Triggered when the left control stick has been changed
  70895. */
  70896. private _onleftstickchanged;
  70897. /**
  70898. * Triggered when the right control stick has been changed
  70899. */
  70900. private _onrightstickchanged;
  70901. /**
  70902. * Represents a gamepad controller
  70903. */
  70904. static GAMEPAD: number;
  70905. /**
  70906. * Represents a generic controller
  70907. */
  70908. static GENERIC: number;
  70909. /**
  70910. * Represents an XBox controller
  70911. */
  70912. static XBOX: number;
  70913. /**
  70914. * Represents a pose-enabled controller
  70915. */
  70916. static POSE_ENABLED: number;
  70917. /**
  70918. * Specifies whether the left control stick should be Y-inverted
  70919. */
  70920. protected _invertLeftStickY: boolean;
  70921. /**
  70922. * Specifies if the gamepad has been connected
  70923. */
  70924. readonly isConnected: boolean;
  70925. /**
  70926. * Initializes the gamepad
  70927. * @param id The id of the gamepad
  70928. * @param index The index of the gamepad
  70929. * @param browserGamepad The browser gamepad
  70930. * @param leftStickX The x component of the left joystick
  70931. * @param leftStickY The y component of the left joystick
  70932. * @param rightStickX The x component of the right joystick
  70933. * @param rightStickY The y component of the right joystick
  70934. */
  70935. constructor(
  70936. /**
  70937. * The id of the gamepad
  70938. */
  70939. id: string,
  70940. /**
  70941. * The index of the gamepad
  70942. */
  70943. index: number,
  70944. /**
  70945. * The browser gamepad
  70946. */
  70947. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70948. /**
  70949. * Callback triggered when the left joystick has changed
  70950. * @param callback
  70951. */
  70952. onleftstickchanged(callback: (values: StickValues) => void): void;
  70953. /**
  70954. * Callback triggered when the right joystick has changed
  70955. * @param callback
  70956. */
  70957. onrightstickchanged(callback: (values: StickValues) => void): void;
  70958. /**
  70959. * Gets the left joystick
  70960. */
  70961. /**
  70962. * Sets the left joystick values
  70963. */
  70964. leftStick: StickValues;
  70965. /**
  70966. * Gets the right joystick
  70967. */
  70968. /**
  70969. * Sets the right joystick value
  70970. */
  70971. rightStick: StickValues;
  70972. /**
  70973. * Updates the gamepad joystick positions
  70974. */
  70975. update(): void;
  70976. /**
  70977. * Disposes the gamepad
  70978. */
  70979. dispose(): void;
  70980. }
  70981. /**
  70982. * Represents a generic gamepad
  70983. */
  70984. export class GenericPad extends Gamepad {
  70985. private _buttons;
  70986. private _onbuttondown;
  70987. private _onbuttonup;
  70988. /**
  70989. * Observable triggered when a button has been pressed
  70990. */
  70991. onButtonDownObservable: Observable<number>;
  70992. /**
  70993. * Observable triggered when a button has been released
  70994. */
  70995. onButtonUpObservable: Observable<number>;
  70996. /**
  70997. * Callback triggered when a button has been pressed
  70998. * @param callback Called when a button has been pressed
  70999. */
  71000. onbuttondown(callback: (buttonPressed: number) => void): void;
  71001. /**
  71002. * Callback triggered when a button has been released
  71003. * @param callback Called when a button has been released
  71004. */
  71005. onbuttonup(callback: (buttonReleased: number) => void): void;
  71006. /**
  71007. * Initializes the generic gamepad
  71008. * @param id The id of the generic gamepad
  71009. * @param index The index of the generic gamepad
  71010. * @param browserGamepad The browser gamepad
  71011. */
  71012. constructor(id: string, index: number, browserGamepad: any);
  71013. private _setButtonValue;
  71014. /**
  71015. * Updates the generic gamepad
  71016. */
  71017. update(): void;
  71018. /**
  71019. * Disposes the generic gamepad
  71020. */
  71021. dispose(): void;
  71022. }
  71023. }
  71024. declare module BABYLON {
  71025. /**
  71026. * Defines the types of pose enabled controllers that are supported
  71027. */
  71028. export enum PoseEnabledControllerType {
  71029. /**
  71030. * HTC Vive
  71031. */
  71032. VIVE = 0,
  71033. /**
  71034. * Oculus Rift
  71035. */
  71036. OCULUS = 1,
  71037. /**
  71038. * Windows mixed reality
  71039. */
  71040. WINDOWS = 2,
  71041. /**
  71042. * Samsung gear VR
  71043. */
  71044. GEAR_VR = 3,
  71045. /**
  71046. * Google Daydream
  71047. */
  71048. DAYDREAM = 4,
  71049. /**
  71050. * Generic
  71051. */
  71052. GENERIC = 5
  71053. }
  71054. /**
  71055. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71056. */
  71057. export interface MutableGamepadButton {
  71058. /**
  71059. * Value of the button/trigger
  71060. */
  71061. value: number;
  71062. /**
  71063. * If the button/trigger is currently touched
  71064. */
  71065. touched: boolean;
  71066. /**
  71067. * If the button/trigger is currently pressed
  71068. */
  71069. pressed: boolean;
  71070. }
  71071. /**
  71072. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71073. * @hidden
  71074. */
  71075. export interface ExtendedGamepadButton extends GamepadButton {
  71076. /**
  71077. * If the button/trigger is currently pressed
  71078. */
  71079. readonly pressed: boolean;
  71080. /**
  71081. * If the button/trigger is currently touched
  71082. */
  71083. readonly touched: boolean;
  71084. /**
  71085. * Value of the button/trigger
  71086. */
  71087. readonly value: number;
  71088. }
  71089. /** @hidden */
  71090. export interface _GamePadFactory {
  71091. /**
  71092. * Returns wether or not the current gamepad can be created for this type of controller.
  71093. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71094. * @returns true if it can be created, otherwise false
  71095. */
  71096. canCreate(gamepadInfo: any): boolean;
  71097. /**
  71098. * Creates a new instance of the Gamepad.
  71099. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71100. * @returns the new gamepad instance
  71101. */
  71102. create(gamepadInfo: any): Gamepad;
  71103. }
  71104. /**
  71105. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71106. */
  71107. export class PoseEnabledControllerHelper {
  71108. /** @hidden */
  71109. static _ControllerFactories: _GamePadFactory[];
  71110. /** @hidden */
  71111. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71112. /**
  71113. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71114. * @param vrGamepad the gamepad to initialized
  71115. * @returns a vr controller of the type the gamepad identified as
  71116. */
  71117. static InitiateController(vrGamepad: any): Gamepad;
  71118. }
  71119. /**
  71120. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71121. */
  71122. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71123. private _deviceRoomPosition;
  71124. private _deviceRoomRotationQuaternion;
  71125. /**
  71126. * The device position in babylon space
  71127. */
  71128. devicePosition: Vector3;
  71129. /**
  71130. * The device rotation in babylon space
  71131. */
  71132. deviceRotationQuaternion: Quaternion;
  71133. /**
  71134. * The scale factor of the device in babylon space
  71135. */
  71136. deviceScaleFactor: number;
  71137. /**
  71138. * (Likely devicePosition should be used instead) The device position in its room space
  71139. */
  71140. position: Vector3;
  71141. /**
  71142. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71143. */
  71144. rotationQuaternion: Quaternion;
  71145. /**
  71146. * The type of controller (Eg. Windows mixed reality)
  71147. */
  71148. controllerType: PoseEnabledControllerType;
  71149. protected _calculatedPosition: Vector3;
  71150. private _calculatedRotation;
  71151. /**
  71152. * The raw pose from the device
  71153. */
  71154. rawPose: DevicePose;
  71155. private _trackPosition;
  71156. private _maxRotationDistFromHeadset;
  71157. private _draggedRoomRotation;
  71158. /**
  71159. * @hidden
  71160. */
  71161. _disableTrackPosition(fixedPosition: Vector3): void;
  71162. /**
  71163. * Internal, the mesh attached to the controller
  71164. * @hidden
  71165. */
  71166. _mesh: Nullable<AbstractMesh>;
  71167. private _poseControlledCamera;
  71168. private _leftHandSystemQuaternion;
  71169. /**
  71170. * Internal, matrix used to convert room space to babylon space
  71171. * @hidden
  71172. */
  71173. _deviceToWorld: Matrix;
  71174. /**
  71175. * Node to be used when casting a ray from the controller
  71176. * @hidden
  71177. */
  71178. _pointingPoseNode: Nullable<TransformNode>;
  71179. /**
  71180. * Name of the child mesh that can be used to cast a ray from the controller
  71181. */
  71182. static readonly POINTING_POSE: string;
  71183. /**
  71184. * Creates a new PoseEnabledController from a gamepad
  71185. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71186. */
  71187. constructor(browserGamepad: any);
  71188. private _workingMatrix;
  71189. /**
  71190. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71191. */
  71192. update(): void;
  71193. /**
  71194. * Updates only the pose device and mesh without doing any button event checking
  71195. */
  71196. protected _updatePoseAndMesh(): void;
  71197. /**
  71198. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71199. * @param poseData raw pose fromthe device
  71200. */
  71201. updateFromDevice(poseData: DevicePose): void;
  71202. /**
  71203. * @hidden
  71204. */
  71205. _meshAttachedObservable: Observable<AbstractMesh>;
  71206. /**
  71207. * Attaches a mesh to the controller
  71208. * @param mesh the mesh to be attached
  71209. */
  71210. attachToMesh(mesh: AbstractMesh): void;
  71211. /**
  71212. * Attaches the controllers mesh to a camera
  71213. * @param camera the camera the mesh should be attached to
  71214. */
  71215. attachToPoseControlledCamera(camera: TargetCamera): void;
  71216. /**
  71217. * Disposes of the controller
  71218. */
  71219. dispose(): void;
  71220. /**
  71221. * The mesh that is attached to the controller
  71222. */
  71223. readonly mesh: Nullable<AbstractMesh>;
  71224. /**
  71225. * Gets the ray of the controller in the direction the controller is pointing
  71226. * @param length the length the resulting ray should be
  71227. * @returns a ray in the direction the controller is pointing
  71228. */
  71229. getForwardRay(length?: number): Ray;
  71230. }
  71231. }
  71232. declare module BABYLON {
  71233. /**
  71234. * Defines the WebVRController object that represents controllers tracked in 3D space
  71235. */
  71236. export abstract class WebVRController extends PoseEnabledController {
  71237. /**
  71238. * Internal, the default controller model for the controller
  71239. */
  71240. protected _defaultModel: AbstractMesh;
  71241. /**
  71242. * Fired when the trigger state has changed
  71243. */
  71244. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71245. /**
  71246. * Fired when the main button state has changed
  71247. */
  71248. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71249. /**
  71250. * Fired when the secondary button state has changed
  71251. */
  71252. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71253. /**
  71254. * Fired when the pad state has changed
  71255. */
  71256. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71257. /**
  71258. * Fired when controllers stick values have changed
  71259. */
  71260. onPadValuesChangedObservable: Observable<StickValues>;
  71261. /**
  71262. * Array of button availible on the controller
  71263. */
  71264. protected _buttons: Array<MutableGamepadButton>;
  71265. private _onButtonStateChange;
  71266. /**
  71267. * Fired when a controller button's state has changed
  71268. * @param callback the callback containing the button that was modified
  71269. */
  71270. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71271. /**
  71272. * X and Y axis corrisponding to the controllers joystick
  71273. */
  71274. pad: StickValues;
  71275. /**
  71276. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71277. */
  71278. hand: string;
  71279. /**
  71280. * The default controller model for the controller
  71281. */
  71282. readonly defaultModel: AbstractMesh;
  71283. /**
  71284. * Creates a new WebVRController from a gamepad
  71285. * @param vrGamepad the gamepad that the WebVRController should be created from
  71286. */
  71287. constructor(vrGamepad: any);
  71288. /**
  71289. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71290. */
  71291. update(): void;
  71292. /**
  71293. * Function to be called when a button is modified
  71294. */
  71295. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71296. /**
  71297. * Loads a mesh and attaches it to the controller
  71298. * @param scene the scene the mesh should be added to
  71299. * @param meshLoaded callback for when the mesh has been loaded
  71300. */
  71301. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71302. private _setButtonValue;
  71303. private _changes;
  71304. private _checkChanges;
  71305. /**
  71306. * Disposes of th webVRCOntroller
  71307. */
  71308. dispose(): void;
  71309. }
  71310. }
  71311. declare module BABYLON {
  71312. /**
  71313. * The HemisphericLight simulates the ambient environment light,
  71314. * so the passed direction is the light reflection direction, not the incoming direction.
  71315. */
  71316. export class HemisphericLight extends Light {
  71317. /**
  71318. * The groundColor is the light in the opposite direction to the one specified during creation.
  71319. * 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.
  71320. */
  71321. groundColor: Color3;
  71322. /**
  71323. * The light reflection direction, not the incoming direction.
  71324. */
  71325. direction: Vector3;
  71326. /**
  71327. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71328. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71329. * The HemisphericLight can't cast shadows.
  71330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71331. * @param name The friendly name of the light
  71332. * @param direction The direction of the light reflection
  71333. * @param scene The scene the light belongs to
  71334. */
  71335. constructor(name: string, direction: Vector3, scene: Scene);
  71336. protected _buildUniformLayout(): void;
  71337. /**
  71338. * Returns the string "HemisphericLight".
  71339. * @return The class name
  71340. */
  71341. getClassName(): string;
  71342. /**
  71343. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71344. * Returns the updated direction.
  71345. * @param target The target the direction should point to
  71346. * @return The computed direction
  71347. */
  71348. setDirectionToTarget(target: Vector3): Vector3;
  71349. /**
  71350. * Returns the shadow generator associated to the light.
  71351. * @returns Always null for hemispheric lights because it does not support shadows.
  71352. */
  71353. getShadowGenerator(): Nullable<IShadowGenerator>;
  71354. /**
  71355. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71356. * @param effect The effect to update
  71357. * @param lightIndex The index of the light in the effect to update
  71358. * @returns The hemispheric light
  71359. */
  71360. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71361. /**
  71362. * Computes the world matrix of the node
  71363. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71364. * @param useWasUpdatedFlag defines a reserved property
  71365. * @returns the world matrix
  71366. */
  71367. computeWorldMatrix(): Matrix;
  71368. /**
  71369. * Returns the integer 3.
  71370. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71371. */
  71372. getTypeID(): number;
  71373. /**
  71374. * Prepares the list of defines specific to the light type.
  71375. * @param defines the list of defines
  71376. * @param lightIndex defines the index of the light for the effect
  71377. */
  71378. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71379. }
  71380. }
  71381. declare module BABYLON {
  71382. /**
  71383. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71384. * IMPORTANT!! The data is right-hand data.
  71385. * @export
  71386. * @interface DevicePose
  71387. */
  71388. export interface DevicePose {
  71389. /**
  71390. * The position of the device, values in array are [x,y,z].
  71391. */
  71392. readonly position: Nullable<Float32Array>;
  71393. /**
  71394. * The linearVelocity of the device, values in array are [x,y,z].
  71395. */
  71396. readonly linearVelocity: Nullable<Float32Array>;
  71397. /**
  71398. * The linearAcceleration of the device, values in array are [x,y,z].
  71399. */
  71400. readonly linearAcceleration: Nullable<Float32Array>;
  71401. /**
  71402. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71403. */
  71404. readonly orientation: Nullable<Float32Array>;
  71405. /**
  71406. * The angularVelocity of the device, values in array are [x,y,z].
  71407. */
  71408. readonly angularVelocity: Nullable<Float32Array>;
  71409. /**
  71410. * The angularAcceleration of the device, values in array are [x,y,z].
  71411. */
  71412. readonly angularAcceleration: Nullable<Float32Array>;
  71413. }
  71414. /**
  71415. * Interface representing a pose controlled object in Babylon.
  71416. * A pose controlled object has both regular pose values as well as pose values
  71417. * from an external device such as a VR head mounted display
  71418. */
  71419. export interface PoseControlled {
  71420. /**
  71421. * The position of the object in babylon space.
  71422. */
  71423. position: Vector3;
  71424. /**
  71425. * The rotation quaternion of the object in babylon space.
  71426. */
  71427. rotationQuaternion: Quaternion;
  71428. /**
  71429. * The position of the device in babylon space.
  71430. */
  71431. devicePosition?: Vector3;
  71432. /**
  71433. * The rotation quaternion of the device in babylon space.
  71434. */
  71435. deviceRotationQuaternion: Quaternion;
  71436. /**
  71437. * The raw pose coming from the device.
  71438. */
  71439. rawPose: Nullable<DevicePose>;
  71440. /**
  71441. * The scale of the device to be used when translating from device space to babylon space.
  71442. */
  71443. deviceScaleFactor: number;
  71444. /**
  71445. * Updates the poseControlled values based on the input device pose.
  71446. * @param poseData the pose data to update the object with
  71447. */
  71448. updateFromDevice(poseData: DevicePose): void;
  71449. }
  71450. /**
  71451. * Set of options to customize the webVRCamera
  71452. */
  71453. export interface WebVROptions {
  71454. /**
  71455. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71456. */
  71457. trackPosition?: boolean;
  71458. /**
  71459. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71460. */
  71461. positionScale?: number;
  71462. /**
  71463. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71464. */
  71465. displayName?: string;
  71466. /**
  71467. * Should the native controller meshes be initialized. (default: true)
  71468. */
  71469. controllerMeshes?: boolean;
  71470. /**
  71471. * Creating a default HemiLight only on controllers. (default: true)
  71472. */
  71473. defaultLightingOnControllers?: boolean;
  71474. /**
  71475. * If you don't want to use the default VR button of the helper. (default: false)
  71476. */
  71477. useCustomVRButton?: boolean;
  71478. /**
  71479. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71480. */
  71481. customVRButton?: HTMLButtonElement;
  71482. /**
  71483. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71484. */
  71485. rayLength?: number;
  71486. /**
  71487. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71488. */
  71489. defaultHeight?: number;
  71490. }
  71491. /**
  71492. * This represents a WebVR camera.
  71493. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71494. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71495. */
  71496. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71497. private webVROptions;
  71498. /**
  71499. * @hidden
  71500. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71501. */
  71502. _vrDevice: any;
  71503. /**
  71504. * The rawPose of the vrDevice.
  71505. */
  71506. rawPose: Nullable<DevicePose>;
  71507. private _onVREnabled;
  71508. private _specsVersion;
  71509. private _attached;
  71510. private _frameData;
  71511. protected _descendants: Array<Node>;
  71512. private _deviceRoomPosition;
  71513. /** @hidden */
  71514. _deviceRoomRotationQuaternion: Quaternion;
  71515. private _standingMatrix;
  71516. /**
  71517. * Represents device position in babylon space.
  71518. */
  71519. devicePosition: Vector3;
  71520. /**
  71521. * Represents device rotation in babylon space.
  71522. */
  71523. deviceRotationQuaternion: Quaternion;
  71524. /**
  71525. * The scale of the device to be used when translating from device space to babylon space.
  71526. */
  71527. deviceScaleFactor: number;
  71528. private _deviceToWorld;
  71529. private _worldToDevice;
  71530. /**
  71531. * References to the webVR controllers for the vrDevice.
  71532. */
  71533. controllers: Array<WebVRController>;
  71534. /**
  71535. * Emits an event when a controller is attached.
  71536. */
  71537. onControllersAttachedObservable: Observable<WebVRController[]>;
  71538. /**
  71539. * Emits an event when a controller's mesh has been loaded;
  71540. */
  71541. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71542. /**
  71543. * Emits an event when the HMD's pose has been updated.
  71544. */
  71545. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71546. private _poseSet;
  71547. /**
  71548. * If the rig cameras be used as parent instead of this camera.
  71549. */
  71550. rigParenting: boolean;
  71551. private _lightOnControllers;
  71552. private _defaultHeight?;
  71553. /**
  71554. * Instantiates a WebVRFreeCamera.
  71555. * @param name The name of the WebVRFreeCamera
  71556. * @param position The starting anchor position for the camera
  71557. * @param scene The scene the camera belongs to
  71558. * @param webVROptions a set of customizable options for the webVRCamera
  71559. */
  71560. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71561. /**
  71562. * Gets the device distance from the ground in meters.
  71563. * @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.
  71564. */
  71565. deviceDistanceToRoomGround(): number;
  71566. /**
  71567. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71568. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71569. */
  71570. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71571. /**
  71572. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71573. * @returns A promise with a boolean set to if the standing matrix is supported.
  71574. */
  71575. useStandingMatrixAsync(): Promise<boolean>;
  71576. /**
  71577. * Disposes the camera
  71578. */
  71579. dispose(): void;
  71580. /**
  71581. * Gets a vrController by name.
  71582. * @param name The name of the controller to retreive
  71583. * @returns the controller matching the name specified or null if not found
  71584. */
  71585. getControllerByName(name: string): Nullable<WebVRController>;
  71586. private _leftController;
  71587. /**
  71588. * The controller corrisponding to the users left hand.
  71589. */
  71590. readonly leftController: Nullable<WebVRController>;
  71591. private _rightController;
  71592. /**
  71593. * The controller corrisponding to the users right hand.
  71594. */
  71595. readonly rightController: Nullable<WebVRController>;
  71596. /**
  71597. * Casts a ray forward from the vrCamera's gaze.
  71598. * @param length Length of the ray (default: 100)
  71599. * @returns the ray corrisponding to the gaze
  71600. */
  71601. getForwardRay(length?: number): Ray;
  71602. /**
  71603. * @hidden
  71604. * Updates the camera based on device's frame data
  71605. */
  71606. _checkInputs(): void;
  71607. /**
  71608. * Updates the poseControlled values based on the input device pose.
  71609. * @param poseData Pose coming from the device
  71610. */
  71611. updateFromDevice(poseData: DevicePose): void;
  71612. private _htmlElementAttached;
  71613. private _detachIfAttached;
  71614. /**
  71615. * WebVR's attach control will start broadcasting frames to the device.
  71616. * Note that in certain browsers (chrome for example) this function must be called
  71617. * within a user-interaction callback. Example:
  71618. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71619. *
  71620. * @param element html element to attach the vrDevice to
  71621. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71622. */
  71623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71624. /**
  71625. * Detaches the camera from the html element and disables VR
  71626. *
  71627. * @param element html element to detach from
  71628. */
  71629. detachControl(element: HTMLElement): void;
  71630. /**
  71631. * @returns the name of this class
  71632. */
  71633. getClassName(): string;
  71634. /**
  71635. * Calls resetPose on the vrDisplay
  71636. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71637. */
  71638. resetToCurrentRotation(): void;
  71639. /**
  71640. * @hidden
  71641. * Updates the rig cameras (left and right eye)
  71642. */
  71643. _updateRigCameras(): void;
  71644. private _workingVector;
  71645. private _oneVector;
  71646. private _workingMatrix;
  71647. private updateCacheCalled;
  71648. private _correctPositionIfNotTrackPosition;
  71649. /**
  71650. * @hidden
  71651. * Updates the cached values of the camera
  71652. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71653. */
  71654. _updateCache(ignoreParentClass?: boolean): void;
  71655. /**
  71656. * @hidden
  71657. * Get current device position in babylon world
  71658. */
  71659. _computeDevicePosition(): void;
  71660. /**
  71661. * Updates the current device position and rotation in the babylon world
  71662. */
  71663. update(): void;
  71664. /**
  71665. * @hidden
  71666. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71667. * @returns an identity matrix
  71668. */
  71669. _getViewMatrix(): Matrix;
  71670. private _tmpMatrix;
  71671. /**
  71672. * This function is called by the two RIG cameras.
  71673. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71674. * @hidden
  71675. */
  71676. _getWebVRViewMatrix(): Matrix;
  71677. /** @hidden */
  71678. _getWebVRProjectionMatrix(): Matrix;
  71679. private _onGamepadConnectedObserver;
  71680. private _onGamepadDisconnectedObserver;
  71681. private _updateCacheWhenTrackingDisabledObserver;
  71682. /**
  71683. * Initializes the controllers and their meshes
  71684. */
  71685. initControllers(): void;
  71686. }
  71687. }
  71688. declare module BABYLON {
  71689. /**
  71690. * Size options for a post process
  71691. */
  71692. export type PostProcessOptions = {
  71693. width: number;
  71694. height: number;
  71695. };
  71696. /**
  71697. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71698. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71699. */
  71700. export class PostProcess {
  71701. /** Name of the PostProcess. */
  71702. name: string;
  71703. /**
  71704. * Gets or sets the unique id of the post process
  71705. */
  71706. uniqueId: number;
  71707. /**
  71708. * Width of the texture to apply the post process on
  71709. */
  71710. width: number;
  71711. /**
  71712. * Height of the texture to apply the post process on
  71713. */
  71714. height: number;
  71715. /**
  71716. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71717. * @hidden
  71718. */
  71719. _outputTexture: Nullable<InternalTexture>;
  71720. /**
  71721. * Sampling mode used by the shader
  71722. * See https://doc.babylonjs.com/classes/3.1/texture
  71723. */
  71724. renderTargetSamplingMode: number;
  71725. /**
  71726. * Clear color to use when screen clearing
  71727. */
  71728. clearColor: Color4;
  71729. /**
  71730. * If the buffer needs to be cleared before applying the post process. (default: true)
  71731. * Should be set to false if shader will overwrite all previous pixels.
  71732. */
  71733. autoClear: boolean;
  71734. /**
  71735. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71736. */
  71737. alphaMode: number;
  71738. /**
  71739. * Sets the setAlphaBlendConstants of the babylon engine
  71740. */
  71741. alphaConstants: Color4;
  71742. /**
  71743. * Animations to be used for the post processing
  71744. */
  71745. animations: Animation[];
  71746. /**
  71747. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71748. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71749. */
  71750. enablePixelPerfectMode: boolean;
  71751. /**
  71752. * Force the postprocess to be applied without taking in account viewport
  71753. */
  71754. forceFullscreenViewport: boolean;
  71755. /**
  71756. * List of inspectable custom properties (used by the Inspector)
  71757. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71758. */
  71759. inspectableCustomProperties: IInspectable[];
  71760. /**
  71761. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71762. *
  71763. * | Value | Type | Description |
  71764. * | ----- | ----------------------------------- | ----------- |
  71765. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71766. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71767. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71768. *
  71769. */
  71770. scaleMode: number;
  71771. /**
  71772. * Force textures to be a power of two (default: false)
  71773. */
  71774. alwaysForcePOT: boolean;
  71775. private _samples;
  71776. /**
  71777. * Number of sample textures (default: 1)
  71778. */
  71779. samples: number;
  71780. /**
  71781. * Modify the scale of the post process to be the same as the viewport (default: false)
  71782. */
  71783. adaptScaleToCurrentViewport: boolean;
  71784. private _camera;
  71785. private _scene;
  71786. private _engine;
  71787. private _options;
  71788. private _reusable;
  71789. private _textureType;
  71790. /**
  71791. * Smart array of input and output textures for the post process.
  71792. * @hidden
  71793. */
  71794. _textures: SmartArray<InternalTexture>;
  71795. /**
  71796. * The index in _textures that corresponds to the output texture.
  71797. * @hidden
  71798. */
  71799. _currentRenderTextureInd: number;
  71800. private _effect;
  71801. private _samplers;
  71802. private _fragmentUrl;
  71803. private _vertexUrl;
  71804. private _parameters;
  71805. private _scaleRatio;
  71806. protected _indexParameters: any;
  71807. private _shareOutputWithPostProcess;
  71808. private _texelSize;
  71809. private _forcedOutputTexture;
  71810. /**
  71811. * Returns the fragment url or shader name used in the post process.
  71812. * @returns the fragment url or name in the shader store.
  71813. */
  71814. getEffectName(): string;
  71815. /**
  71816. * An event triggered when the postprocess is activated.
  71817. */
  71818. onActivateObservable: Observable<Camera>;
  71819. private _onActivateObserver;
  71820. /**
  71821. * A function that is added to the onActivateObservable
  71822. */
  71823. onActivate: Nullable<(camera: Camera) => void>;
  71824. /**
  71825. * An event triggered when the postprocess changes its size.
  71826. */
  71827. onSizeChangedObservable: Observable<PostProcess>;
  71828. private _onSizeChangedObserver;
  71829. /**
  71830. * A function that is added to the onSizeChangedObservable
  71831. */
  71832. onSizeChanged: (postProcess: PostProcess) => void;
  71833. /**
  71834. * An event triggered when the postprocess applies its effect.
  71835. */
  71836. onApplyObservable: Observable<Effect>;
  71837. private _onApplyObserver;
  71838. /**
  71839. * A function that is added to the onApplyObservable
  71840. */
  71841. onApply: (effect: Effect) => void;
  71842. /**
  71843. * An event triggered before rendering the postprocess
  71844. */
  71845. onBeforeRenderObservable: Observable<Effect>;
  71846. private _onBeforeRenderObserver;
  71847. /**
  71848. * A function that is added to the onBeforeRenderObservable
  71849. */
  71850. onBeforeRender: (effect: Effect) => void;
  71851. /**
  71852. * An event triggered after rendering the postprocess
  71853. */
  71854. onAfterRenderObservable: Observable<Effect>;
  71855. private _onAfterRenderObserver;
  71856. /**
  71857. * A function that is added to the onAfterRenderObservable
  71858. */
  71859. onAfterRender: (efect: Effect) => void;
  71860. /**
  71861. * 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
  71862. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71863. */
  71864. inputTexture: InternalTexture;
  71865. /**
  71866. * Gets the camera which post process is applied to.
  71867. * @returns The camera the post process is applied to.
  71868. */
  71869. getCamera(): Camera;
  71870. /**
  71871. * Gets the texel size of the postprocess.
  71872. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71873. */
  71874. readonly texelSize: Vector2;
  71875. /**
  71876. * Creates a new instance PostProcess
  71877. * @param name The name of the PostProcess.
  71878. * @param fragmentUrl The url of the fragment shader to be used.
  71879. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71880. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71881. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71882. * @param camera The camera to apply the render pass to.
  71883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71884. * @param engine The engine which the post process will be applied. (default: current engine)
  71885. * @param reusable If the post process can be reused on the same frame. (default: false)
  71886. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71887. * @param textureType Type of textures used when performing the post process. (default: 0)
  71888. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71889. * @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
  71890. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71891. */
  71892. constructor(
  71893. /** Name of the PostProcess. */
  71894. 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);
  71895. /**
  71896. * Gets a string idenfifying the name of the class
  71897. * @returns "PostProcess" string
  71898. */
  71899. getClassName(): string;
  71900. /**
  71901. * Gets the engine which this post process belongs to.
  71902. * @returns The engine the post process was enabled with.
  71903. */
  71904. getEngine(): Engine;
  71905. /**
  71906. * The effect that is created when initializing the post process.
  71907. * @returns The created effect corrisponding the the postprocess.
  71908. */
  71909. getEffect(): Effect;
  71910. /**
  71911. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71912. * @param postProcess The post process to share the output with.
  71913. * @returns This post process.
  71914. */
  71915. shareOutputWith(postProcess: PostProcess): PostProcess;
  71916. /**
  71917. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71918. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71919. */
  71920. useOwnOutput(): void;
  71921. /**
  71922. * Updates the effect with the current post process compile time values and recompiles the shader.
  71923. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71924. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71925. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71926. * @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
  71927. * @param onCompiled Called when the shader has been compiled.
  71928. * @param onError Called if there is an error when compiling a shader.
  71929. */
  71930. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71931. /**
  71932. * The post process is reusable if it can be used multiple times within one frame.
  71933. * @returns If the post process is reusable
  71934. */
  71935. isReusable(): boolean;
  71936. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71937. markTextureDirty(): void;
  71938. /**
  71939. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71940. * 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.
  71941. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71942. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71943. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71944. * @returns The target texture that was bound to be written to.
  71945. */
  71946. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71947. /**
  71948. * If the post process is supported.
  71949. */
  71950. readonly isSupported: boolean;
  71951. /**
  71952. * The aspect ratio of the output texture.
  71953. */
  71954. readonly aspectRatio: number;
  71955. /**
  71956. * Get a value indicating if the post-process is ready to be used
  71957. * @returns true if the post-process is ready (shader is compiled)
  71958. */
  71959. isReady(): boolean;
  71960. /**
  71961. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71962. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71963. */
  71964. apply(): Nullable<Effect>;
  71965. private _disposeTextures;
  71966. /**
  71967. * Disposes the post process.
  71968. * @param camera The camera to dispose the post process on.
  71969. */
  71970. dispose(camera?: Camera): void;
  71971. }
  71972. }
  71973. declare module BABYLON {
  71974. /**
  71975. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71976. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71977. */
  71978. export class PostProcessManager {
  71979. private _scene;
  71980. private _indexBuffer;
  71981. private _vertexBuffers;
  71982. /**
  71983. * Creates a new instance PostProcess
  71984. * @param scene The scene that the post process is associated with.
  71985. */
  71986. constructor(scene: Scene);
  71987. private _prepareBuffers;
  71988. private _buildIndexBuffer;
  71989. /**
  71990. * Rebuilds the vertex buffers of the manager.
  71991. * @hidden
  71992. */
  71993. _rebuild(): void;
  71994. /**
  71995. * Prepares a frame to be run through a post process.
  71996. * @param sourceTexture The input texture to the post procesess. (default: null)
  71997. * @param postProcesses An array of post processes to be run. (default: null)
  71998. * @returns True if the post processes were able to be run.
  71999. * @hidden
  72000. */
  72001. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  72002. /**
  72003. * Manually render a set of post processes to a texture.
  72004. * @param postProcesses An array of post processes to be run.
  72005. * @param targetTexture The target texture to render to.
  72006. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  72007. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  72008. * @param lodLevel defines which lod of the texture to render to
  72009. */
  72010. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  72011. /**
  72012. * Finalize the result of the output of the postprocesses.
  72013. * @param doNotPresent If true the result will not be displayed to the screen.
  72014. * @param targetTexture The target texture to render to.
  72015. * @param faceIndex The index of the face to bind the target texture to.
  72016. * @param postProcesses The array of post processes to render.
  72017. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  72018. * @hidden
  72019. */
  72020. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  72021. /**
  72022. * Disposes of the post process manager.
  72023. */
  72024. dispose(): void;
  72025. }
  72026. }
  72027. declare module BABYLON {
  72028. interface AbstractScene {
  72029. /**
  72030. * The list of layers (background and foreground) of the scene
  72031. */
  72032. layers: Array<Layer>;
  72033. }
  72034. /**
  72035. * Defines the layer scene component responsible to manage any layers
  72036. * in a given scene.
  72037. */
  72038. export class LayerSceneComponent implements ISceneComponent {
  72039. /**
  72040. * The component name helpfull to identify the component in the list of scene components.
  72041. */
  72042. readonly name: string;
  72043. /**
  72044. * The scene the component belongs to.
  72045. */
  72046. scene: Scene;
  72047. private _engine;
  72048. /**
  72049. * Creates a new instance of the component for the given scene
  72050. * @param scene Defines the scene to register the component in
  72051. */
  72052. constructor(scene: Scene);
  72053. /**
  72054. * Registers the component in a given scene
  72055. */
  72056. register(): void;
  72057. /**
  72058. * Rebuilds the elements related to this component in case of
  72059. * context lost for instance.
  72060. */
  72061. rebuild(): void;
  72062. /**
  72063. * Disposes the component and the associated ressources.
  72064. */
  72065. dispose(): void;
  72066. private _draw;
  72067. private _drawCameraPredicate;
  72068. private _drawCameraBackground;
  72069. private _drawCameraForeground;
  72070. private _drawRenderTargetPredicate;
  72071. private _drawRenderTargetBackground;
  72072. private _drawRenderTargetForeground;
  72073. }
  72074. }
  72075. declare module BABYLON {
  72076. /** @hidden */
  72077. export var layerPixelShader: {
  72078. name: string;
  72079. shader: string;
  72080. };
  72081. }
  72082. declare module BABYLON {
  72083. /** @hidden */
  72084. export var layerVertexShader: {
  72085. name: string;
  72086. shader: string;
  72087. };
  72088. }
  72089. declare module BABYLON {
  72090. /**
  72091. * This represents a full screen 2d layer.
  72092. * This can be useful to display a picture in the background of your scene for instance.
  72093. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72094. */
  72095. export class Layer {
  72096. /**
  72097. * Define the name of the layer.
  72098. */
  72099. name: string;
  72100. /**
  72101. * Define the texture the layer should display.
  72102. */
  72103. texture: Nullable<Texture>;
  72104. /**
  72105. * Is the layer in background or foreground.
  72106. */
  72107. isBackground: boolean;
  72108. /**
  72109. * Define the color of the layer (instead of texture).
  72110. */
  72111. color: Color4;
  72112. /**
  72113. * Define the scale of the layer in order to zoom in out of the texture.
  72114. */
  72115. scale: Vector2;
  72116. /**
  72117. * Define an offset for the layer in order to shift the texture.
  72118. */
  72119. offset: Vector2;
  72120. /**
  72121. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72122. */
  72123. alphaBlendingMode: number;
  72124. /**
  72125. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72126. * Alpha test will not mix with the background color in case of transparency.
  72127. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72128. */
  72129. alphaTest: boolean;
  72130. /**
  72131. * Define a mask to restrict the layer to only some of the scene cameras.
  72132. */
  72133. layerMask: number;
  72134. /**
  72135. * Define the list of render target the layer is visible into.
  72136. */
  72137. renderTargetTextures: RenderTargetTexture[];
  72138. /**
  72139. * Define if the layer is only used in renderTarget or if it also
  72140. * renders in the main frame buffer of the canvas.
  72141. */
  72142. renderOnlyInRenderTargetTextures: boolean;
  72143. private _scene;
  72144. private _vertexBuffers;
  72145. private _indexBuffer;
  72146. private _effect;
  72147. private _alphaTestEffect;
  72148. /**
  72149. * An event triggered when the layer is disposed.
  72150. */
  72151. onDisposeObservable: Observable<Layer>;
  72152. private _onDisposeObserver;
  72153. /**
  72154. * Back compatibility with callback before the onDisposeObservable existed.
  72155. * The set callback will be triggered when the layer has been disposed.
  72156. */
  72157. onDispose: () => void;
  72158. /**
  72159. * An event triggered before rendering the scene
  72160. */
  72161. onBeforeRenderObservable: Observable<Layer>;
  72162. private _onBeforeRenderObserver;
  72163. /**
  72164. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72165. * The set callback will be triggered just before rendering the layer.
  72166. */
  72167. onBeforeRender: () => void;
  72168. /**
  72169. * An event triggered after rendering the scene
  72170. */
  72171. onAfterRenderObservable: Observable<Layer>;
  72172. private _onAfterRenderObserver;
  72173. /**
  72174. * Back compatibility with callback before the onAfterRenderObservable existed.
  72175. * The set callback will be triggered just after rendering the layer.
  72176. */
  72177. onAfterRender: () => void;
  72178. /**
  72179. * Instantiates a new layer.
  72180. * This represents a full screen 2d layer.
  72181. * This can be useful to display a picture in the background of your scene for instance.
  72182. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72183. * @param name Define the name of the layer in the scene
  72184. * @param imgUrl Define the url of the texture to display in the layer
  72185. * @param scene Define the scene the layer belongs to
  72186. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72187. * @param color Defines a color for the layer
  72188. */
  72189. constructor(
  72190. /**
  72191. * Define the name of the layer.
  72192. */
  72193. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72194. private _createIndexBuffer;
  72195. /** @hidden */
  72196. _rebuild(): void;
  72197. /**
  72198. * Renders the layer in the scene.
  72199. */
  72200. render(): void;
  72201. /**
  72202. * Disposes and releases the associated ressources.
  72203. */
  72204. dispose(): void;
  72205. }
  72206. }
  72207. declare module BABYLON {
  72208. interface AbstractScene {
  72209. /**
  72210. * The list of procedural textures added to the scene
  72211. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72212. */
  72213. proceduralTextures: Array<ProceduralTexture>;
  72214. }
  72215. /**
  72216. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72217. * in a given scene.
  72218. */
  72219. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72220. /**
  72221. * The component name helpfull to identify the component in the list of scene components.
  72222. */
  72223. readonly name: string;
  72224. /**
  72225. * The scene the component belongs to.
  72226. */
  72227. scene: Scene;
  72228. /**
  72229. * Creates a new instance of the component for the given scene
  72230. * @param scene Defines the scene to register the component in
  72231. */
  72232. constructor(scene: Scene);
  72233. /**
  72234. * Registers the component in a given scene
  72235. */
  72236. register(): void;
  72237. /**
  72238. * Rebuilds the elements related to this component in case of
  72239. * context lost for instance.
  72240. */
  72241. rebuild(): void;
  72242. /**
  72243. * Disposes the component and the associated ressources.
  72244. */
  72245. dispose(): void;
  72246. private _beforeClear;
  72247. }
  72248. }
  72249. declare module BABYLON {
  72250. /** @hidden */
  72251. export var proceduralVertexShader: {
  72252. name: string;
  72253. shader: string;
  72254. };
  72255. }
  72256. declare module BABYLON {
  72257. /**
  72258. * 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.
  72259. * This is the base class of any Procedural texture and contains most of the shareable code.
  72260. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72261. */
  72262. export class ProceduralTexture extends Texture {
  72263. isCube: boolean;
  72264. /**
  72265. * Define if the texture is enabled or not (disabled texture will not render)
  72266. */
  72267. isEnabled: boolean;
  72268. /**
  72269. * Define if the texture must be cleared before rendering (default is true)
  72270. */
  72271. autoClear: boolean;
  72272. /**
  72273. * Callback called when the texture is generated
  72274. */
  72275. onGenerated: () => void;
  72276. /**
  72277. * Event raised when the texture is generated
  72278. */
  72279. onGeneratedObservable: Observable<ProceduralTexture>;
  72280. /** @hidden */
  72281. _generateMipMaps: boolean;
  72282. /** @hidden **/
  72283. _effect: Effect;
  72284. /** @hidden */
  72285. _textures: {
  72286. [key: string]: Texture;
  72287. };
  72288. private _size;
  72289. private _currentRefreshId;
  72290. private _refreshRate;
  72291. private _vertexBuffers;
  72292. private _indexBuffer;
  72293. private _uniforms;
  72294. private _samplers;
  72295. private _fragment;
  72296. private _floats;
  72297. private _ints;
  72298. private _floatsArrays;
  72299. private _colors3;
  72300. private _colors4;
  72301. private _vectors2;
  72302. private _vectors3;
  72303. private _matrices;
  72304. private _fallbackTexture;
  72305. private _fallbackTextureUsed;
  72306. private _engine;
  72307. private _cachedDefines;
  72308. private _contentUpdateId;
  72309. private _contentData;
  72310. /**
  72311. * Instantiates a new procedural texture.
  72312. * 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.
  72313. * This is the base class of any Procedural texture and contains most of the shareable code.
  72314. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72315. * @param name Define the name of the texture
  72316. * @param size Define the size of the texture to create
  72317. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72318. * @param scene Define the scene the texture belongs to
  72319. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72320. * @param generateMipMaps Define if the texture should creates mip maps or not
  72321. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72322. */
  72323. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72324. /**
  72325. * The effect that is created when initializing the post process.
  72326. * @returns The created effect corrisponding the the postprocess.
  72327. */
  72328. getEffect(): Effect;
  72329. /**
  72330. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72331. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72332. */
  72333. getContent(): Nullable<ArrayBufferView>;
  72334. private _createIndexBuffer;
  72335. /** @hidden */
  72336. _rebuild(): void;
  72337. /**
  72338. * Resets the texture in order to recreate its associated resources.
  72339. * This can be called in case of context loss
  72340. */
  72341. reset(): void;
  72342. protected _getDefines(): string;
  72343. /**
  72344. * Is the texture ready to be used ? (rendered at least once)
  72345. * @returns true if ready, otherwise, false.
  72346. */
  72347. isReady(): boolean;
  72348. /**
  72349. * Resets the refresh counter of the texture and start bak from scratch.
  72350. * Could be useful to regenerate the texture if it is setup to render only once.
  72351. */
  72352. resetRefreshCounter(): void;
  72353. /**
  72354. * Set the fragment shader to use in order to render the texture.
  72355. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72356. */
  72357. setFragment(fragment: any): void;
  72358. /**
  72359. * Define the refresh rate of the texture or the rendering frequency.
  72360. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72361. */
  72362. refreshRate: number;
  72363. /** @hidden */
  72364. _shouldRender(): boolean;
  72365. /**
  72366. * Get the size the texture is rendering at.
  72367. * @returns the size (texture is always squared)
  72368. */
  72369. getRenderSize(): number;
  72370. /**
  72371. * Resize the texture to new value.
  72372. * @param size Define the new size the texture should have
  72373. * @param generateMipMaps Define whether the new texture should create mip maps
  72374. */
  72375. resize(size: number, generateMipMaps: boolean): void;
  72376. private _checkUniform;
  72377. /**
  72378. * Set a texture in the shader program used to render.
  72379. * @param name Define the name of the uniform samplers as defined in the shader
  72380. * @param texture Define the texture to bind to this sampler
  72381. * @return the texture itself allowing "fluent" like uniform updates
  72382. */
  72383. setTexture(name: string, texture: Texture): ProceduralTexture;
  72384. /**
  72385. * Set a float in the shader.
  72386. * @param name Define the name of the uniform as defined in the shader
  72387. * @param value Define the value to give to the uniform
  72388. * @return the texture itself allowing "fluent" like uniform updates
  72389. */
  72390. setFloat(name: string, value: number): ProceduralTexture;
  72391. /**
  72392. * Set a int in the shader.
  72393. * @param name Define the name of the uniform as defined in the shader
  72394. * @param value Define the value to give to the uniform
  72395. * @return the texture itself allowing "fluent" like uniform updates
  72396. */
  72397. setInt(name: string, value: number): ProceduralTexture;
  72398. /**
  72399. * Set an array of floats in the shader.
  72400. * @param name Define the name of the uniform as defined in the shader
  72401. * @param value Define the value to give to the uniform
  72402. * @return the texture itself allowing "fluent" like uniform updates
  72403. */
  72404. setFloats(name: string, value: number[]): ProceduralTexture;
  72405. /**
  72406. * Set a vec3 in the shader from a Color3.
  72407. * @param name Define the name of the uniform as defined in the shader
  72408. * @param value Define the value to give to the uniform
  72409. * @return the texture itself allowing "fluent" like uniform updates
  72410. */
  72411. setColor3(name: string, value: Color3): ProceduralTexture;
  72412. /**
  72413. * Set a vec4 in the shader from a Color4.
  72414. * @param name Define the name of the uniform as defined in the shader
  72415. * @param value Define the value to give to the uniform
  72416. * @return the texture itself allowing "fluent" like uniform updates
  72417. */
  72418. setColor4(name: string, value: Color4): ProceduralTexture;
  72419. /**
  72420. * Set a vec2 in the shader from a Vector2.
  72421. * @param name Define the name of the uniform as defined in the shader
  72422. * @param value Define the value to give to the uniform
  72423. * @return the texture itself allowing "fluent" like uniform updates
  72424. */
  72425. setVector2(name: string, value: Vector2): ProceduralTexture;
  72426. /**
  72427. * Set a vec3 in the shader from a Vector3.
  72428. * @param name Define the name of the uniform as defined in the shader
  72429. * @param value Define the value to give to the uniform
  72430. * @return the texture itself allowing "fluent" like uniform updates
  72431. */
  72432. setVector3(name: string, value: Vector3): ProceduralTexture;
  72433. /**
  72434. * Set a mat4 in the shader from a MAtrix.
  72435. * @param name Define the name of the uniform as defined in the shader
  72436. * @param value Define the value to give to the uniform
  72437. * @return the texture itself allowing "fluent" like uniform updates
  72438. */
  72439. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72440. /**
  72441. * Render the texture to its associated render target.
  72442. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72443. */
  72444. render(useCameraPostProcess?: boolean): void;
  72445. /**
  72446. * Clone the texture.
  72447. * @returns the cloned texture
  72448. */
  72449. clone(): ProceduralTexture;
  72450. /**
  72451. * Dispose the texture and release its asoociated resources.
  72452. */
  72453. dispose(): void;
  72454. }
  72455. }
  72456. declare module BABYLON {
  72457. /**
  72458. * This represents the base class for particle system in Babylon.
  72459. * 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.
  72460. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72461. * @example https://doc.babylonjs.com/babylon101/particles
  72462. */
  72463. export class BaseParticleSystem {
  72464. /**
  72465. * Source color is added to the destination color without alpha affecting the result
  72466. */
  72467. static BLENDMODE_ONEONE: number;
  72468. /**
  72469. * Blend current color and particle color using particle’s alpha
  72470. */
  72471. static BLENDMODE_STANDARD: number;
  72472. /**
  72473. * Add current color and particle color multiplied by particle’s alpha
  72474. */
  72475. static BLENDMODE_ADD: number;
  72476. /**
  72477. * Multiply current color with particle color
  72478. */
  72479. static BLENDMODE_MULTIPLY: number;
  72480. /**
  72481. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72482. */
  72483. static BLENDMODE_MULTIPLYADD: number;
  72484. /**
  72485. * List of animations used by the particle system.
  72486. */
  72487. animations: Animation[];
  72488. /**
  72489. * The id of the Particle system.
  72490. */
  72491. id: string;
  72492. /**
  72493. * The friendly name of the Particle system.
  72494. */
  72495. name: string;
  72496. /**
  72497. * The rendering group used by the Particle system to chose when to render.
  72498. */
  72499. renderingGroupId: number;
  72500. /**
  72501. * The emitter represents the Mesh or position we are attaching the particle system to.
  72502. */
  72503. emitter: Nullable<AbstractMesh | Vector3>;
  72504. /**
  72505. * The maximum number of particles to emit per frame
  72506. */
  72507. emitRate: number;
  72508. /**
  72509. * If you want to launch only a few particles at once, that can be done, as well.
  72510. */
  72511. manualEmitCount: number;
  72512. /**
  72513. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72514. */
  72515. updateSpeed: number;
  72516. /**
  72517. * The amount of time the particle system is running (depends of the overall update speed).
  72518. */
  72519. targetStopDuration: number;
  72520. /**
  72521. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72522. */
  72523. disposeOnStop: boolean;
  72524. /**
  72525. * Minimum power of emitting particles.
  72526. */
  72527. minEmitPower: number;
  72528. /**
  72529. * Maximum power of emitting particles.
  72530. */
  72531. maxEmitPower: number;
  72532. /**
  72533. * Minimum life time of emitting particles.
  72534. */
  72535. minLifeTime: number;
  72536. /**
  72537. * Maximum life time of emitting particles.
  72538. */
  72539. maxLifeTime: number;
  72540. /**
  72541. * Minimum Size of emitting particles.
  72542. */
  72543. minSize: number;
  72544. /**
  72545. * Maximum Size of emitting particles.
  72546. */
  72547. maxSize: number;
  72548. /**
  72549. * Minimum scale of emitting particles on X axis.
  72550. */
  72551. minScaleX: number;
  72552. /**
  72553. * Maximum scale of emitting particles on X axis.
  72554. */
  72555. maxScaleX: number;
  72556. /**
  72557. * Minimum scale of emitting particles on Y axis.
  72558. */
  72559. minScaleY: number;
  72560. /**
  72561. * Maximum scale of emitting particles on Y axis.
  72562. */
  72563. maxScaleY: number;
  72564. /**
  72565. * Gets or sets the minimal initial rotation in radians.
  72566. */
  72567. minInitialRotation: number;
  72568. /**
  72569. * Gets or sets the maximal initial rotation in radians.
  72570. */
  72571. maxInitialRotation: number;
  72572. /**
  72573. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72574. */
  72575. minAngularSpeed: number;
  72576. /**
  72577. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72578. */
  72579. maxAngularSpeed: number;
  72580. /**
  72581. * The texture used to render each particle. (this can be a spritesheet)
  72582. */
  72583. particleTexture: Nullable<Texture>;
  72584. /**
  72585. * The layer mask we are rendering the particles through.
  72586. */
  72587. layerMask: number;
  72588. /**
  72589. * This can help using your own shader to render the particle system.
  72590. * The according effect will be created
  72591. */
  72592. customShader: any;
  72593. /**
  72594. * By default particle system starts as soon as they are created. This prevents the
  72595. * automatic start to happen and let you decide when to start emitting particles.
  72596. */
  72597. preventAutoStart: boolean;
  72598. private _noiseTexture;
  72599. /**
  72600. * Gets or sets a texture used to add random noise to particle positions
  72601. */
  72602. noiseTexture: Nullable<ProceduralTexture>;
  72603. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72604. noiseStrength: Vector3;
  72605. /**
  72606. * Callback triggered when the particle animation is ending.
  72607. */
  72608. onAnimationEnd: Nullable<() => void>;
  72609. /**
  72610. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72611. */
  72612. blendMode: number;
  72613. /**
  72614. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72615. * to override the particles.
  72616. */
  72617. forceDepthWrite: boolean;
  72618. /** 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 */
  72619. preWarmCycles: number;
  72620. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72621. preWarmStepOffset: number;
  72622. /**
  72623. * 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)
  72624. */
  72625. spriteCellChangeSpeed: number;
  72626. /**
  72627. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72628. */
  72629. startSpriteCellID: number;
  72630. /**
  72631. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72632. */
  72633. endSpriteCellID: number;
  72634. /**
  72635. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72636. */
  72637. spriteCellWidth: number;
  72638. /**
  72639. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72640. */
  72641. spriteCellHeight: number;
  72642. /**
  72643. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72644. */
  72645. spriteRandomStartCell: boolean;
  72646. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72647. translationPivot: Vector2;
  72648. /** @hidden */
  72649. protected _isAnimationSheetEnabled: boolean;
  72650. /**
  72651. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72652. */
  72653. beginAnimationOnStart: boolean;
  72654. /**
  72655. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72656. */
  72657. beginAnimationFrom: number;
  72658. /**
  72659. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72660. */
  72661. beginAnimationTo: number;
  72662. /**
  72663. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72664. */
  72665. beginAnimationLoop: boolean;
  72666. /**
  72667. * Gets or sets a world offset applied to all particles
  72668. */
  72669. worldOffset: Vector3;
  72670. /**
  72671. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72672. */
  72673. isAnimationSheetEnabled: boolean;
  72674. /**
  72675. * Get hosting scene
  72676. * @returns the scene
  72677. */
  72678. getScene(): Scene;
  72679. /**
  72680. * You can use gravity if you want to give an orientation to your particles.
  72681. */
  72682. gravity: Vector3;
  72683. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72684. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72685. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72686. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72687. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72688. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72689. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72690. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72691. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72692. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72693. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72694. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72695. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72696. /**
  72697. * Defines the delay in milliseconds before starting the system (0 by default)
  72698. */
  72699. startDelay: number;
  72700. /**
  72701. * Gets the current list of drag gradients.
  72702. * You must use addDragGradient and removeDragGradient to udpate this list
  72703. * @returns the list of drag gradients
  72704. */
  72705. getDragGradients(): Nullable<Array<FactorGradient>>;
  72706. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72707. limitVelocityDamping: number;
  72708. /**
  72709. * Gets the current list of limit velocity gradients.
  72710. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72711. * @returns the list of limit velocity gradients
  72712. */
  72713. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72714. /**
  72715. * Gets the current list of color gradients.
  72716. * You must use addColorGradient and removeColorGradient to udpate this list
  72717. * @returns the list of color gradients
  72718. */
  72719. getColorGradients(): Nullable<Array<ColorGradient>>;
  72720. /**
  72721. * Gets the current list of size gradients.
  72722. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72723. * @returns the list of size gradients
  72724. */
  72725. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72726. /**
  72727. * Gets the current list of color remap gradients.
  72728. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72729. * @returns the list of color remap gradients
  72730. */
  72731. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72732. /**
  72733. * Gets the current list of alpha remap gradients.
  72734. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72735. * @returns the list of alpha remap gradients
  72736. */
  72737. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72738. /**
  72739. * Gets the current list of life time gradients.
  72740. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72741. * @returns the list of life time gradients
  72742. */
  72743. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72744. /**
  72745. * Gets the current list of angular speed gradients.
  72746. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72747. * @returns the list of angular speed gradients
  72748. */
  72749. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72750. /**
  72751. * Gets the current list of velocity gradients.
  72752. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72753. * @returns the list of velocity gradients
  72754. */
  72755. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72756. /**
  72757. * Gets the current list of start size gradients.
  72758. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72759. * @returns the list of start size gradients
  72760. */
  72761. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72762. /**
  72763. * Gets the current list of emit rate gradients.
  72764. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72765. * @returns the list of emit rate gradients
  72766. */
  72767. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72768. /**
  72769. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72770. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72771. */
  72772. direction1: Vector3;
  72773. /**
  72774. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72775. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72776. */
  72777. direction2: Vector3;
  72778. /**
  72779. * 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.
  72780. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72781. */
  72782. minEmitBox: Vector3;
  72783. /**
  72784. * 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.
  72785. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72786. */
  72787. maxEmitBox: Vector3;
  72788. /**
  72789. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72790. */
  72791. color1: Color4;
  72792. /**
  72793. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72794. */
  72795. color2: Color4;
  72796. /**
  72797. * Color the particle will have at the end of its lifetime
  72798. */
  72799. colorDead: Color4;
  72800. /**
  72801. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72802. */
  72803. textureMask: Color4;
  72804. /**
  72805. * The particle emitter type defines the emitter used by the particle system.
  72806. * It can be for example box, sphere, or cone...
  72807. */
  72808. particleEmitterType: IParticleEmitterType;
  72809. /** @hidden */
  72810. _isSubEmitter: boolean;
  72811. /**
  72812. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72813. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72814. */
  72815. billboardMode: number;
  72816. protected _isBillboardBased: boolean;
  72817. /**
  72818. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72819. */
  72820. isBillboardBased: boolean;
  72821. /**
  72822. * The scene the particle system belongs to.
  72823. */
  72824. protected _scene: Scene;
  72825. /**
  72826. * Local cache of defines for image processing.
  72827. */
  72828. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72829. /**
  72830. * Default configuration related to image processing available in the standard Material.
  72831. */
  72832. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72833. /**
  72834. * Gets the image processing configuration used either in this material.
  72835. */
  72836. /**
  72837. * Sets the Default image processing configuration used either in the this material.
  72838. *
  72839. * If sets to null, the scene one is in use.
  72840. */
  72841. imageProcessingConfiguration: ImageProcessingConfiguration;
  72842. /**
  72843. * Attaches a new image processing configuration to the Standard Material.
  72844. * @param configuration
  72845. */
  72846. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72847. /** @hidden */
  72848. protected _reset(): void;
  72849. /** @hidden */
  72850. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72851. /**
  72852. * Instantiates a particle system.
  72853. * 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.
  72854. * @param name The name of the particle system
  72855. */
  72856. constructor(name: string);
  72857. /**
  72858. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72859. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72860. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72861. * @returns the emitter
  72862. */
  72863. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72864. /**
  72865. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72866. * @param radius The radius of the hemisphere to emit from
  72867. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72868. * @returns the emitter
  72869. */
  72870. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72871. /**
  72872. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72873. * @param radius The radius of the sphere to emit from
  72874. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72875. * @returns the emitter
  72876. */
  72877. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72878. /**
  72879. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72880. * @param radius The radius of the sphere to emit from
  72881. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72882. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72883. * @returns the emitter
  72884. */
  72885. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72886. /**
  72887. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72888. * @param radius The radius of the emission cylinder
  72889. * @param height The height of the emission cylinder
  72890. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72891. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72892. * @returns the emitter
  72893. */
  72894. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72895. /**
  72896. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72897. * @param radius The radius of the cylinder to emit from
  72898. * @param height The height of the emission cylinder
  72899. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72900. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72901. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72902. * @returns the emitter
  72903. */
  72904. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72905. /**
  72906. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72907. * @param radius The radius of the cone to emit from
  72908. * @param angle The base angle of the cone
  72909. * @returns the emitter
  72910. */
  72911. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72912. /**
  72913. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72914. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72915. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72916. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72917. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72918. * @returns the emitter
  72919. */
  72920. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72921. }
  72922. }
  72923. declare module BABYLON {
  72924. /**
  72925. * Type of sub emitter
  72926. */
  72927. export enum SubEmitterType {
  72928. /**
  72929. * Attached to the particle over it's lifetime
  72930. */
  72931. ATTACHED = 0,
  72932. /**
  72933. * Created when the particle dies
  72934. */
  72935. END = 1
  72936. }
  72937. /**
  72938. * Sub emitter class used to emit particles from an existing particle
  72939. */
  72940. export class SubEmitter {
  72941. /**
  72942. * the particle system to be used by the sub emitter
  72943. */
  72944. particleSystem: ParticleSystem;
  72945. /**
  72946. * Type of the submitter (Default: END)
  72947. */
  72948. type: SubEmitterType;
  72949. /**
  72950. * 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)
  72951. * Note: This only is supported when using an emitter of type Mesh
  72952. */
  72953. inheritDirection: boolean;
  72954. /**
  72955. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72956. */
  72957. inheritedVelocityAmount: number;
  72958. /**
  72959. * Creates a sub emitter
  72960. * @param particleSystem the particle system to be used by the sub emitter
  72961. */
  72962. constructor(
  72963. /**
  72964. * the particle system to be used by the sub emitter
  72965. */
  72966. particleSystem: ParticleSystem);
  72967. /**
  72968. * Clones the sub emitter
  72969. * @returns the cloned sub emitter
  72970. */
  72971. clone(): SubEmitter;
  72972. /**
  72973. * Serialize current object to a JSON object
  72974. * @returns the serialized object
  72975. */
  72976. serialize(): any;
  72977. /** @hidden */
  72978. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72979. /**
  72980. * Creates a new SubEmitter from a serialized JSON version
  72981. * @param serializationObject defines the JSON object to read from
  72982. * @param scene defines the hosting scene
  72983. * @param rootUrl defines the rootUrl for data loading
  72984. * @returns a new SubEmitter
  72985. */
  72986. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72987. /** Release associated resources */
  72988. dispose(): void;
  72989. }
  72990. }
  72991. declare module BABYLON {
  72992. /** @hidden */
  72993. export var clipPlaneFragmentDeclaration: {
  72994. name: string;
  72995. shader: string;
  72996. };
  72997. }
  72998. declare module BABYLON {
  72999. /** @hidden */
  73000. export var imageProcessingDeclaration: {
  73001. name: string;
  73002. shader: string;
  73003. };
  73004. }
  73005. declare module BABYLON {
  73006. /** @hidden */
  73007. export var imageProcessingFunctions: {
  73008. name: string;
  73009. shader: string;
  73010. };
  73011. }
  73012. declare module BABYLON {
  73013. /** @hidden */
  73014. export var clipPlaneFragment: {
  73015. name: string;
  73016. shader: string;
  73017. };
  73018. }
  73019. declare module BABYLON {
  73020. /** @hidden */
  73021. export var particlesPixelShader: {
  73022. name: string;
  73023. shader: string;
  73024. };
  73025. }
  73026. declare module BABYLON {
  73027. /** @hidden */
  73028. export var clipPlaneVertexDeclaration: {
  73029. name: string;
  73030. shader: string;
  73031. };
  73032. }
  73033. declare module BABYLON {
  73034. /** @hidden */
  73035. export var clipPlaneVertex: {
  73036. name: string;
  73037. shader: string;
  73038. };
  73039. }
  73040. declare module BABYLON {
  73041. /** @hidden */
  73042. export var particlesVertexShader: {
  73043. name: string;
  73044. shader: string;
  73045. };
  73046. }
  73047. declare module BABYLON {
  73048. /**
  73049. * This represents a particle system in Babylon.
  73050. * 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.
  73051. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73052. * @example https://doc.babylonjs.com/babylon101/particles
  73053. */
  73054. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73055. /**
  73056. * Billboard mode will only apply to Y axis
  73057. */
  73058. static readonly BILLBOARDMODE_Y: number;
  73059. /**
  73060. * Billboard mode will apply to all axes
  73061. */
  73062. static readonly BILLBOARDMODE_ALL: number;
  73063. /**
  73064. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73065. */
  73066. static readonly BILLBOARDMODE_STRETCHED: number;
  73067. /**
  73068. * This function can be defined to provide custom update for active particles.
  73069. * This function will be called instead of regular update (age, position, color, etc.).
  73070. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73071. */
  73072. updateFunction: (particles: Particle[]) => void;
  73073. private _emitterWorldMatrix;
  73074. /**
  73075. * This function can be defined to specify initial direction for every new particle.
  73076. * It by default use the emitterType defined function
  73077. */
  73078. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73079. /**
  73080. * This function can be defined to specify initial position for every new particle.
  73081. * It by default use the emitterType defined function
  73082. */
  73083. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73084. /**
  73085. * @hidden
  73086. */
  73087. _inheritedVelocityOffset: Vector3;
  73088. /**
  73089. * An event triggered when the system is disposed
  73090. */
  73091. onDisposeObservable: Observable<ParticleSystem>;
  73092. private _onDisposeObserver;
  73093. /**
  73094. * Sets a callback that will be triggered when the system is disposed
  73095. */
  73096. onDispose: () => void;
  73097. private _particles;
  73098. private _epsilon;
  73099. private _capacity;
  73100. private _stockParticles;
  73101. private _newPartsExcess;
  73102. private _vertexData;
  73103. private _vertexBuffer;
  73104. private _vertexBuffers;
  73105. private _spriteBuffer;
  73106. private _indexBuffer;
  73107. private _effect;
  73108. private _customEffect;
  73109. private _cachedDefines;
  73110. private _scaledColorStep;
  73111. private _colorDiff;
  73112. private _scaledDirection;
  73113. private _scaledGravity;
  73114. private _currentRenderId;
  73115. private _alive;
  73116. private _useInstancing;
  73117. private _started;
  73118. private _stopped;
  73119. private _actualFrame;
  73120. private _scaledUpdateSpeed;
  73121. private _vertexBufferSize;
  73122. /** @hidden */
  73123. _currentEmitRateGradient: Nullable<FactorGradient>;
  73124. /** @hidden */
  73125. _currentEmitRate1: number;
  73126. /** @hidden */
  73127. _currentEmitRate2: number;
  73128. /** @hidden */
  73129. _currentStartSizeGradient: Nullable<FactorGradient>;
  73130. /** @hidden */
  73131. _currentStartSize1: number;
  73132. /** @hidden */
  73133. _currentStartSize2: number;
  73134. private readonly _rawTextureWidth;
  73135. private _rampGradientsTexture;
  73136. private _useRampGradients;
  73137. /** Gets or sets a boolean indicating that ramp gradients must be used
  73138. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73139. */
  73140. useRampGradients: boolean;
  73141. /**
  73142. * 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.
  73143. * 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: [])
  73144. */
  73145. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73146. private _subEmitters;
  73147. /**
  73148. * @hidden
  73149. * If the particle systems emitter should be disposed when the particle system is disposed
  73150. */
  73151. _disposeEmitterOnDispose: boolean;
  73152. /**
  73153. * The current active Sub-systems, this property is used by the root particle system only.
  73154. */
  73155. activeSubSystems: Array<ParticleSystem>;
  73156. private _rootParticleSystem;
  73157. /**
  73158. * Gets the current list of active particles
  73159. */
  73160. readonly particles: Particle[];
  73161. /**
  73162. * Returns the string "ParticleSystem"
  73163. * @returns a string containing the class name
  73164. */
  73165. getClassName(): string;
  73166. /**
  73167. * Instantiates a particle system.
  73168. * 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.
  73169. * @param name The name of the particle system
  73170. * @param capacity The max number of particles alive at the same time
  73171. * @param scene The scene the particle system belongs to
  73172. * @param customEffect a custom effect used to change the way particles are rendered by default
  73173. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73174. * @param epsilon Offset used to render the particles
  73175. */
  73176. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73177. private _addFactorGradient;
  73178. private _removeFactorGradient;
  73179. /**
  73180. * Adds a new life time gradient
  73181. * @param gradient defines the gradient to use (between 0 and 1)
  73182. * @param factor defines the life time factor to affect to the specified gradient
  73183. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73184. * @returns the current particle system
  73185. */
  73186. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73187. /**
  73188. * Remove a specific life time gradient
  73189. * @param gradient defines the gradient to remove
  73190. * @returns the current particle system
  73191. */
  73192. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73193. /**
  73194. * Adds a new size gradient
  73195. * @param gradient defines the gradient to use (between 0 and 1)
  73196. * @param factor defines the size factor to affect to the specified gradient
  73197. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73198. * @returns the current particle system
  73199. */
  73200. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73201. /**
  73202. * Remove a specific size gradient
  73203. * @param gradient defines the gradient to remove
  73204. * @returns the current particle system
  73205. */
  73206. removeSizeGradient(gradient: number): IParticleSystem;
  73207. /**
  73208. * Adds a new color remap gradient
  73209. * @param gradient defines the gradient to use (between 0 and 1)
  73210. * @param min defines the color remap minimal range
  73211. * @param max defines the color remap maximal range
  73212. * @returns the current particle system
  73213. */
  73214. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73215. /**
  73216. * Remove a specific color remap gradient
  73217. * @param gradient defines the gradient to remove
  73218. * @returns the current particle system
  73219. */
  73220. removeColorRemapGradient(gradient: number): IParticleSystem;
  73221. /**
  73222. * Adds a new alpha remap gradient
  73223. * @param gradient defines the gradient to use (between 0 and 1)
  73224. * @param min defines the alpha remap minimal range
  73225. * @param max defines the alpha remap maximal range
  73226. * @returns the current particle system
  73227. */
  73228. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73229. /**
  73230. * Remove a specific alpha remap gradient
  73231. * @param gradient defines the gradient to remove
  73232. * @returns the current particle system
  73233. */
  73234. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73235. /**
  73236. * Adds a new angular speed gradient
  73237. * @param gradient defines the gradient to use (between 0 and 1)
  73238. * @param factor defines the angular speed to affect to the specified gradient
  73239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73240. * @returns the current particle system
  73241. */
  73242. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73243. /**
  73244. * Remove a specific angular speed gradient
  73245. * @param gradient defines the gradient to remove
  73246. * @returns the current particle system
  73247. */
  73248. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73249. /**
  73250. * Adds a new velocity gradient
  73251. * @param gradient defines the gradient to use (between 0 and 1)
  73252. * @param factor defines the velocity to affect to the specified gradient
  73253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73254. * @returns the current particle system
  73255. */
  73256. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73257. /**
  73258. * Remove a specific velocity gradient
  73259. * @param gradient defines the gradient to remove
  73260. * @returns the current particle system
  73261. */
  73262. removeVelocityGradient(gradient: number): IParticleSystem;
  73263. /**
  73264. * Adds a new limit velocity gradient
  73265. * @param gradient defines the gradient to use (between 0 and 1)
  73266. * @param factor defines the limit velocity value to affect to the specified gradient
  73267. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73268. * @returns the current particle system
  73269. */
  73270. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73271. /**
  73272. * Remove a specific limit velocity gradient
  73273. * @param gradient defines the gradient to remove
  73274. * @returns the current particle system
  73275. */
  73276. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73277. /**
  73278. * Adds a new drag gradient
  73279. * @param gradient defines the gradient to use (between 0 and 1)
  73280. * @param factor defines the drag value to affect to the specified gradient
  73281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73282. * @returns the current particle system
  73283. */
  73284. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73285. /**
  73286. * Remove a specific drag gradient
  73287. * @param gradient defines the gradient to remove
  73288. * @returns the current particle system
  73289. */
  73290. removeDragGradient(gradient: number): IParticleSystem;
  73291. /**
  73292. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73293. * @param gradient defines the gradient to use (between 0 and 1)
  73294. * @param factor defines the emit rate value to affect to the specified gradient
  73295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73296. * @returns the current particle system
  73297. */
  73298. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73299. /**
  73300. * Remove a specific emit rate gradient
  73301. * @param gradient defines the gradient to remove
  73302. * @returns the current particle system
  73303. */
  73304. removeEmitRateGradient(gradient: number): IParticleSystem;
  73305. /**
  73306. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73307. * @param gradient defines the gradient to use (between 0 and 1)
  73308. * @param factor defines the start size value to affect to the specified gradient
  73309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73310. * @returns the current particle system
  73311. */
  73312. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73313. /**
  73314. * Remove a specific start size gradient
  73315. * @param gradient defines the gradient to remove
  73316. * @returns the current particle system
  73317. */
  73318. removeStartSizeGradient(gradient: number): IParticleSystem;
  73319. private _createRampGradientTexture;
  73320. /**
  73321. * Gets the current list of ramp gradients.
  73322. * You must use addRampGradient and removeRampGradient to udpate this list
  73323. * @returns the list of ramp gradients
  73324. */
  73325. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73326. /**
  73327. * Adds a new ramp gradient used to remap particle colors
  73328. * @param gradient defines the gradient to use (between 0 and 1)
  73329. * @param color defines the color to affect to the specified gradient
  73330. * @returns the current particle system
  73331. */
  73332. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73333. /**
  73334. * Remove a specific ramp gradient
  73335. * @param gradient defines the gradient to remove
  73336. * @returns the current particle system
  73337. */
  73338. removeRampGradient(gradient: number): ParticleSystem;
  73339. /**
  73340. * Adds a new color gradient
  73341. * @param gradient defines the gradient to use (between 0 and 1)
  73342. * @param color1 defines the color to affect to the specified gradient
  73343. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73344. * @returns this particle system
  73345. */
  73346. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73347. /**
  73348. * Remove a specific color gradient
  73349. * @param gradient defines the gradient to remove
  73350. * @returns this particle system
  73351. */
  73352. removeColorGradient(gradient: number): IParticleSystem;
  73353. private _fetchR;
  73354. protected _reset(): void;
  73355. private _resetEffect;
  73356. private _createVertexBuffers;
  73357. private _createIndexBuffer;
  73358. /**
  73359. * Gets the maximum number of particles active at the same time.
  73360. * @returns The max number of active particles.
  73361. */
  73362. getCapacity(): number;
  73363. /**
  73364. * Gets whether there are still active particles in the system.
  73365. * @returns True if it is alive, otherwise false.
  73366. */
  73367. isAlive(): boolean;
  73368. /**
  73369. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73370. * @returns True if it has been started, otherwise false.
  73371. */
  73372. isStarted(): boolean;
  73373. private _prepareSubEmitterInternalArray;
  73374. /**
  73375. * Starts the particle system and begins to emit
  73376. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73377. */
  73378. start(delay?: number): void;
  73379. /**
  73380. * Stops the particle system.
  73381. * @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.
  73382. */
  73383. stop(stopSubEmitters?: boolean): void;
  73384. /**
  73385. * Remove all active particles
  73386. */
  73387. reset(): void;
  73388. /**
  73389. * @hidden (for internal use only)
  73390. */
  73391. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73392. /**
  73393. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73394. * Its lifetime will start back at 0.
  73395. */
  73396. recycleParticle: (particle: Particle) => void;
  73397. private _stopSubEmitters;
  73398. private _createParticle;
  73399. private _removeFromRoot;
  73400. private _emitFromParticle;
  73401. private _update;
  73402. /** @hidden */
  73403. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73404. /** @hidden */
  73405. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73406. /** @hidden */
  73407. private _getEffect;
  73408. /**
  73409. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73410. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73411. */
  73412. animate(preWarmOnly?: boolean): void;
  73413. private _appendParticleVertices;
  73414. /**
  73415. * Rebuilds the particle system.
  73416. */
  73417. rebuild(): void;
  73418. /**
  73419. * Is this system ready to be used/rendered
  73420. * @return true if the system is ready
  73421. */
  73422. isReady(): boolean;
  73423. private _render;
  73424. /**
  73425. * Renders the particle system in its current state.
  73426. * @returns the current number of particles
  73427. */
  73428. render(): number;
  73429. /**
  73430. * Disposes the particle system and free the associated resources
  73431. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73432. */
  73433. dispose(disposeTexture?: boolean): void;
  73434. /**
  73435. * Clones the particle system.
  73436. * @param name The name of the cloned object
  73437. * @param newEmitter The new emitter to use
  73438. * @returns the cloned particle system
  73439. */
  73440. clone(name: string, newEmitter: any): ParticleSystem;
  73441. /**
  73442. * Serializes the particle system to a JSON object.
  73443. * @returns the JSON object
  73444. */
  73445. serialize(): any;
  73446. /** @hidden */
  73447. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73448. /** @hidden */
  73449. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73450. /**
  73451. * Parses a JSON object to create a particle system.
  73452. * @param parsedParticleSystem The JSON object to parse
  73453. * @param scene The scene to create the particle system in
  73454. * @param rootUrl The root url to use to load external dependencies like texture
  73455. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73456. * @returns the Parsed particle system
  73457. */
  73458. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73459. }
  73460. }
  73461. declare module BABYLON {
  73462. /**
  73463. * A particle represents one of the element emitted by a particle system.
  73464. * This is mainly define by its coordinates, direction, velocity and age.
  73465. */
  73466. export class Particle {
  73467. /**
  73468. * The particle system the particle belongs to.
  73469. */
  73470. particleSystem: ParticleSystem;
  73471. private static _Count;
  73472. /**
  73473. * Unique ID of the particle
  73474. */
  73475. id: number;
  73476. /**
  73477. * The world position of the particle in the scene.
  73478. */
  73479. position: Vector3;
  73480. /**
  73481. * The world direction of the particle in the scene.
  73482. */
  73483. direction: Vector3;
  73484. /**
  73485. * The color of the particle.
  73486. */
  73487. color: Color4;
  73488. /**
  73489. * The color change of the particle per step.
  73490. */
  73491. colorStep: Color4;
  73492. /**
  73493. * Defines how long will the life of the particle be.
  73494. */
  73495. lifeTime: number;
  73496. /**
  73497. * The current age of the particle.
  73498. */
  73499. age: number;
  73500. /**
  73501. * The current size of the particle.
  73502. */
  73503. size: number;
  73504. /**
  73505. * The current scale of the particle.
  73506. */
  73507. scale: Vector2;
  73508. /**
  73509. * The current angle of the particle.
  73510. */
  73511. angle: number;
  73512. /**
  73513. * Defines how fast is the angle changing.
  73514. */
  73515. angularSpeed: number;
  73516. /**
  73517. * Defines the cell index used by the particle to be rendered from a sprite.
  73518. */
  73519. cellIndex: number;
  73520. /**
  73521. * The information required to support color remapping
  73522. */
  73523. remapData: Vector4;
  73524. /** @hidden */
  73525. _randomCellOffset?: number;
  73526. /** @hidden */
  73527. _initialDirection: Nullable<Vector3>;
  73528. /** @hidden */
  73529. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73530. /** @hidden */
  73531. _initialStartSpriteCellID: number;
  73532. /** @hidden */
  73533. _initialEndSpriteCellID: number;
  73534. /** @hidden */
  73535. _currentColorGradient: Nullable<ColorGradient>;
  73536. /** @hidden */
  73537. _currentColor1: Color4;
  73538. /** @hidden */
  73539. _currentColor2: Color4;
  73540. /** @hidden */
  73541. _currentSizeGradient: Nullable<FactorGradient>;
  73542. /** @hidden */
  73543. _currentSize1: number;
  73544. /** @hidden */
  73545. _currentSize2: number;
  73546. /** @hidden */
  73547. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73548. /** @hidden */
  73549. _currentAngularSpeed1: number;
  73550. /** @hidden */
  73551. _currentAngularSpeed2: number;
  73552. /** @hidden */
  73553. _currentVelocityGradient: Nullable<FactorGradient>;
  73554. /** @hidden */
  73555. _currentVelocity1: number;
  73556. /** @hidden */
  73557. _currentVelocity2: number;
  73558. /** @hidden */
  73559. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73560. /** @hidden */
  73561. _currentLimitVelocity1: number;
  73562. /** @hidden */
  73563. _currentLimitVelocity2: number;
  73564. /** @hidden */
  73565. _currentDragGradient: Nullable<FactorGradient>;
  73566. /** @hidden */
  73567. _currentDrag1: number;
  73568. /** @hidden */
  73569. _currentDrag2: number;
  73570. /** @hidden */
  73571. _randomNoiseCoordinates1: Vector3;
  73572. /** @hidden */
  73573. _randomNoiseCoordinates2: Vector3;
  73574. /**
  73575. * Creates a new instance Particle
  73576. * @param particleSystem the particle system the particle belongs to
  73577. */
  73578. constructor(
  73579. /**
  73580. * The particle system the particle belongs to.
  73581. */
  73582. particleSystem: ParticleSystem);
  73583. private updateCellInfoFromSystem;
  73584. /**
  73585. * Defines how the sprite cell index is updated for the particle
  73586. */
  73587. updateCellIndex(): void;
  73588. /** @hidden */
  73589. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73590. /** @hidden */
  73591. _inheritParticleInfoToSubEmitters(): void;
  73592. /** @hidden */
  73593. _reset(): void;
  73594. /**
  73595. * Copy the properties of particle to another one.
  73596. * @param other the particle to copy the information to.
  73597. */
  73598. copyTo(other: Particle): void;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * Particle emitter represents a volume emitting particles.
  73604. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73605. */
  73606. export interface IParticleEmitterType {
  73607. /**
  73608. * Called by the particle System when the direction is computed for the created particle.
  73609. * @param worldMatrix is the world matrix of the particle system
  73610. * @param directionToUpdate is the direction vector to update with the result
  73611. * @param particle is the particle we are computed the direction for
  73612. */
  73613. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73614. /**
  73615. * Called by the particle System when the position is computed for the created particle.
  73616. * @param worldMatrix is the world matrix of the particle system
  73617. * @param positionToUpdate is the position vector to update with the result
  73618. * @param particle is the particle we are computed the position for
  73619. */
  73620. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73621. /**
  73622. * Clones the current emitter and returns a copy of it
  73623. * @returns the new emitter
  73624. */
  73625. clone(): IParticleEmitterType;
  73626. /**
  73627. * Called by the GPUParticleSystem to setup the update shader
  73628. * @param effect defines the update shader
  73629. */
  73630. applyToShader(effect: Effect): void;
  73631. /**
  73632. * Returns a string to use to update the GPU particles update shader
  73633. * @returns the effect defines string
  73634. */
  73635. getEffectDefines(): string;
  73636. /**
  73637. * Returns a string representing the class name
  73638. * @returns a string containing the class name
  73639. */
  73640. getClassName(): string;
  73641. /**
  73642. * Serializes the particle system to a JSON object.
  73643. * @returns the JSON object
  73644. */
  73645. serialize(): any;
  73646. /**
  73647. * Parse properties from a JSON object
  73648. * @param serializationObject defines the JSON object
  73649. */
  73650. parse(serializationObject: any): void;
  73651. }
  73652. }
  73653. declare module BABYLON {
  73654. /**
  73655. * Particle emitter emitting particles from the inside of a box.
  73656. * It emits the particles randomly between 2 given directions.
  73657. */
  73658. export class BoxParticleEmitter implements IParticleEmitterType {
  73659. /**
  73660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73661. */
  73662. direction1: Vector3;
  73663. /**
  73664. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73665. */
  73666. direction2: Vector3;
  73667. /**
  73668. * 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.
  73669. */
  73670. minEmitBox: Vector3;
  73671. /**
  73672. * 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.
  73673. */
  73674. maxEmitBox: Vector3;
  73675. /**
  73676. * Creates a new instance BoxParticleEmitter
  73677. */
  73678. constructor();
  73679. /**
  73680. * Called by the particle System when the direction is computed for the created particle.
  73681. * @param worldMatrix is the world matrix of the particle system
  73682. * @param directionToUpdate is the direction vector to update with the result
  73683. * @param particle is the particle we are computed the direction for
  73684. */
  73685. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73686. /**
  73687. * Called by the particle System when the position is computed for the created particle.
  73688. * @param worldMatrix is the world matrix of the particle system
  73689. * @param positionToUpdate is the position vector to update with the result
  73690. * @param particle is the particle we are computed the position for
  73691. */
  73692. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73693. /**
  73694. * Clones the current emitter and returns a copy of it
  73695. * @returns the new emitter
  73696. */
  73697. clone(): BoxParticleEmitter;
  73698. /**
  73699. * Called by the GPUParticleSystem to setup the update shader
  73700. * @param effect defines the update shader
  73701. */
  73702. applyToShader(effect: Effect): void;
  73703. /**
  73704. * Returns a string to use to update the GPU particles update shader
  73705. * @returns a string containng the defines string
  73706. */
  73707. getEffectDefines(): string;
  73708. /**
  73709. * Returns the string "BoxParticleEmitter"
  73710. * @returns a string containing the class name
  73711. */
  73712. getClassName(): string;
  73713. /**
  73714. * Serializes the particle system to a JSON object.
  73715. * @returns the JSON object
  73716. */
  73717. serialize(): any;
  73718. /**
  73719. * Parse properties from a JSON object
  73720. * @param serializationObject defines the JSON object
  73721. */
  73722. parse(serializationObject: any): void;
  73723. }
  73724. }
  73725. declare module BABYLON {
  73726. /**
  73727. * Particle emitter emitting particles from the inside of a cone.
  73728. * It emits the particles alongside the cone volume from the base to the particle.
  73729. * The emission direction might be randomized.
  73730. */
  73731. export class ConeParticleEmitter implements IParticleEmitterType {
  73732. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73733. directionRandomizer: number;
  73734. private _radius;
  73735. private _angle;
  73736. private _height;
  73737. /**
  73738. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73739. */
  73740. radiusRange: number;
  73741. /**
  73742. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73743. */
  73744. heightRange: number;
  73745. /**
  73746. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73747. */
  73748. emitFromSpawnPointOnly: boolean;
  73749. /**
  73750. * Gets or sets the radius of the emission cone
  73751. */
  73752. radius: number;
  73753. /**
  73754. * Gets or sets the angle of the emission cone
  73755. */
  73756. angle: number;
  73757. private _buildHeight;
  73758. /**
  73759. * Creates a new instance ConeParticleEmitter
  73760. * @param radius the radius of the emission cone (1 by default)
  73761. * @param angle the cone base angle (PI by default)
  73762. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73763. */
  73764. constructor(radius?: number, angle?: number,
  73765. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73766. directionRandomizer?: number);
  73767. /**
  73768. * Called by the particle System when the direction is computed for the created particle.
  73769. * @param worldMatrix is the world matrix of the particle system
  73770. * @param directionToUpdate is the direction vector to update with the result
  73771. * @param particle is the particle we are computed the direction for
  73772. */
  73773. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73774. /**
  73775. * Called by the particle System when the position is computed for the created particle.
  73776. * @param worldMatrix is the world matrix of the particle system
  73777. * @param positionToUpdate is the position vector to update with the result
  73778. * @param particle is the particle we are computed the position for
  73779. */
  73780. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73781. /**
  73782. * Clones the current emitter and returns a copy of it
  73783. * @returns the new emitter
  73784. */
  73785. clone(): ConeParticleEmitter;
  73786. /**
  73787. * Called by the GPUParticleSystem to setup the update shader
  73788. * @param effect defines the update shader
  73789. */
  73790. applyToShader(effect: Effect): void;
  73791. /**
  73792. * Returns a string to use to update the GPU particles update shader
  73793. * @returns a string containng the defines string
  73794. */
  73795. getEffectDefines(): string;
  73796. /**
  73797. * Returns the string "ConeParticleEmitter"
  73798. * @returns a string containing the class name
  73799. */
  73800. getClassName(): string;
  73801. /**
  73802. * Serializes the particle system to a JSON object.
  73803. * @returns the JSON object
  73804. */
  73805. serialize(): any;
  73806. /**
  73807. * Parse properties from a JSON object
  73808. * @param serializationObject defines the JSON object
  73809. */
  73810. parse(serializationObject: any): void;
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /**
  73815. * Particle emitter emitting particles from the inside of a cylinder.
  73816. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73817. */
  73818. export class CylinderParticleEmitter implements IParticleEmitterType {
  73819. /**
  73820. * The radius of the emission cylinder.
  73821. */
  73822. radius: number;
  73823. /**
  73824. * The height of the emission cylinder.
  73825. */
  73826. height: number;
  73827. /**
  73828. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73829. */
  73830. radiusRange: number;
  73831. /**
  73832. * How much to randomize the particle direction [0-1].
  73833. */
  73834. directionRandomizer: number;
  73835. /**
  73836. * Creates a new instance CylinderParticleEmitter
  73837. * @param radius the radius of the emission cylinder (1 by default)
  73838. * @param height the height of the emission cylinder (1 by default)
  73839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73840. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73841. */
  73842. constructor(
  73843. /**
  73844. * The radius of the emission cylinder.
  73845. */
  73846. radius?: number,
  73847. /**
  73848. * The height of the emission cylinder.
  73849. */
  73850. height?: number,
  73851. /**
  73852. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73853. */
  73854. radiusRange?: number,
  73855. /**
  73856. * How much to randomize the particle direction [0-1].
  73857. */
  73858. directionRandomizer?: number);
  73859. /**
  73860. * Called by the particle System when the direction is computed for the created particle.
  73861. * @param worldMatrix is the world matrix of the particle system
  73862. * @param directionToUpdate is the direction vector to update with the result
  73863. * @param particle is the particle we are computed the direction for
  73864. */
  73865. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73866. /**
  73867. * Called by the particle System when the position is computed for the created particle.
  73868. * @param worldMatrix is the world matrix of the particle system
  73869. * @param positionToUpdate is the position vector to update with the result
  73870. * @param particle is the particle we are computed the position for
  73871. */
  73872. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73873. /**
  73874. * Clones the current emitter and returns a copy of it
  73875. * @returns the new emitter
  73876. */
  73877. clone(): CylinderParticleEmitter;
  73878. /**
  73879. * Called by the GPUParticleSystem to setup the update shader
  73880. * @param effect defines the update shader
  73881. */
  73882. applyToShader(effect: Effect): void;
  73883. /**
  73884. * Returns a string to use to update the GPU particles update shader
  73885. * @returns a string containng the defines string
  73886. */
  73887. getEffectDefines(): string;
  73888. /**
  73889. * Returns the string "CylinderParticleEmitter"
  73890. * @returns a string containing the class name
  73891. */
  73892. getClassName(): string;
  73893. /**
  73894. * Serializes the particle system to a JSON object.
  73895. * @returns the JSON object
  73896. */
  73897. serialize(): any;
  73898. /**
  73899. * Parse properties from a JSON object
  73900. * @param serializationObject defines the JSON object
  73901. */
  73902. parse(serializationObject: any): void;
  73903. }
  73904. /**
  73905. * Particle emitter emitting particles from the inside of a cylinder.
  73906. * It emits the particles randomly between two vectors.
  73907. */
  73908. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73909. /**
  73910. * The min limit of the emission direction.
  73911. */
  73912. direction1: Vector3;
  73913. /**
  73914. * The max limit of the emission direction.
  73915. */
  73916. direction2: Vector3;
  73917. /**
  73918. * Creates a new instance CylinderDirectedParticleEmitter
  73919. * @param radius the radius of the emission cylinder (1 by default)
  73920. * @param height the height of the emission cylinder (1 by default)
  73921. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73922. * @param direction1 the min limit of the emission direction (up vector by default)
  73923. * @param direction2 the max limit of the emission direction (up vector by default)
  73924. */
  73925. constructor(radius?: number, height?: number, radiusRange?: number,
  73926. /**
  73927. * The min limit of the emission direction.
  73928. */
  73929. direction1?: Vector3,
  73930. /**
  73931. * The max limit of the emission direction.
  73932. */
  73933. direction2?: Vector3);
  73934. /**
  73935. * Called by the particle System when the direction is computed for the created particle.
  73936. * @param worldMatrix is the world matrix of the particle system
  73937. * @param directionToUpdate is the direction vector to update with the result
  73938. * @param particle is the particle we are computed the direction for
  73939. */
  73940. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73941. /**
  73942. * Clones the current emitter and returns a copy of it
  73943. * @returns the new emitter
  73944. */
  73945. clone(): CylinderDirectedParticleEmitter;
  73946. /**
  73947. * Called by the GPUParticleSystem to setup the update shader
  73948. * @param effect defines the update shader
  73949. */
  73950. applyToShader(effect: Effect): void;
  73951. /**
  73952. * Returns a string to use to update the GPU particles update shader
  73953. * @returns a string containng the defines string
  73954. */
  73955. getEffectDefines(): string;
  73956. /**
  73957. * Returns the string "CylinderDirectedParticleEmitter"
  73958. * @returns a string containing the class name
  73959. */
  73960. getClassName(): string;
  73961. /**
  73962. * Serializes the particle system to a JSON object.
  73963. * @returns the JSON object
  73964. */
  73965. serialize(): any;
  73966. /**
  73967. * Parse properties from a JSON object
  73968. * @param serializationObject defines the JSON object
  73969. */
  73970. parse(serializationObject: any): void;
  73971. }
  73972. }
  73973. declare module BABYLON {
  73974. /**
  73975. * Particle emitter emitting particles from the inside of a hemisphere.
  73976. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73977. */
  73978. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73979. /**
  73980. * The radius of the emission hemisphere.
  73981. */
  73982. radius: number;
  73983. /**
  73984. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73985. */
  73986. radiusRange: number;
  73987. /**
  73988. * How much to randomize the particle direction [0-1].
  73989. */
  73990. directionRandomizer: number;
  73991. /**
  73992. * Creates a new instance HemisphericParticleEmitter
  73993. * @param radius the radius of the emission hemisphere (1 by default)
  73994. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73995. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73996. */
  73997. constructor(
  73998. /**
  73999. * The radius of the emission hemisphere.
  74000. */
  74001. radius?: number,
  74002. /**
  74003. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74004. */
  74005. radiusRange?: number,
  74006. /**
  74007. * How much to randomize the particle direction [0-1].
  74008. */
  74009. directionRandomizer?: number);
  74010. /**
  74011. * Called by the particle System when the direction is computed for the created particle.
  74012. * @param worldMatrix is the world matrix of the particle system
  74013. * @param directionToUpdate is the direction vector to update with the result
  74014. * @param particle is the particle we are computed the direction for
  74015. */
  74016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74017. /**
  74018. * Called by the particle System when the position is computed for the created particle.
  74019. * @param worldMatrix is the world matrix of the particle system
  74020. * @param positionToUpdate is the position vector to update with the result
  74021. * @param particle is the particle we are computed the position for
  74022. */
  74023. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74024. /**
  74025. * Clones the current emitter and returns a copy of it
  74026. * @returns the new emitter
  74027. */
  74028. clone(): HemisphericParticleEmitter;
  74029. /**
  74030. * Called by the GPUParticleSystem to setup the update shader
  74031. * @param effect defines the update shader
  74032. */
  74033. applyToShader(effect: Effect): void;
  74034. /**
  74035. * Returns a string to use to update the GPU particles update shader
  74036. * @returns a string containng the defines string
  74037. */
  74038. getEffectDefines(): string;
  74039. /**
  74040. * Returns the string "HemisphericParticleEmitter"
  74041. * @returns a string containing the class name
  74042. */
  74043. getClassName(): string;
  74044. /**
  74045. * Serializes the particle system to a JSON object.
  74046. * @returns the JSON object
  74047. */
  74048. serialize(): any;
  74049. /**
  74050. * Parse properties from a JSON object
  74051. * @param serializationObject defines the JSON object
  74052. */
  74053. parse(serializationObject: any): void;
  74054. }
  74055. }
  74056. declare module BABYLON {
  74057. /**
  74058. * Particle emitter emitting particles from a point.
  74059. * It emits the particles randomly between 2 given directions.
  74060. */
  74061. export class PointParticleEmitter implements IParticleEmitterType {
  74062. /**
  74063. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74064. */
  74065. direction1: Vector3;
  74066. /**
  74067. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74068. */
  74069. direction2: Vector3;
  74070. /**
  74071. * Creates a new instance PointParticleEmitter
  74072. */
  74073. constructor();
  74074. /**
  74075. * Called by the particle System when the direction is computed for the created particle.
  74076. * @param worldMatrix is the world matrix of the particle system
  74077. * @param directionToUpdate is the direction vector to update with the result
  74078. * @param particle is the particle we are computed the direction for
  74079. */
  74080. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74081. /**
  74082. * Called by the particle System when the position is computed for the created particle.
  74083. * @param worldMatrix is the world matrix of the particle system
  74084. * @param positionToUpdate is the position vector to update with the result
  74085. * @param particle is the particle we are computed the position for
  74086. */
  74087. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74088. /**
  74089. * Clones the current emitter and returns a copy of it
  74090. * @returns the new emitter
  74091. */
  74092. clone(): PointParticleEmitter;
  74093. /**
  74094. * Called by the GPUParticleSystem to setup the update shader
  74095. * @param effect defines the update shader
  74096. */
  74097. applyToShader(effect: Effect): void;
  74098. /**
  74099. * Returns a string to use to update the GPU particles update shader
  74100. * @returns a string containng the defines string
  74101. */
  74102. getEffectDefines(): string;
  74103. /**
  74104. * Returns the string "PointParticleEmitter"
  74105. * @returns a string containing the class name
  74106. */
  74107. getClassName(): string;
  74108. /**
  74109. * Serializes the particle system to a JSON object.
  74110. * @returns the JSON object
  74111. */
  74112. serialize(): any;
  74113. /**
  74114. * Parse properties from a JSON object
  74115. * @param serializationObject defines the JSON object
  74116. */
  74117. parse(serializationObject: any): void;
  74118. }
  74119. }
  74120. declare module BABYLON {
  74121. /**
  74122. * Particle emitter emitting particles from the inside of a sphere.
  74123. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74124. */
  74125. export class SphereParticleEmitter implements IParticleEmitterType {
  74126. /**
  74127. * The radius of the emission sphere.
  74128. */
  74129. radius: number;
  74130. /**
  74131. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74132. */
  74133. radiusRange: number;
  74134. /**
  74135. * How much to randomize the particle direction [0-1].
  74136. */
  74137. directionRandomizer: number;
  74138. /**
  74139. * Creates a new instance SphereParticleEmitter
  74140. * @param radius the radius of the emission sphere (1 by default)
  74141. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74142. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74143. */
  74144. constructor(
  74145. /**
  74146. * The radius of the emission sphere.
  74147. */
  74148. radius?: number,
  74149. /**
  74150. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74151. */
  74152. radiusRange?: number,
  74153. /**
  74154. * How much to randomize the particle direction [0-1].
  74155. */
  74156. directionRandomizer?: number);
  74157. /**
  74158. * Called by the particle System when the direction is computed for the created particle.
  74159. * @param worldMatrix is the world matrix of the particle system
  74160. * @param directionToUpdate is the direction vector to update with the result
  74161. * @param particle is the particle we are computed the direction for
  74162. */
  74163. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74164. /**
  74165. * Called by the particle System when the position is computed for the created particle.
  74166. * @param worldMatrix is the world matrix of the particle system
  74167. * @param positionToUpdate is the position vector to update with the result
  74168. * @param particle is the particle we are computed the position for
  74169. */
  74170. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74171. /**
  74172. * Clones the current emitter and returns a copy of it
  74173. * @returns the new emitter
  74174. */
  74175. clone(): SphereParticleEmitter;
  74176. /**
  74177. * Called by the GPUParticleSystem to setup the update shader
  74178. * @param effect defines the update shader
  74179. */
  74180. applyToShader(effect: Effect): void;
  74181. /**
  74182. * Returns a string to use to update the GPU particles update shader
  74183. * @returns a string containng the defines string
  74184. */
  74185. getEffectDefines(): string;
  74186. /**
  74187. * Returns the string "SphereParticleEmitter"
  74188. * @returns a string containing the class name
  74189. */
  74190. getClassName(): string;
  74191. /**
  74192. * Serializes the particle system to a JSON object.
  74193. * @returns the JSON object
  74194. */
  74195. serialize(): any;
  74196. /**
  74197. * Parse properties from a JSON object
  74198. * @param serializationObject defines the JSON object
  74199. */
  74200. parse(serializationObject: any): void;
  74201. }
  74202. /**
  74203. * Particle emitter emitting particles from the inside of a sphere.
  74204. * It emits the particles randomly between two vectors.
  74205. */
  74206. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74207. /**
  74208. * The min limit of the emission direction.
  74209. */
  74210. direction1: Vector3;
  74211. /**
  74212. * The max limit of the emission direction.
  74213. */
  74214. direction2: Vector3;
  74215. /**
  74216. * Creates a new instance SphereDirectedParticleEmitter
  74217. * @param radius the radius of the emission sphere (1 by default)
  74218. * @param direction1 the min limit of the emission direction (up vector by default)
  74219. * @param direction2 the max limit of the emission direction (up vector by default)
  74220. */
  74221. constructor(radius?: number,
  74222. /**
  74223. * The min limit of the emission direction.
  74224. */
  74225. direction1?: Vector3,
  74226. /**
  74227. * The max limit of the emission direction.
  74228. */
  74229. direction2?: Vector3);
  74230. /**
  74231. * Called by the particle System when the direction is computed for the created particle.
  74232. * @param worldMatrix is the world matrix of the particle system
  74233. * @param directionToUpdate is the direction vector to update with the result
  74234. * @param particle is the particle we are computed the direction for
  74235. */
  74236. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74237. /**
  74238. * Clones the current emitter and returns a copy of it
  74239. * @returns the new emitter
  74240. */
  74241. clone(): SphereDirectedParticleEmitter;
  74242. /**
  74243. * Called by the GPUParticleSystem to setup the update shader
  74244. * @param effect defines the update shader
  74245. */
  74246. applyToShader(effect: Effect): void;
  74247. /**
  74248. * Returns a string to use to update the GPU particles update shader
  74249. * @returns a string containng the defines string
  74250. */
  74251. getEffectDefines(): string;
  74252. /**
  74253. * Returns the string "SphereDirectedParticleEmitter"
  74254. * @returns a string containing the class name
  74255. */
  74256. getClassName(): string;
  74257. /**
  74258. * Serializes the particle system to a JSON object.
  74259. * @returns the JSON object
  74260. */
  74261. serialize(): any;
  74262. /**
  74263. * Parse properties from a JSON object
  74264. * @param serializationObject defines the JSON object
  74265. */
  74266. parse(serializationObject: any): void;
  74267. }
  74268. }
  74269. declare module BABYLON {
  74270. /**
  74271. * Interface representing a particle system in Babylon.js.
  74272. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74273. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74274. */
  74275. export interface IParticleSystem {
  74276. /**
  74277. * List of animations used by the particle system.
  74278. */
  74279. animations: Animation[];
  74280. /**
  74281. * The id of the Particle system.
  74282. */
  74283. id: string;
  74284. /**
  74285. * The name of the Particle system.
  74286. */
  74287. name: string;
  74288. /**
  74289. * The emitter represents the Mesh or position we are attaching the particle system to.
  74290. */
  74291. emitter: Nullable<AbstractMesh | Vector3>;
  74292. /**
  74293. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74294. */
  74295. isBillboardBased: boolean;
  74296. /**
  74297. * The rendering group used by the Particle system to chose when to render.
  74298. */
  74299. renderingGroupId: number;
  74300. /**
  74301. * The layer mask we are rendering the particles through.
  74302. */
  74303. layerMask: number;
  74304. /**
  74305. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74306. */
  74307. updateSpeed: number;
  74308. /**
  74309. * The amount of time the particle system is running (depends of the overall update speed).
  74310. */
  74311. targetStopDuration: number;
  74312. /**
  74313. * The texture used to render each particle. (this can be a spritesheet)
  74314. */
  74315. particleTexture: Nullable<Texture>;
  74316. /**
  74317. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74318. */
  74319. blendMode: number;
  74320. /**
  74321. * Minimum life time of emitting particles.
  74322. */
  74323. minLifeTime: number;
  74324. /**
  74325. * Maximum life time of emitting particles.
  74326. */
  74327. maxLifeTime: number;
  74328. /**
  74329. * Minimum Size of emitting particles.
  74330. */
  74331. minSize: number;
  74332. /**
  74333. * Maximum Size of emitting particles.
  74334. */
  74335. maxSize: number;
  74336. /**
  74337. * Minimum scale of emitting particles on X axis.
  74338. */
  74339. minScaleX: number;
  74340. /**
  74341. * Maximum scale of emitting particles on X axis.
  74342. */
  74343. maxScaleX: number;
  74344. /**
  74345. * Minimum scale of emitting particles on Y axis.
  74346. */
  74347. minScaleY: number;
  74348. /**
  74349. * Maximum scale of emitting particles on Y axis.
  74350. */
  74351. maxScaleY: number;
  74352. /**
  74353. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74354. */
  74355. color1: Color4;
  74356. /**
  74357. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74358. */
  74359. color2: Color4;
  74360. /**
  74361. * Color the particle will have at the end of its lifetime.
  74362. */
  74363. colorDead: Color4;
  74364. /**
  74365. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74366. */
  74367. emitRate: number;
  74368. /**
  74369. * You can use gravity if you want to give an orientation to your particles.
  74370. */
  74371. gravity: Vector3;
  74372. /**
  74373. * Minimum power of emitting particles.
  74374. */
  74375. minEmitPower: number;
  74376. /**
  74377. * Maximum power of emitting particles.
  74378. */
  74379. maxEmitPower: number;
  74380. /**
  74381. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74382. */
  74383. minAngularSpeed: number;
  74384. /**
  74385. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74386. */
  74387. maxAngularSpeed: number;
  74388. /**
  74389. * Gets or sets the minimal initial rotation in radians.
  74390. */
  74391. minInitialRotation: number;
  74392. /**
  74393. * Gets or sets the maximal initial rotation in radians.
  74394. */
  74395. maxInitialRotation: number;
  74396. /**
  74397. * The particle emitter type defines the emitter used by the particle system.
  74398. * It can be for example box, sphere, or cone...
  74399. */
  74400. particleEmitterType: Nullable<IParticleEmitterType>;
  74401. /**
  74402. * Defines the delay in milliseconds before starting the system (0 by default)
  74403. */
  74404. startDelay: number;
  74405. /**
  74406. * 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
  74407. */
  74408. preWarmCycles: number;
  74409. /**
  74410. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74411. */
  74412. preWarmStepOffset: number;
  74413. /**
  74414. * 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)
  74415. */
  74416. spriteCellChangeSpeed: number;
  74417. /**
  74418. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74419. */
  74420. startSpriteCellID: number;
  74421. /**
  74422. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74423. */
  74424. endSpriteCellID: number;
  74425. /**
  74426. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74427. */
  74428. spriteCellWidth: number;
  74429. /**
  74430. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74431. */
  74432. spriteCellHeight: number;
  74433. /**
  74434. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74435. */
  74436. spriteRandomStartCell: boolean;
  74437. /**
  74438. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74439. */
  74440. isAnimationSheetEnabled: boolean;
  74441. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74442. translationPivot: Vector2;
  74443. /**
  74444. * Gets or sets a texture used to add random noise to particle positions
  74445. */
  74446. noiseTexture: Nullable<BaseTexture>;
  74447. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74448. noiseStrength: Vector3;
  74449. /**
  74450. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74451. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74452. */
  74453. billboardMode: number;
  74454. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74455. limitVelocityDamping: number;
  74456. /**
  74457. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74458. */
  74459. beginAnimationOnStart: boolean;
  74460. /**
  74461. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74462. */
  74463. beginAnimationFrom: number;
  74464. /**
  74465. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74466. */
  74467. beginAnimationTo: number;
  74468. /**
  74469. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74470. */
  74471. beginAnimationLoop: boolean;
  74472. /**
  74473. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74474. */
  74475. disposeOnStop: boolean;
  74476. /**
  74477. * Gets the maximum number of particles active at the same time.
  74478. * @returns The max number of active particles.
  74479. */
  74480. getCapacity(): number;
  74481. /**
  74482. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74483. * @returns True if it has been started, otherwise false.
  74484. */
  74485. isStarted(): boolean;
  74486. /**
  74487. * Animates the particle system for this frame.
  74488. */
  74489. animate(): void;
  74490. /**
  74491. * Renders the particle system in its current state.
  74492. * @returns the current number of particles
  74493. */
  74494. render(): number;
  74495. /**
  74496. * Dispose the particle system and frees its associated resources.
  74497. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74498. */
  74499. dispose(disposeTexture?: boolean): void;
  74500. /**
  74501. * Clones the particle system.
  74502. * @param name The name of the cloned object
  74503. * @param newEmitter The new emitter to use
  74504. * @returns the cloned particle system
  74505. */
  74506. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74507. /**
  74508. * Serializes the particle system to a JSON object.
  74509. * @returns the JSON object
  74510. */
  74511. serialize(): any;
  74512. /**
  74513. * Rebuild the particle system
  74514. */
  74515. rebuild(): void;
  74516. /**
  74517. * Starts the particle system and begins to emit
  74518. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74519. */
  74520. start(delay?: number): void;
  74521. /**
  74522. * Stops the particle system.
  74523. */
  74524. stop(): void;
  74525. /**
  74526. * Remove all active particles
  74527. */
  74528. reset(): void;
  74529. /**
  74530. * Is this system ready to be used/rendered
  74531. * @return true if the system is ready
  74532. */
  74533. isReady(): boolean;
  74534. /**
  74535. * Adds a new color gradient
  74536. * @param gradient defines the gradient to use (between 0 and 1)
  74537. * @param color1 defines the color to affect to the specified gradient
  74538. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74539. * @returns the current particle system
  74540. */
  74541. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74542. /**
  74543. * Remove a specific color gradient
  74544. * @param gradient defines the gradient to remove
  74545. * @returns the current particle system
  74546. */
  74547. removeColorGradient(gradient: number): IParticleSystem;
  74548. /**
  74549. * Adds a new size gradient
  74550. * @param gradient defines the gradient to use (between 0 and 1)
  74551. * @param factor defines the size factor to affect to the specified gradient
  74552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74553. * @returns the current particle system
  74554. */
  74555. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74556. /**
  74557. * Remove a specific size gradient
  74558. * @param gradient defines the gradient to remove
  74559. * @returns the current particle system
  74560. */
  74561. removeSizeGradient(gradient: number): IParticleSystem;
  74562. /**
  74563. * Gets the current list of color gradients.
  74564. * You must use addColorGradient and removeColorGradient to udpate this list
  74565. * @returns the list of color gradients
  74566. */
  74567. getColorGradients(): Nullable<Array<ColorGradient>>;
  74568. /**
  74569. * Gets the current list of size gradients.
  74570. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74571. * @returns the list of size gradients
  74572. */
  74573. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74574. /**
  74575. * Gets the current list of angular speed gradients.
  74576. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74577. * @returns the list of angular speed gradients
  74578. */
  74579. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74580. /**
  74581. * Adds a new angular speed gradient
  74582. * @param gradient defines the gradient to use (between 0 and 1)
  74583. * @param factor defines the angular speed to affect to the specified gradient
  74584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74585. * @returns the current particle system
  74586. */
  74587. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74588. /**
  74589. * Remove a specific angular speed gradient
  74590. * @param gradient defines the gradient to remove
  74591. * @returns the current particle system
  74592. */
  74593. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74594. /**
  74595. * Gets the current list of velocity gradients.
  74596. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74597. * @returns the list of velocity gradients
  74598. */
  74599. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74600. /**
  74601. * Adds a new velocity gradient
  74602. * @param gradient defines the gradient to use (between 0 and 1)
  74603. * @param factor defines the velocity to affect to the specified gradient
  74604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74605. * @returns the current particle system
  74606. */
  74607. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74608. /**
  74609. * Remove a specific velocity gradient
  74610. * @param gradient defines the gradient to remove
  74611. * @returns the current particle system
  74612. */
  74613. removeVelocityGradient(gradient: number): IParticleSystem;
  74614. /**
  74615. * Gets the current list of limit velocity gradients.
  74616. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74617. * @returns the list of limit velocity gradients
  74618. */
  74619. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74620. /**
  74621. * Adds a new limit velocity gradient
  74622. * @param gradient defines the gradient to use (between 0 and 1)
  74623. * @param factor defines the limit velocity to affect to the specified gradient
  74624. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74625. * @returns the current particle system
  74626. */
  74627. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74628. /**
  74629. * Remove a specific limit velocity gradient
  74630. * @param gradient defines the gradient to remove
  74631. * @returns the current particle system
  74632. */
  74633. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74634. /**
  74635. * Adds a new drag gradient
  74636. * @param gradient defines the gradient to use (between 0 and 1)
  74637. * @param factor defines the drag to affect to the specified gradient
  74638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74639. * @returns the current particle system
  74640. */
  74641. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74642. /**
  74643. * Remove a specific drag gradient
  74644. * @param gradient defines the gradient to remove
  74645. * @returns the current particle system
  74646. */
  74647. removeDragGradient(gradient: number): IParticleSystem;
  74648. /**
  74649. * Gets the current list of drag gradients.
  74650. * You must use addDragGradient and removeDragGradient to udpate this list
  74651. * @returns the list of drag gradients
  74652. */
  74653. getDragGradients(): Nullable<Array<FactorGradient>>;
  74654. /**
  74655. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74656. * @param gradient defines the gradient to use (between 0 and 1)
  74657. * @param factor defines the emit rate to affect to the specified gradient
  74658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74659. * @returns the current particle system
  74660. */
  74661. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74662. /**
  74663. * Remove a specific emit rate gradient
  74664. * @param gradient defines the gradient to remove
  74665. * @returns the current particle system
  74666. */
  74667. removeEmitRateGradient(gradient: number): IParticleSystem;
  74668. /**
  74669. * Gets the current list of emit rate gradients.
  74670. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74671. * @returns the list of emit rate gradients
  74672. */
  74673. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74674. /**
  74675. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74676. * @param gradient defines the gradient to use (between 0 and 1)
  74677. * @param factor defines the start size to affect to the specified gradient
  74678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74679. * @returns the current particle system
  74680. */
  74681. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74682. /**
  74683. * Remove a specific start size gradient
  74684. * @param gradient defines the gradient to remove
  74685. * @returns the current particle system
  74686. */
  74687. removeStartSizeGradient(gradient: number): IParticleSystem;
  74688. /**
  74689. * Gets the current list of start size gradients.
  74690. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74691. * @returns the list of start size gradients
  74692. */
  74693. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74694. /**
  74695. * Adds a new life time gradient
  74696. * @param gradient defines the gradient to use (between 0 and 1)
  74697. * @param factor defines the life time factor to affect to the specified gradient
  74698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74699. * @returns the current particle system
  74700. */
  74701. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74702. /**
  74703. * Remove a specific life time gradient
  74704. * @param gradient defines the gradient to remove
  74705. * @returns the current particle system
  74706. */
  74707. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74708. /**
  74709. * Gets the current list of life time gradients.
  74710. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74711. * @returns the list of life time gradients
  74712. */
  74713. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74714. /**
  74715. * Gets the current list of color gradients.
  74716. * You must use addColorGradient and removeColorGradient to udpate this list
  74717. * @returns the list of color gradients
  74718. */
  74719. getColorGradients(): Nullable<Array<ColorGradient>>;
  74720. /**
  74721. * Adds a new ramp gradient used to remap particle colors
  74722. * @param gradient defines the gradient to use (between 0 and 1)
  74723. * @param color defines the color to affect to the specified gradient
  74724. * @returns the current particle system
  74725. */
  74726. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74727. /**
  74728. * Gets the current list of ramp gradients.
  74729. * You must use addRampGradient and removeRampGradient to udpate this list
  74730. * @returns the list of ramp gradients
  74731. */
  74732. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74733. /** Gets or sets a boolean indicating that ramp gradients must be used
  74734. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74735. */
  74736. useRampGradients: boolean;
  74737. /**
  74738. * Adds a new color remap gradient
  74739. * @param gradient defines the gradient to use (between 0 and 1)
  74740. * @param min defines the color remap minimal range
  74741. * @param max defines the color remap maximal range
  74742. * @returns the current particle system
  74743. */
  74744. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74745. /**
  74746. * Gets the current list of color remap gradients.
  74747. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74748. * @returns the list of color remap gradients
  74749. */
  74750. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74751. /**
  74752. * Adds a new alpha remap gradient
  74753. * @param gradient defines the gradient to use (between 0 and 1)
  74754. * @param min defines the alpha remap minimal range
  74755. * @param max defines the alpha remap maximal range
  74756. * @returns the current particle system
  74757. */
  74758. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74759. /**
  74760. * Gets the current list of alpha remap gradients.
  74761. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74762. * @returns the list of alpha remap gradients
  74763. */
  74764. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74765. /**
  74766. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74767. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74768. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74769. * @returns the emitter
  74770. */
  74771. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74772. /**
  74773. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74774. * @param radius The radius of the hemisphere to emit from
  74775. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74776. * @returns the emitter
  74777. */
  74778. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74779. /**
  74780. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74781. * @param radius The radius of the sphere to emit from
  74782. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74783. * @returns the emitter
  74784. */
  74785. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74786. /**
  74787. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74788. * @param radius The radius of the sphere to emit from
  74789. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74790. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74791. * @returns the emitter
  74792. */
  74793. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74794. /**
  74795. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74796. * @param radius The radius of the emission cylinder
  74797. * @param height The height of the emission cylinder
  74798. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74799. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74800. * @returns the emitter
  74801. */
  74802. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74803. /**
  74804. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74805. * @param radius The radius of the cylinder to emit from
  74806. * @param height The height of the emission cylinder
  74807. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74808. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74809. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74810. * @returns the emitter
  74811. */
  74812. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74813. /**
  74814. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74815. * @param radius The radius of the cone to emit from
  74816. * @param angle The base angle of the cone
  74817. * @returns the emitter
  74818. */
  74819. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74820. /**
  74821. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74824. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74825. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74826. * @returns the emitter
  74827. */
  74828. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74829. /**
  74830. * Get hosting scene
  74831. * @returns the scene
  74832. */
  74833. getScene(): Scene;
  74834. }
  74835. }
  74836. declare module BABYLON {
  74837. /**
  74838. * Creates an instance based on a source mesh.
  74839. */
  74840. export class InstancedMesh extends AbstractMesh {
  74841. private _sourceMesh;
  74842. private _currentLOD;
  74843. /** @hidden */
  74844. _indexInSourceMeshInstanceArray: number;
  74845. constructor(name: string, source: Mesh);
  74846. /**
  74847. * Returns the string "InstancedMesh".
  74848. */
  74849. getClassName(): string;
  74850. /**
  74851. * If the source mesh receives shadows
  74852. */
  74853. readonly receiveShadows: boolean;
  74854. /**
  74855. * The material of the source mesh
  74856. */
  74857. readonly material: Nullable<Material>;
  74858. /**
  74859. * Visibility of the source mesh
  74860. */
  74861. readonly visibility: number;
  74862. /**
  74863. * Skeleton of the source mesh
  74864. */
  74865. readonly skeleton: Nullable<Skeleton>;
  74866. /**
  74867. * Rendering ground id of the source mesh
  74868. */
  74869. renderingGroupId: number;
  74870. /**
  74871. * Returns the total number of vertices (integer).
  74872. */
  74873. getTotalVertices(): number;
  74874. /**
  74875. * Returns a positive integer : the total number of indices in this mesh geometry.
  74876. * @returns the numner of indices or zero if the mesh has no geometry.
  74877. */
  74878. getTotalIndices(): number;
  74879. /**
  74880. * The source mesh of the instance
  74881. */
  74882. readonly sourceMesh: Mesh;
  74883. /**
  74884. * Is this node ready to be used/rendered
  74885. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74886. * @return {boolean} is it ready
  74887. */
  74888. isReady(completeCheck?: boolean): boolean;
  74889. /**
  74890. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74891. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74892. * @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.
  74893. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74894. */
  74895. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74896. /**
  74897. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74898. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74899. * The `data` are either a numeric array either a Float32Array.
  74900. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74901. * 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).
  74902. * Note that a new underlying VertexBuffer object is created each call.
  74903. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74904. *
  74905. * Possible `kind` values :
  74906. * - VertexBuffer.PositionKind
  74907. * - VertexBuffer.UVKind
  74908. * - VertexBuffer.UV2Kind
  74909. * - VertexBuffer.UV3Kind
  74910. * - VertexBuffer.UV4Kind
  74911. * - VertexBuffer.UV5Kind
  74912. * - VertexBuffer.UV6Kind
  74913. * - VertexBuffer.ColorKind
  74914. * - VertexBuffer.MatricesIndicesKind
  74915. * - VertexBuffer.MatricesIndicesExtraKind
  74916. * - VertexBuffer.MatricesWeightsKind
  74917. * - VertexBuffer.MatricesWeightsExtraKind
  74918. *
  74919. * Returns the Mesh.
  74920. */
  74921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74922. /**
  74923. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74924. * If the mesh has no geometry, it is simply returned as it is.
  74925. * The `data` are either a numeric array either a Float32Array.
  74926. * No new underlying VertexBuffer object is created.
  74927. * 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.
  74928. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74929. *
  74930. * Possible `kind` values :
  74931. * - VertexBuffer.PositionKind
  74932. * - VertexBuffer.UVKind
  74933. * - VertexBuffer.UV2Kind
  74934. * - VertexBuffer.UV3Kind
  74935. * - VertexBuffer.UV4Kind
  74936. * - VertexBuffer.UV5Kind
  74937. * - VertexBuffer.UV6Kind
  74938. * - VertexBuffer.ColorKind
  74939. * - VertexBuffer.MatricesIndicesKind
  74940. * - VertexBuffer.MatricesIndicesExtraKind
  74941. * - VertexBuffer.MatricesWeightsKind
  74942. * - VertexBuffer.MatricesWeightsExtraKind
  74943. *
  74944. * Returns the Mesh.
  74945. */
  74946. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74947. /**
  74948. * Sets the mesh indices.
  74949. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74950. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74951. * This method creates a new index buffer each call.
  74952. * Returns the Mesh.
  74953. */
  74954. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74955. /**
  74956. * Boolean : True if the mesh owns the requested kind of data.
  74957. */
  74958. isVerticesDataPresent(kind: string): boolean;
  74959. /**
  74960. * Returns an array of indices (IndicesArray).
  74961. */
  74962. getIndices(): Nullable<IndicesArray>;
  74963. readonly _positions: Nullable<Vector3[]>;
  74964. /**
  74965. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74966. * This means the mesh underlying bounding box and sphere are recomputed.
  74967. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74968. * @returns the current mesh
  74969. */
  74970. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74971. /** @hidden */
  74972. _preActivate(): InstancedMesh;
  74973. /** @hidden */
  74974. _activate(renderId: number): InstancedMesh;
  74975. /**
  74976. * Returns the current associated LOD AbstractMesh.
  74977. */
  74978. getLOD(camera: Camera): AbstractMesh;
  74979. /** @hidden */
  74980. _syncSubMeshes(): InstancedMesh;
  74981. /** @hidden */
  74982. _generatePointsArray(): boolean;
  74983. /**
  74984. * Creates a new InstancedMesh from the current mesh.
  74985. * - name (string) : the cloned mesh name
  74986. * - newParent (optional Node) : the optional Node to parent the clone to.
  74987. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74988. *
  74989. * Returns the clone.
  74990. */
  74991. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74992. /**
  74993. * Disposes the InstancedMesh.
  74994. * Returns nothing.
  74995. */
  74996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74997. }
  74998. }
  74999. declare module BABYLON {
  75000. /**
  75001. * Defines the options associated with the creation of a shader material.
  75002. */
  75003. export interface IShaderMaterialOptions {
  75004. /**
  75005. * Does the material work in alpha blend mode
  75006. */
  75007. needAlphaBlending: boolean;
  75008. /**
  75009. * Does the material work in alpha test mode
  75010. */
  75011. needAlphaTesting: boolean;
  75012. /**
  75013. * The list of attribute names used in the shader
  75014. */
  75015. attributes: string[];
  75016. /**
  75017. * The list of unifrom names used in the shader
  75018. */
  75019. uniforms: string[];
  75020. /**
  75021. * The list of UBO names used in the shader
  75022. */
  75023. uniformBuffers: string[];
  75024. /**
  75025. * The list of sampler names used in the shader
  75026. */
  75027. samplers: string[];
  75028. /**
  75029. * The list of defines used in the shader
  75030. */
  75031. defines: string[];
  75032. }
  75033. /**
  75034. * 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.
  75035. *
  75036. * This returned material effects how the mesh will look based on the code in the shaders.
  75037. *
  75038. * @see http://doc.babylonjs.com/how_to/shader_material
  75039. */
  75040. export class ShaderMaterial extends Material {
  75041. private _shaderPath;
  75042. private _options;
  75043. private _textures;
  75044. private _textureArrays;
  75045. private _floats;
  75046. private _ints;
  75047. private _floatsArrays;
  75048. private _colors3;
  75049. private _colors3Arrays;
  75050. private _colors4;
  75051. private _vectors2;
  75052. private _vectors3;
  75053. private _vectors4;
  75054. private _matrices;
  75055. private _matrices3x3;
  75056. private _matrices2x2;
  75057. private _vectors2Arrays;
  75058. private _vectors3Arrays;
  75059. private _cachedWorldViewMatrix;
  75060. private _renderId;
  75061. /**
  75062. * Instantiate a new shader material.
  75063. * 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.
  75064. * This returned material effects how the mesh will look based on the code in the shaders.
  75065. * @see http://doc.babylonjs.com/how_to/shader_material
  75066. * @param name Define the name of the material in the scene
  75067. * @param scene Define the scene the material belongs to
  75068. * @param shaderPath Defines the route to the shader code in one of three ways:
  75069. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75070. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75071. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75072. * @param options Define the options used to create the shader
  75073. */
  75074. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75075. /**
  75076. * Gets the options used to compile the shader.
  75077. * They can be modified to trigger a new compilation
  75078. */
  75079. readonly options: IShaderMaterialOptions;
  75080. /**
  75081. * Gets the current class name of the material e.g. "ShaderMaterial"
  75082. * Mainly use in serialization.
  75083. * @returns the class name
  75084. */
  75085. getClassName(): string;
  75086. /**
  75087. * Specifies if the material will require alpha blending
  75088. * @returns a boolean specifying if alpha blending is needed
  75089. */
  75090. needAlphaBlending(): boolean;
  75091. /**
  75092. * Specifies if this material should be rendered in alpha test mode
  75093. * @returns a boolean specifying if an alpha test is needed.
  75094. */
  75095. needAlphaTesting(): boolean;
  75096. private _checkUniform;
  75097. /**
  75098. * Set a texture in the shader.
  75099. * @param name Define the name of the uniform samplers as defined in the shader
  75100. * @param texture Define the texture to bind to this sampler
  75101. * @return the material itself allowing "fluent" like uniform updates
  75102. */
  75103. setTexture(name: string, texture: Texture): ShaderMaterial;
  75104. /**
  75105. * Set a texture array in the shader.
  75106. * @param name Define the name of the uniform sampler array as defined in the shader
  75107. * @param textures Define the list of textures to bind to this sampler
  75108. * @return the material itself allowing "fluent" like uniform updates
  75109. */
  75110. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75111. /**
  75112. * Set a float in the shader.
  75113. * @param name Define the name of the uniform as defined in the shader
  75114. * @param value Define the value to give to the uniform
  75115. * @return the material itself allowing "fluent" like uniform updates
  75116. */
  75117. setFloat(name: string, value: number): ShaderMaterial;
  75118. /**
  75119. * Set a int in the shader.
  75120. * @param name Define the name of the uniform as defined in the shader
  75121. * @param value Define the value to give to the uniform
  75122. * @return the material itself allowing "fluent" like uniform updates
  75123. */
  75124. setInt(name: string, value: number): ShaderMaterial;
  75125. /**
  75126. * Set an array of floats in the shader.
  75127. * @param name Define the name of the uniform as defined in the shader
  75128. * @param value Define the value to give to the uniform
  75129. * @return the material itself allowing "fluent" like uniform updates
  75130. */
  75131. setFloats(name: string, value: number[]): ShaderMaterial;
  75132. /**
  75133. * Set a vec3 in the shader from a Color3.
  75134. * @param name Define the name of the uniform as defined in the shader
  75135. * @param value Define the value to give to the uniform
  75136. * @return the material itself allowing "fluent" like uniform updates
  75137. */
  75138. setColor3(name: string, value: Color3): ShaderMaterial;
  75139. /**
  75140. * Set a vec3 array in the shader from a Color3 array.
  75141. * @param name Define the name of the uniform as defined in the shader
  75142. * @param value Define the value to give to the uniform
  75143. * @return the material itself allowing "fluent" like uniform updates
  75144. */
  75145. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75146. /**
  75147. * Set a vec4 in the shader from a Color4.
  75148. * @param name Define the name of the uniform as defined in the shader
  75149. * @param value Define the value to give to the uniform
  75150. * @return the material itself allowing "fluent" like uniform updates
  75151. */
  75152. setColor4(name: string, value: Color4): ShaderMaterial;
  75153. /**
  75154. * Set a vec2 in the shader from a Vector2.
  75155. * @param name Define the name of the uniform as defined in the shader
  75156. * @param value Define the value to give to the uniform
  75157. * @return the material itself allowing "fluent" like uniform updates
  75158. */
  75159. setVector2(name: string, value: Vector2): ShaderMaterial;
  75160. /**
  75161. * Set a vec3 in the shader from a Vector3.
  75162. * @param name Define the name of the uniform as defined in the shader
  75163. * @param value Define the value to give to the uniform
  75164. * @return the material itself allowing "fluent" like uniform updates
  75165. */
  75166. setVector3(name: string, value: Vector3): ShaderMaterial;
  75167. /**
  75168. * Set a vec4 in the shader from a Vector4.
  75169. * @param name Define the name of the uniform as defined in the shader
  75170. * @param value Define the value to give to the uniform
  75171. * @return the material itself allowing "fluent" like uniform updates
  75172. */
  75173. setVector4(name: string, value: Vector4): ShaderMaterial;
  75174. /**
  75175. * Set a mat4 in the shader from a Matrix.
  75176. * @param name Define the name of the uniform as defined in the shader
  75177. * @param value Define the value to give to the uniform
  75178. * @return the material itself allowing "fluent" like uniform updates
  75179. */
  75180. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75181. /**
  75182. * Set a mat3 in the shader from a Float32Array.
  75183. * @param name Define the name of the uniform as defined in the shader
  75184. * @param value Define the value to give to the uniform
  75185. * @return the material itself allowing "fluent" like uniform updates
  75186. */
  75187. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75188. /**
  75189. * Set a mat2 in the shader from a Float32Array.
  75190. * @param name Define the name of the uniform as defined in the shader
  75191. * @param value Define the value to give to the uniform
  75192. * @return the material itself allowing "fluent" like uniform updates
  75193. */
  75194. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75195. /**
  75196. * Set a vec2 array in the shader from a number array.
  75197. * @param name Define the name of the uniform as defined in the shader
  75198. * @param value Define the value to give to the uniform
  75199. * @return the material itself allowing "fluent" like uniform updates
  75200. */
  75201. setArray2(name: string, value: number[]): ShaderMaterial;
  75202. /**
  75203. * Set a vec3 array in the shader from a number array.
  75204. * @param name Define the name of the uniform as defined in the shader
  75205. * @param value Define the value to give to the uniform
  75206. * @return the material itself allowing "fluent" like uniform updates
  75207. */
  75208. setArray3(name: string, value: number[]): ShaderMaterial;
  75209. private _checkCache;
  75210. /**
  75211. * Checks if the material is ready to render the requested mesh
  75212. * @param mesh Define the mesh to render
  75213. * @param useInstances Define whether or not the material is used with instances
  75214. * @returns true if ready, otherwise false
  75215. */
  75216. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75217. /**
  75218. * Binds the world matrix to the material
  75219. * @param world defines the world transformation matrix
  75220. */
  75221. bindOnlyWorldMatrix(world: Matrix): void;
  75222. /**
  75223. * Binds the material to the mesh
  75224. * @param world defines the world transformation matrix
  75225. * @param mesh defines the mesh to bind the material to
  75226. */
  75227. bind(world: Matrix, mesh?: Mesh): void;
  75228. /**
  75229. * Gets the active textures from the material
  75230. * @returns an array of textures
  75231. */
  75232. getActiveTextures(): BaseTexture[];
  75233. /**
  75234. * Specifies if the material uses a texture
  75235. * @param texture defines the texture to check against the material
  75236. * @returns a boolean specifying if the material uses the texture
  75237. */
  75238. hasTexture(texture: BaseTexture): boolean;
  75239. /**
  75240. * Makes a duplicate of the material, and gives it a new name
  75241. * @param name defines the new name for the duplicated material
  75242. * @returns the cloned material
  75243. */
  75244. clone(name: string): ShaderMaterial;
  75245. /**
  75246. * Disposes the material
  75247. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75248. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75249. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75250. */
  75251. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75252. /**
  75253. * Serializes this material in a JSON representation
  75254. * @returns the serialized material object
  75255. */
  75256. serialize(): any;
  75257. /**
  75258. * Creates a shader material from parsed shader material data
  75259. * @param source defines the JSON represnetation of the material
  75260. * @param scene defines the hosting scene
  75261. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75262. * @returns a new material
  75263. */
  75264. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75265. }
  75266. }
  75267. declare module BABYLON {
  75268. /** @hidden */
  75269. export var colorPixelShader: {
  75270. name: string;
  75271. shader: string;
  75272. };
  75273. }
  75274. declare module BABYLON {
  75275. /** @hidden */
  75276. export var colorVertexShader: {
  75277. name: string;
  75278. shader: string;
  75279. };
  75280. }
  75281. declare module BABYLON {
  75282. /**
  75283. * Line mesh
  75284. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75285. */
  75286. export class LinesMesh extends Mesh {
  75287. /**
  75288. * If vertex color should be applied to the mesh
  75289. */
  75290. useVertexColor?: boolean | undefined;
  75291. /**
  75292. * If vertex alpha should be applied to the mesh
  75293. */
  75294. useVertexAlpha?: boolean | undefined;
  75295. /**
  75296. * Color of the line (Default: White)
  75297. */
  75298. color: Color3;
  75299. /**
  75300. * Alpha of the line (Default: 1)
  75301. */
  75302. alpha: number;
  75303. /**
  75304. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75305. * This margin is expressed in world space coordinates, so its value may vary.
  75306. * Default value is 0.1
  75307. */
  75308. intersectionThreshold: number;
  75309. private _colorShader;
  75310. /**
  75311. * Creates a new LinesMesh
  75312. * @param name defines the name
  75313. * @param scene defines the hosting scene
  75314. * @param parent defines the parent mesh if any
  75315. * @param source defines the optional source LinesMesh used to clone data from
  75316. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75317. * When false, achieved by calling a clone(), also passing False.
  75318. * This will make creation of children, recursive.
  75319. * @param useVertexColor defines if this LinesMesh supports vertex color
  75320. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75321. */
  75322. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75323. /**
  75324. * If vertex color should be applied to the mesh
  75325. */
  75326. useVertexColor?: boolean | undefined,
  75327. /**
  75328. * If vertex alpha should be applied to the mesh
  75329. */
  75330. useVertexAlpha?: boolean | undefined);
  75331. private _addClipPlaneDefine;
  75332. private _removeClipPlaneDefine;
  75333. isReady(): boolean;
  75334. /**
  75335. * Returns the string "LineMesh"
  75336. */
  75337. getClassName(): string;
  75338. /**
  75339. * @hidden
  75340. */
  75341. /**
  75342. * @hidden
  75343. */
  75344. material: Material;
  75345. /**
  75346. * @hidden
  75347. */
  75348. readonly checkCollisions: boolean;
  75349. /** @hidden */
  75350. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75351. /** @hidden */
  75352. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75353. /**
  75354. * Disposes of the line mesh
  75355. * @param doNotRecurse If children should be disposed
  75356. */
  75357. dispose(doNotRecurse?: boolean): void;
  75358. /**
  75359. * Returns a new LineMesh object cloned from the current one.
  75360. */
  75361. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75362. /**
  75363. * Creates a new InstancedLinesMesh object from the mesh model.
  75364. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75365. * @param name defines the name of the new instance
  75366. * @returns a new InstancedLinesMesh
  75367. */
  75368. createInstance(name: string): InstancedLinesMesh;
  75369. }
  75370. /**
  75371. * Creates an instance based on a source LinesMesh
  75372. */
  75373. export class InstancedLinesMesh extends InstancedMesh {
  75374. /**
  75375. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75376. * This margin is expressed in world space coordinates, so its value may vary.
  75377. * Initilized with the intersectionThreshold value of the source LinesMesh
  75378. */
  75379. intersectionThreshold: number;
  75380. constructor(name: string, source: LinesMesh);
  75381. /**
  75382. * Returns the string "InstancedLinesMesh".
  75383. */
  75384. getClassName(): string;
  75385. }
  75386. }
  75387. declare module BABYLON {
  75388. /** @hidden */
  75389. export var linePixelShader: {
  75390. name: string;
  75391. shader: string;
  75392. };
  75393. }
  75394. declare module BABYLON {
  75395. /** @hidden */
  75396. export var lineVertexShader: {
  75397. name: string;
  75398. shader: string;
  75399. };
  75400. }
  75401. declare module BABYLON {
  75402. interface AbstractMesh {
  75403. /**
  75404. * Disables the mesh edge rendering mode
  75405. * @returns the currentAbstractMesh
  75406. */
  75407. disableEdgesRendering(): AbstractMesh;
  75408. /**
  75409. * Enables the edge rendering mode on the mesh.
  75410. * This mode makes the mesh edges visible
  75411. * @param epsilon defines the maximal distance between two angles to detect a face
  75412. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75413. * @returns the currentAbstractMesh
  75414. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75415. */
  75416. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75417. /**
  75418. * Gets the edgesRenderer associated with the mesh
  75419. */
  75420. edgesRenderer: Nullable<EdgesRenderer>;
  75421. }
  75422. interface LinesMesh {
  75423. /**
  75424. * Enables the edge rendering mode on the mesh.
  75425. * This mode makes the mesh edges visible
  75426. * @param epsilon defines the maximal distance between two angles to detect a face
  75427. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75428. * @returns the currentAbstractMesh
  75429. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75430. */
  75431. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75432. }
  75433. interface InstancedLinesMesh {
  75434. /**
  75435. * Enables the edge rendering mode on the mesh.
  75436. * This mode makes the mesh edges visible
  75437. * @param epsilon defines the maximal distance between two angles to detect a face
  75438. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75439. * @returns the current InstancedLinesMesh
  75440. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75441. */
  75442. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75443. }
  75444. /**
  75445. * Defines the minimum contract an Edges renderer should follow.
  75446. */
  75447. export interface IEdgesRenderer extends IDisposable {
  75448. /**
  75449. * Gets or sets a boolean indicating if the edgesRenderer is active
  75450. */
  75451. isEnabled: boolean;
  75452. /**
  75453. * Renders the edges of the attached mesh,
  75454. */
  75455. render(): void;
  75456. /**
  75457. * Checks wether or not the edges renderer is ready to render.
  75458. * @return true if ready, otherwise false.
  75459. */
  75460. isReady(): boolean;
  75461. }
  75462. /**
  75463. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75464. */
  75465. export class EdgesRenderer implements IEdgesRenderer {
  75466. /**
  75467. * Define the size of the edges with an orthographic camera
  75468. */
  75469. edgesWidthScalerForOrthographic: number;
  75470. /**
  75471. * Define the size of the edges with a perspective camera
  75472. */
  75473. edgesWidthScalerForPerspective: number;
  75474. protected _source: AbstractMesh;
  75475. protected _linesPositions: number[];
  75476. protected _linesNormals: number[];
  75477. protected _linesIndices: number[];
  75478. protected _epsilon: number;
  75479. protected _indicesCount: number;
  75480. protected _lineShader: ShaderMaterial;
  75481. protected _ib: WebGLBuffer;
  75482. protected _buffers: {
  75483. [key: string]: Nullable<VertexBuffer>;
  75484. };
  75485. protected _checkVerticesInsteadOfIndices: boolean;
  75486. private _meshRebuildObserver;
  75487. private _meshDisposeObserver;
  75488. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75489. isEnabled: boolean;
  75490. /**
  75491. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75492. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75493. * @param source Mesh used to create edges
  75494. * @param epsilon sum of angles in adjacency to check for edge
  75495. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75496. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75497. */
  75498. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75499. protected _prepareRessources(): void;
  75500. /** @hidden */
  75501. _rebuild(): void;
  75502. /**
  75503. * Releases the required resources for the edges renderer
  75504. */
  75505. dispose(): void;
  75506. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75507. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75508. /**
  75509. * Checks if the pair of p0 and p1 is en edge
  75510. * @param faceIndex
  75511. * @param edge
  75512. * @param faceNormals
  75513. * @param p0
  75514. * @param p1
  75515. * @private
  75516. */
  75517. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75518. /**
  75519. * push line into the position, normal and index buffer
  75520. * @protected
  75521. */
  75522. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75523. /**
  75524. * Generates lines edges from adjacencjes
  75525. * @private
  75526. */
  75527. _generateEdgesLines(): void;
  75528. /**
  75529. * Checks wether or not the edges renderer is ready to render.
  75530. * @return true if ready, otherwise false.
  75531. */
  75532. isReady(): boolean;
  75533. /**
  75534. * Renders the edges of the attached mesh,
  75535. */
  75536. render(): void;
  75537. }
  75538. /**
  75539. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75540. */
  75541. export class LineEdgesRenderer extends EdgesRenderer {
  75542. /**
  75543. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75544. * @param source LineMesh used to generate edges
  75545. * @param epsilon not important (specified angle for edge detection)
  75546. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75547. */
  75548. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75549. /**
  75550. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75551. */
  75552. _generateEdgesLines(): void;
  75553. }
  75554. }
  75555. declare module BABYLON {
  75556. /**
  75557. * This represents the object necessary to create a rendering group.
  75558. * This is exclusively used and created by the rendering manager.
  75559. * To modify the behavior, you use the available helpers in your scene or meshes.
  75560. * @hidden
  75561. */
  75562. export class RenderingGroup {
  75563. index: number;
  75564. private _scene;
  75565. private _opaqueSubMeshes;
  75566. private _transparentSubMeshes;
  75567. private _alphaTestSubMeshes;
  75568. private _depthOnlySubMeshes;
  75569. private _particleSystems;
  75570. private _spriteManagers;
  75571. private _opaqueSortCompareFn;
  75572. private _alphaTestSortCompareFn;
  75573. private _transparentSortCompareFn;
  75574. private _renderOpaque;
  75575. private _renderAlphaTest;
  75576. private _renderTransparent;
  75577. private _edgesRenderers;
  75578. onBeforeTransparentRendering: () => void;
  75579. /**
  75580. * Set the opaque sort comparison function.
  75581. * If null the sub meshes will be render in the order they were created
  75582. */
  75583. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75584. /**
  75585. * Set the alpha test sort comparison function.
  75586. * If null the sub meshes will be render in the order they were created
  75587. */
  75588. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75589. /**
  75590. * Set the transparent sort comparison function.
  75591. * If null the sub meshes will be render in the order they were created
  75592. */
  75593. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75594. /**
  75595. * Creates a new rendering group.
  75596. * @param index The rendering group index
  75597. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75598. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75599. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75600. */
  75601. 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>);
  75602. /**
  75603. * Render all the sub meshes contained in the group.
  75604. * @param customRenderFunction Used to override the default render behaviour of the group.
  75605. * @returns true if rendered some submeshes.
  75606. */
  75607. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75608. /**
  75609. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75610. * @param subMeshes The submeshes to render
  75611. */
  75612. private renderOpaqueSorted;
  75613. /**
  75614. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75615. * @param subMeshes The submeshes to render
  75616. */
  75617. private renderAlphaTestSorted;
  75618. /**
  75619. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75620. * @param subMeshes The submeshes to render
  75621. */
  75622. private renderTransparentSorted;
  75623. /**
  75624. * Renders the submeshes in a specified order.
  75625. * @param subMeshes The submeshes to sort before render
  75626. * @param sortCompareFn The comparison function use to sort
  75627. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75628. * @param transparent Specifies to activate blending if true
  75629. */
  75630. private static renderSorted;
  75631. /**
  75632. * Renders the submeshes in the order they were dispatched (no sort applied).
  75633. * @param subMeshes The submeshes to render
  75634. */
  75635. private static renderUnsorted;
  75636. /**
  75637. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75638. * are rendered back to front if in the same alpha index.
  75639. *
  75640. * @param a The first submesh
  75641. * @param b The second submesh
  75642. * @returns The result of the comparison
  75643. */
  75644. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75645. /**
  75646. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75647. * are rendered back to front.
  75648. *
  75649. * @param a The first submesh
  75650. * @param b The second submesh
  75651. * @returns The result of the comparison
  75652. */
  75653. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75654. /**
  75655. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75656. * are rendered front to back (prevent overdraw).
  75657. *
  75658. * @param a The first submesh
  75659. * @param b The second submesh
  75660. * @returns The result of the comparison
  75661. */
  75662. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75663. /**
  75664. * Resets the different lists of submeshes to prepare a new frame.
  75665. */
  75666. prepare(): void;
  75667. dispose(): void;
  75668. /**
  75669. * Inserts the submesh in its correct queue depending on its material.
  75670. * @param subMesh The submesh to dispatch
  75671. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75672. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75673. */
  75674. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75675. dispatchSprites(spriteManager: ISpriteManager): void;
  75676. dispatchParticles(particleSystem: IParticleSystem): void;
  75677. private _renderParticles;
  75678. private _renderSprites;
  75679. }
  75680. }
  75681. declare module BABYLON {
  75682. /**
  75683. * Interface describing the different options available in the rendering manager
  75684. * regarding Auto Clear between groups.
  75685. */
  75686. export interface IRenderingManagerAutoClearSetup {
  75687. /**
  75688. * Defines whether or not autoclear is enable.
  75689. */
  75690. autoClear: boolean;
  75691. /**
  75692. * Defines whether or not to autoclear the depth buffer.
  75693. */
  75694. depth: boolean;
  75695. /**
  75696. * Defines whether or not to autoclear the stencil buffer.
  75697. */
  75698. stencil: boolean;
  75699. }
  75700. /**
  75701. * This class is used by the onRenderingGroupObservable
  75702. */
  75703. export class RenderingGroupInfo {
  75704. /**
  75705. * The Scene that being rendered
  75706. */
  75707. scene: Scene;
  75708. /**
  75709. * The camera currently used for the rendering pass
  75710. */
  75711. camera: Nullable<Camera>;
  75712. /**
  75713. * The ID of the renderingGroup being processed
  75714. */
  75715. renderingGroupId: number;
  75716. }
  75717. /**
  75718. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75719. * It is enable to manage the different groups as well as the different necessary sort functions.
  75720. * This should not be used directly aside of the few static configurations
  75721. */
  75722. export class RenderingManager {
  75723. /**
  75724. * The max id used for rendering groups (not included)
  75725. */
  75726. static MAX_RENDERINGGROUPS: number;
  75727. /**
  75728. * The min id used for rendering groups (included)
  75729. */
  75730. static MIN_RENDERINGGROUPS: number;
  75731. /**
  75732. * Used to globally prevent autoclearing scenes.
  75733. */
  75734. static AUTOCLEAR: boolean;
  75735. /**
  75736. * @hidden
  75737. */
  75738. _useSceneAutoClearSetup: boolean;
  75739. private _scene;
  75740. private _renderingGroups;
  75741. private _depthStencilBufferAlreadyCleaned;
  75742. private _autoClearDepthStencil;
  75743. private _customOpaqueSortCompareFn;
  75744. private _customAlphaTestSortCompareFn;
  75745. private _customTransparentSortCompareFn;
  75746. private _renderingGroupInfo;
  75747. /**
  75748. * Instantiates a new rendering group for a particular scene
  75749. * @param scene Defines the scene the groups belongs to
  75750. */
  75751. constructor(scene: Scene);
  75752. private _clearDepthStencilBuffer;
  75753. /**
  75754. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75755. * @hidden
  75756. */
  75757. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75758. /**
  75759. * Resets the different information of the group to prepare a new frame
  75760. * @hidden
  75761. */
  75762. reset(): void;
  75763. /**
  75764. * Dispose and release the group and its associated resources.
  75765. * @hidden
  75766. */
  75767. dispose(): void;
  75768. /**
  75769. * Clear the info related to rendering groups preventing retention points during dispose.
  75770. */
  75771. freeRenderingGroups(): void;
  75772. private _prepareRenderingGroup;
  75773. /**
  75774. * Add a sprite manager to the rendering manager in order to render it this frame.
  75775. * @param spriteManager Define the sprite manager to render
  75776. */
  75777. dispatchSprites(spriteManager: ISpriteManager): void;
  75778. /**
  75779. * Add a particle system to the rendering manager in order to render it this frame.
  75780. * @param particleSystem Define the particle system to render
  75781. */
  75782. dispatchParticles(particleSystem: IParticleSystem): void;
  75783. /**
  75784. * Add a submesh to the manager in order to render it this frame
  75785. * @param subMesh The submesh to dispatch
  75786. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75787. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75788. */
  75789. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75790. /**
  75791. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75792. * This allowed control for front to back rendering or reversly depending of the special needs.
  75793. *
  75794. * @param renderingGroupId The rendering group id corresponding to its index
  75795. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75796. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75797. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75798. */
  75799. 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;
  75800. /**
  75801. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75802. *
  75803. * @param renderingGroupId The rendering group id corresponding to its index
  75804. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75805. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75806. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75807. */
  75808. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75809. /**
  75810. * Gets the current auto clear configuration for one rendering group of the rendering
  75811. * manager.
  75812. * @param index the rendering group index to get the information for
  75813. * @returns The auto clear setup for the requested rendering group
  75814. */
  75815. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75816. }
  75817. }
  75818. declare module BABYLON {
  75819. /**
  75820. * This Helps creating a texture that will be created from a camera in your scene.
  75821. * It is basically a dynamic texture that could be used to create special effects for instance.
  75822. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75823. */
  75824. export class RenderTargetTexture extends Texture {
  75825. isCube: boolean;
  75826. /**
  75827. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75828. */
  75829. static readonly REFRESHRATE_RENDER_ONCE: number;
  75830. /**
  75831. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75832. */
  75833. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75834. /**
  75835. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75836. * the central point of your effect and can save a lot of performances.
  75837. */
  75838. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75839. /**
  75840. * Use this predicate to dynamically define the list of mesh you want to render.
  75841. * If set, the renderList property will be overwritten.
  75842. */
  75843. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75844. private _renderList;
  75845. /**
  75846. * Use this list to define the list of mesh you want to render.
  75847. */
  75848. renderList: Nullable<Array<AbstractMesh>>;
  75849. private _hookArray;
  75850. /**
  75851. * Define if particles should be rendered in your texture.
  75852. */
  75853. renderParticles: boolean;
  75854. /**
  75855. * Define if sprites should be rendered in your texture.
  75856. */
  75857. renderSprites: boolean;
  75858. /**
  75859. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75860. */
  75861. coordinatesMode: number;
  75862. /**
  75863. * Define the camera used to render the texture.
  75864. */
  75865. activeCamera: Nullable<Camera>;
  75866. /**
  75867. * Override the render function of the texture with your own one.
  75868. */
  75869. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75870. /**
  75871. * Define if camera post processes should be use while rendering the texture.
  75872. */
  75873. useCameraPostProcesses: boolean;
  75874. /**
  75875. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75876. */
  75877. ignoreCameraViewport: boolean;
  75878. private _postProcessManager;
  75879. private _postProcesses;
  75880. private _resizeObserver;
  75881. /**
  75882. * An event triggered when the texture is unbind.
  75883. */
  75884. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75885. /**
  75886. * An event triggered when the texture is unbind.
  75887. */
  75888. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75889. private _onAfterUnbindObserver;
  75890. /**
  75891. * Set a after unbind callback in the texture.
  75892. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75893. */
  75894. onAfterUnbind: () => void;
  75895. /**
  75896. * An event triggered before rendering the texture
  75897. */
  75898. onBeforeRenderObservable: Observable<number>;
  75899. private _onBeforeRenderObserver;
  75900. /**
  75901. * Set a before render callback in the texture.
  75902. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75903. */
  75904. onBeforeRender: (faceIndex: number) => void;
  75905. /**
  75906. * An event triggered after rendering the texture
  75907. */
  75908. onAfterRenderObservable: Observable<number>;
  75909. private _onAfterRenderObserver;
  75910. /**
  75911. * Set a after render callback in the texture.
  75912. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75913. */
  75914. onAfterRender: (faceIndex: number) => void;
  75915. /**
  75916. * An event triggered after the texture clear
  75917. */
  75918. onClearObservable: Observable<Engine>;
  75919. private _onClearObserver;
  75920. /**
  75921. * Set a clear callback in the texture.
  75922. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75923. */
  75924. onClear: (Engine: Engine) => void;
  75925. /**
  75926. * Define the clear color of the Render Target if it should be different from the scene.
  75927. */
  75928. clearColor: Color4;
  75929. protected _size: number | {
  75930. width: number;
  75931. height: number;
  75932. };
  75933. protected _initialSizeParameter: number | {
  75934. width: number;
  75935. height: number;
  75936. } | {
  75937. ratio: number;
  75938. };
  75939. protected _sizeRatio: Nullable<number>;
  75940. /** @hidden */
  75941. _generateMipMaps: boolean;
  75942. protected _renderingManager: RenderingManager;
  75943. /** @hidden */
  75944. _waitingRenderList: string[];
  75945. protected _doNotChangeAspectRatio: boolean;
  75946. protected _currentRefreshId: number;
  75947. protected _refreshRate: number;
  75948. protected _textureMatrix: Matrix;
  75949. protected _samples: number;
  75950. protected _renderTargetOptions: RenderTargetCreationOptions;
  75951. /**
  75952. * Gets render target creation options that were used.
  75953. */
  75954. readonly renderTargetOptions: RenderTargetCreationOptions;
  75955. protected _engine: Engine;
  75956. protected _onRatioRescale(): void;
  75957. /**
  75958. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75959. * It must define where the camera used to render the texture is set
  75960. */
  75961. boundingBoxPosition: Vector3;
  75962. private _boundingBoxSize;
  75963. /**
  75964. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75965. * When defined, the cubemap will switch to local mode
  75966. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75967. * @example https://www.babylonjs-playground.com/#RNASML
  75968. */
  75969. boundingBoxSize: Vector3;
  75970. /**
  75971. * In case the RTT has been created with a depth texture, get the associated
  75972. * depth texture.
  75973. * Otherwise, return null.
  75974. */
  75975. depthStencilTexture: Nullable<InternalTexture>;
  75976. /**
  75977. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75978. * or used a shadow, depth texture...
  75979. * @param name The friendly name of the texture
  75980. * @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)
  75981. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75982. * @param generateMipMaps True if mip maps need to be generated after render.
  75983. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75984. * @param type The type of the buffer in the RTT (int, half float, float...)
  75985. * @param isCube True if a cube texture needs to be created
  75986. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75987. * @param generateDepthBuffer True to generate a depth buffer
  75988. * @param generateStencilBuffer True to generate a stencil buffer
  75989. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75990. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75991. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75992. */
  75993. constructor(name: string, size: number | {
  75994. width: number;
  75995. height: number;
  75996. } | {
  75997. ratio: number;
  75998. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75999. /**
  76000. * Creates a depth stencil texture.
  76001. * This is only available in WebGL 2 or with the depth texture extension available.
  76002. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  76003. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  76004. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  76005. */
  76006. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  76007. private _processSizeParameter;
  76008. /**
  76009. * Define the number of samples to use in case of MSAA.
  76010. * It defaults to one meaning no MSAA has been enabled.
  76011. */
  76012. samples: number;
  76013. /**
  76014. * Resets the refresh counter of the texture and start bak from scratch.
  76015. * Could be useful to regenerate the texture if it is setup to render only once.
  76016. */
  76017. resetRefreshCounter(): void;
  76018. /**
  76019. * Define the refresh rate of the texture or the rendering frequency.
  76020. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76021. */
  76022. refreshRate: number;
  76023. /**
  76024. * Adds a post process to the render target rendering passes.
  76025. * @param postProcess define the post process to add
  76026. */
  76027. addPostProcess(postProcess: PostProcess): void;
  76028. /**
  76029. * Clear all the post processes attached to the render target
  76030. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  76031. */
  76032. clearPostProcesses(dispose?: boolean): void;
  76033. /**
  76034. * Remove one of the post process from the list of attached post processes to the texture
  76035. * @param postProcess define the post process to remove from the list
  76036. */
  76037. removePostProcess(postProcess: PostProcess): void;
  76038. /** @hidden */
  76039. _shouldRender(): boolean;
  76040. /**
  76041. * Gets the actual render size of the texture.
  76042. * @returns the width of the render size
  76043. */
  76044. getRenderSize(): number;
  76045. /**
  76046. * Gets the actual render width of the texture.
  76047. * @returns the width of the render size
  76048. */
  76049. getRenderWidth(): number;
  76050. /**
  76051. * Gets the actual render height of the texture.
  76052. * @returns the height of the render size
  76053. */
  76054. getRenderHeight(): number;
  76055. /**
  76056. * Get if the texture can be rescaled or not.
  76057. */
  76058. readonly canRescale: boolean;
  76059. /**
  76060. * Resize the texture using a ratio.
  76061. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76062. */
  76063. scale(ratio: number): void;
  76064. /**
  76065. * Get the texture reflection matrix used to rotate/transform the reflection.
  76066. * @returns the reflection matrix
  76067. */
  76068. getReflectionTextureMatrix(): Matrix;
  76069. /**
  76070. * Resize the texture to a new desired size.
  76071. * Be carrefull as it will recreate all the data in the new texture.
  76072. * @param size Define the new size. It can be:
  76073. * - a number for squared texture,
  76074. * - an object containing { width: number, height: number }
  76075. * - or an object containing a ratio { ratio: number }
  76076. */
  76077. resize(size: number | {
  76078. width: number;
  76079. height: number;
  76080. } | {
  76081. ratio: number;
  76082. }): void;
  76083. /**
  76084. * Renders all the objects from the render list into the texture.
  76085. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76086. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76087. */
  76088. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76089. private _bestReflectionRenderTargetDimension;
  76090. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76091. private renderToTarget;
  76092. /**
  76093. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76094. * This allowed control for front to back rendering or reversly depending of the special needs.
  76095. *
  76096. * @param renderingGroupId The rendering group id corresponding to its index
  76097. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76098. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76099. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76100. */
  76101. 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;
  76102. /**
  76103. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76104. *
  76105. * @param renderingGroupId The rendering group id corresponding to its index
  76106. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76107. */
  76108. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76109. /**
  76110. * Clones the texture.
  76111. * @returns the cloned texture
  76112. */
  76113. clone(): RenderTargetTexture;
  76114. /**
  76115. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76116. * @returns The JSON representation of the texture
  76117. */
  76118. serialize(): any;
  76119. /**
  76120. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76121. */
  76122. disposeFramebufferObjects(): void;
  76123. /**
  76124. * Dispose the texture and release its associated resources.
  76125. */
  76126. dispose(): void;
  76127. /** @hidden */
  76128. _rebuild(): void;
  76129. /**
  76130. * Clear the info related to rendering groups preventing retention point in material dispose.
  76131. */
  76132. freeRenderingGroups(): void;
  76133. }
  76134. }
  76135. declare module BABYLON {
  76136. /**
  76137. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76138. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76139. * You can then easily use it as a reflectionTexture on a flat surface.
  76140. * In case the surface is not a plane, please consider relying on reflection probes.
  76141. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76142. */
  76143. export class MirrorTexture extends RenderTargetTexture {
  76144. private scene;
  76145. /**
  76146. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76147. * 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.
  76148. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76149. */
  76150. mirrorPlane: Plane;
  76151. /**
  76152. * Define the blur ratio used to blur the reflection if needed.
  76153. */
  76154. blurRatio: number;
  76155. /**
  76156. * Define the adaptive blur kernel used to blur the reflection if needed.
  76157. * This will autocompute the closest best match for the `blurKernel`
  76158. */
  76159. adaptiveBlurKernel: number;
  76160. /**
  76161. * Define the blur kernel used to blur the reflection if needed.
  76162. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76163. */
  76164. blurKernel: number;
  76165. /**
  76166. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76167. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76168. */
  76169. blurKernelX: number;
  76170. /**
  76171. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76172. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76173. */
  76174. blurKernelY: number;
  76175. private _autoComputeBlurKernel;
  76176. protected _onRatioRescale(): void;
  76177. private _updateGammaSpace;
  76178. private _imageProcessingConfigChangeObserver;
  76179. private _transformMatrix;
  76180. private _mirrorMatrix;
  76181. private _savedViewMatrix;
  76182. private _blurX;
  76183. private _blurY;
  76184. private _adaptiveBlurKernel;
  76185. private _blurKernelX;
  76186. private _blurKernelY;
  76187. private _blurRatio;
  76188. /**
  76189. * Instantiates a Mirror Texture.
  76190. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76191. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76192. * You can then easily use it as a reflectionTexture on a flat surface.
  76193. * In case the surface is not a plane, please consider relying on reflection probes.
  76194. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76195. * @param name
  76196. * @param size
  76197. * @param scene
  76198. * @param generateMipMaps
  76199. * @param type
  76200. * @param samplingMode
  76201. * @param generateDepthBuffer
  76202. */
  76203. constructor(name: string, size: number | {
  76204. width: number;
  76205. height: number;
  76206. } | {
  76207. ratio: number;
  76208. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76209. private _preparePostProcesses;
  76210. /**
  76211. * Clone the mirror texture.
  76212. * @returns the cloned texture
  76213. */
  76214. clone(): MirrorTexture;
  76215. /**
  76216. * Serialize the texture to a JSON representation you could use in Parse later on
  76217. * @returns the serialized JSON representation
  76218. */
  76219. serialize(): any;
  76220. /**
  76221. * Dispose the texture and release its associated resources.
  76222. */
  76223. dispose(): void;
  76224. }
  76225. }
  76226. declare module BABYLON {
  76227. /**
  76228. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76229. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76230. */
  76231. export class Texture extends BaseTexture {
  76232. /** @hidden */
  76233. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76234. /** @hidden */
  76235. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76236. /** @hidden */
  76237. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76238. /** nearest is mag = nearest and min = nearest and mip = linear */
  76239. static readonly NEAREST_SAMPLINGMODE: number;
  76240. /** nearest is mag = nearest and min = nearest and mip = linear */
  76241. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76243. static readonly BILINEAR_SAMPLINGMODE: number;
  76244. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76245. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76246. /** Trilinear is mag = linear and min = linear and mip = linear */
  76247. static readonly TRILINEAR_SAMPLINGMODE: number;
  76248. /** Trilinear is mag = linear and min = linear and mip = linear */
  76249. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76250. /** mag = nearest and min = nearest and mip = nearest */
  76251. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76252. /** mag = nearest and min = linear and mip = nearest */
  76253. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76254. /** mag = nearest and min = linear and mip = linear */
  76255. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76256. /** mag = nearest and min = linear and mip = none */
  76257. static readonly NEAREST_LINEAR: number;
  76258. /** mag = nearest and min = nearest and mip = none */
  76259. static readonly NEAREST_NEAREST: number;
  76260. /** mag = linear and min = nearest and mip = nearest */
  76261. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76262. /** mag = linear and min = nearest and mip = linear */
  76263. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76264. /** mag = linear and min = linear and mip = none */
  76265. static readonly LINEAR_LINEAR: number;
  76266. /** mag = linear and min = nearest and mip = none */
  76267. static readonly LINEAR_NEAREST: number;
  76268. /** Explicit coordinates mode */
  76269. static readonly EXPLICIT_MODE: number;
  76270. /** Spherical coordinates mode */
  76271. static readonly SPHERICAL_MODE: number;
  76272. /** Planar coordinates mode */
  76273. static readonly PLANAR_MODE: number;
  76274. /** Cubic coordinates mode */
  76275. static readonly CUBIC_MODE: number;
  76276. /** Projection coordinates mode */
  76277. static readonly PROJECTION_MODE: number;
  76278. /** Inverse Cubic coordinates mode */
  76279. static readonly SKYBOX_MODE: number;
  76280. /** Inverse Cubic coordinates mode */
  76281. static readonly INVCUBIC_MODE: number;
  76282. /** Equirectangular coordinates mode */
  76283. static readonly EQUIRECTANGULAR_MODE: number;
  76284. /** Equirectangular Fixed coordinates mode */
  76285. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76286. /** Equirectangular Fixed Mirrored coordinates mode */
  76287. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76288. /** Texture is not repeating outside of 0..1 UVs */
  76289. static readonly CLAMP_ADDRESSMODE: number;
  76290. /** Texture is repeating outside of 0..1 UVs */
  76291. static readonly WRAP_ADDRESSMODE: number;
  76292. /** Texture is repeating and mirrored */
  76293. static readonly MIRROR_ADDRESSMODE: number;
  76294. /**
  76295. * 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
  76296. */
  76297. static UseSerializedUrlIfAny: boolean;
  76298. /**
  76299. * Define the url of the texture.
  76300. */
  76301. url: Nullable<string>;
  76302. /**
  76303. * Define an offset on the texture to offset the u coordinates of the UVs
  76304. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76305. */
  76306. uOffset: number;
  76307. /**
  76308. * Define an offset on the texture to offset the v coordinates of the UVs
  76309. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76310. */
  76311. vOffset: number;
  76312. /**
  76313. * Define an offset on the texture to scale the u coordinates of the UVs
  76314. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76315. */
  76316. uScale: number;
  76317. /**
  76318. * Define an offset on the texture to scale the v coordinates of the UVs
  76319. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76320. */
  76321. vScale: number;
  76322. /**
  76323. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76324. * @see http://doc.babylonjs.com/how_to/more_materials
  76325. */
  76326. uAng: number;
  76327. /**
  76328. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76329. * @see http://doc.babylonjs.com/how_to/more_materials
  76330. */
  76331. vAng: number;
  76332. /**
  76333. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76334. * @see http://doc.babylonjs.com/how_to/more_materials
  76335. */
  76336. wAng: number;
  76337. /**
  76338. * Defines the center of rotation (U)
  76339. */
  76340. uRotationCenter: number;
  76341. /**
  76342. * Defines the center of rotation (V)
  76343. */
  76344. vRotationCenter: number;
  76345. /**
  76346. * Defines the center of rotation (W)
  76347. */
  76348. wRotationCenter: number;
  76349. /**
  76350. * Are mip maps generated for this texture or not.
  76351. */
  76352. readonly noMipmap: boolean;
  76353. /**
  76354. * List of inspectable custom properties (used by the Inspector)
  76355. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76356. */
  76357. inspectableCustomProperties: IInspectable[];
  76358. private _noMipmap;
  76359. /** @hidden */
  76360. _invertY: boolean;
  76361. private _rowGenerationMatrix;
  76362. private _cachedTextureMatrix;
  76363. private _projectionModeMatrix;
  76364. private _t0;
  76365. private _t1;
  76366. private _t2;
  76367. private _cachedUOffset;
  76368. private _cachedVOffset;
  76369. private _cachedUScale;
  76370. private _cachedVScale;
  76371. private _cachedUAng;
  76372. private _cachedVAng;
  76373. private _cachedWAng;
  76374. private _cachedProjectionMatrixId;
  76375. private _cachedCoordinatesMode;
  76376. /** @hidden */
  76377. protected _initialSamplingMode: number;
  76378. /** @hidden */
  76379. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76380. private _deleteBuffer;
  76381. protected _format: Nullable<number>;
  76382. private _delayedOnLoad;
  76383. private _delayedOnError;
  76384. /**
  76385. * Observable triggered once the texture has been loaded.
  76386. */
  76387. onLoadObservable: Observable<Texture>;
  76388. protected _isBlocking: boolean;
  76389. /**
  76390. * Is the texture preventing material to render while loading.
  76391. * If false, a default texture will be used instead of the loading one during the preparation step.
  76392. */
  76393. isBlocking: boolean;
  76394. /**
  76395. * Get the current sampling mode associated with the texture.
  76396. */
  76397. readonly samplingMode: number;
  76398. /**
  76399. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76400. */
  76401. readonly invertY: boolean;
  76402. /**
  76403. * Instantiates a new texture.
  76404. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76405. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76406. * @param url define the url of the picture to load as a texture
  76407. * @param scene define the scene the texture will belong to
  76408. * @param noMipmap define if the texture will require mip maps or not
  76409. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76410. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76411. * @param onLoad define a callback triggered when the texture has been loaded
  76412. * @param onError define a callback triggered when an error occurred during the loading session
  76413. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76414. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76415. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76416. */
  76417. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  76418. /**
  76419. * Update the url (and optional buffer) of this texture if url was null during construction.
  76420. * @param url the url of the texture
  76421. * @param buffer the buffer of the texture (defaults to null)
  76422. * @param onLoad callback called when the texture is loaded (defaults to null)
  76423. */
  76424. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76425. /**
  76426. * Finish the loading sequence of a texture flagged as delayed load.
  76427. * @hidden
  76428. */
  76429. delayLoad(): void;
  76430. private _prepareRowForTextureGeneration;
  76431. /**
  76432. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76433. * @returns the transform matrix of the texture.
  76434. */
  76435. getTextureMatrix(): Matrix;
  76436. /**
  76437. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76438. * @returns The reflection texture transform
  76439. */
  76440. getReflectionTextureMatrix(): Matrix;
  76441. /**
  76442. * Clones the texture.
  76443. * @returns the cloned texture
  76444. */
  76445. clone(): Texture;
  76446. /**
  76447. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76448. * @returns The JSON representation of the texture
  76449. */
  76450. serialize(): any;
  76451. /**
  76452. * Get the current class name of the texture useful for serialization or dynamic coding.
  76453. * @returns "Texture"
  76454. */
  76455. getClassName(): string;
  76456. /**
  76457. * Dispose the texture and release its associated resources.
  76458. */
  76459. dispose(): void;
  76460. /**
  76461. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76462. * @param parsedTexture Define the JSON representation of the texture
  76463. * @param scene Define the scene the parsed texture should be instantiated in
  76464. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76465. * @returns The parsed texture if successful
  76466. */
  76467. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76468. /**
  76469. * Creates a texture from its base 64 representation.
  76470. * @param data Define the base64 payload without the data: prefix
  76471. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76472. * @param scene Define the scene the texture should belong to
  76473. * @param noMipmap Forces the texture to not create mip map information if true
  76474. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76475. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76476. * @param onLoad define a callback triggered when the texture has been loaded
  76477. * @param onError define a callback triggered when an error occurred during the loading session
  76478. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76479. * @returns the created texture
  76480. */
  76481. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76482. /**
  76483. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76484. * @param data Define the base64 payload without the data: prefix
  76485. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76486. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76487. * @param scene Define the scene the texture should belong to
  76488. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76489. * @param noMipmap Forces the texture to not create mip map information if true
  76490. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76491. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76492. * @param onLoad define a callback triggered when the texture has been loaded
  76493. * @param onError define a callback triggered when an error occurred during the loading session
  76494. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76495. * @returns the created texture
  76496. */
  76497. 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;
  76498. }
  76499. }
  76500. declare module BABYLON {
  76501. /**
  76502. * Raw texture can help creating a texture directly from an array of data.
  76503. * This can be super useful if you either get the data from an uncompressed source or
  76504. * if you wish to create your texture pixel by pixel.
  76505. */
  76506. export class RawTexture extends Texture {
  76507. /**
  76508. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76509. */
  76510. format: number;
  76511. private _engine;
  76512. /**
  76513. * Instantiates a new RawTexture.
  76514. * Raw texture can help creating a texture directly from an array of data.
  76515. * This can be super useful if you either get the data from an uncompressed source or
  76516. * if you wish to create your texture pixel by pixel.
  76517. * @param data define the array of data to use to create the texture
  76518. * @param width define the width of the texture
  76519. * @param height define the height of the texture
  76520. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76521. * @param scene define the scene the texture belongs to
  76522. * @param generateMipMaps define whether mip maps should be generated or not
  76523. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76524. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76525. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76526. */
  76527. constructor(data: ArrayBufferView, width: number, height: number,
  76528. /**
  76529. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76530. */
  76531. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76532. /**
  76533. * Updates the texture underlying data.
  76534. * @param data Define the new data of the texture
  76535. */
  76536. update(data: ArrayBufferView): void;
  76537. /**
  76538. * Creates a luminance texture from some data.
  76539. * @param data Define the texture data
  76540. * @param width Define the width of the texture
  76541. * @param height Define the height of the texture
  76542. * @param scene Define the scene the texture belongs to
  76543. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76546. * @returns the luminance texture
  76547. */
  76548. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76549. /**
  76550. * Creates a luminance alpha texture from some data.
  76551. * @param data Define the texture data
  76552. * @param width Define the width of the texture
  76553. * @param height Define the height of the texture
  76554. * @param scene Define the scene the texture belongs to
  76555. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76556. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76557. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76558. * @returns the luminance alpha texture
  76559. */
  76560. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76561. /**
  76562. * Creates an alpha texture from some data.
  76563. * @param data Define the texture data
  76564. * @param width Define the width of the texture
  76565. * @param height Define the height of the texture
  76566. * @param scene Define the scene the texture belongs to
  76567. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76568. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76569. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76570. * @returns the alpha texture
  76571. */
  76572. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76573. /**
  76574. * Creates a RGB texture from some data.
  76575. * @param data Define the texture data
  76576. * @param width Define the width of the texture
  76577. * @param height Define the height of the texture
  76578. * @param scene Define the scene the texture belongs to
  76579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76583. * @returns the RGB alpha texture
  76584. */
  76585. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76586. /**
  76587. * Creates a RGBA texture from some data.
  76588. * @param data Define the texture data
  76589. * @param width Define the width of the texture
  76590. * @param height Define the height of the texture
  76591. * @param scene Define the scene the texture belongs to
  76592. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76593. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76594. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76595. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76596. * @returns the RGBA texture
  76597. */
  76598. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76599. /**
  76600. * Creates a R texture from some data.
  76601. * @param data Define the texture data
  76602. * @param width Define the width of the texture
  76603. * @param height Define the height of the texture
  76604. * @param scene Define the scene the texture belongs to
  76605. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76608. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76609. * @returns the R texture
  76610. */
  76611. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76612. }
  76613. }
  76614. declare module BABYLON {
  76615. /**
  76616. * Defines a runtime animation
  76617. */
  76618. export class RuntimeAnimation {
  76619. private _events;
  76620. /**
  76621. * The current frame of the runtime animation
  76622. */
  76623. private _currentFrame;
  76624. /**
  76625. * The animation used by the runtime animation
  76626. */
  76627. private _animation;
  76628. /**
  76629. * The target of the runtime animation
  76630. */
  76631. private _target;
  76632. /**
  76633. * The initiating animatable
  76634. */
  76635. private _host;
  76636. /**
  76637. * The original value of the runtime animation
  76638. */
  76639. private _originalValue;
  76640. /**
  76641. * The original blend value of the runtime animation
  76642. */
  76643. private _originalBlendValue;
  76644. /**
  76645. * The offsets cache of the runtime animation
  76646. */
  76647. private _offsetsCache;
  76648. /**
  76649. * The high limits cache of the runtime animation
  76650. */
  76651. private _highLimitsCache;
  76652. /**
  76653. * Specifies if the runtime animation has been stopped
  76654. */
  76655. private _stopped;
  76656. /**
  76657. * The blending factor of the runtime animation
  76658. */
  76659. private _blendingFactor;
  76660. /**
  76661. * The BabylonJS scene
  76662. */
  76663. private _scene;
  76664. /**
  76665. * The current value of the runtime animation
  76666. */
  76667. private _currentValue;
  76668. /** @hidden */
  76669. _workValue: any;
  76670. /**
  76671. * The active target of the runtime animation
  76672. */
  76673. private _activeTarget;
  76674. /**
  76675. * The target path of the runtime animation
  76676. */
  76677. private _targetPath;
  76678. /**
  76679. * The weight of the runtime animation
  76680. */
  76681. private _weight;
  76682. /**
  76683. * The ratio offset of the runtime animation
  76684. */
  76685. private _ratioOffset;
  76686. /**
  76687. * The previous delay of the runtime animation
  76688. */
  76689. private _previousDelay;
  76690. /**
  76691. * The previous ratio of the runtime animation
  76692. */
  76693. private _previousRatio;
  76694. /**
  76695. * Gets the current frame of the runtime animation
  76696. */
  76697. readonly currentFrame: number;
  76698. /**
  76699. * Gets the weight of the runtime animation
  76700. */
  76701. readonly weight: number;
  76702. /**
  76703. * Gets the current value of the runtime animation
  76704. */
  76705. readonly currentValue: any;
  76706. /**
  76707. * Gets the target path of the runtime animation
  76708. */
  76709. readonly targetPath: string;
  76710. /**
  76711. * Gets the actual target of the runtime animation
  76712. */
  76713. readonly target: any;
  76714. /**
  76715. * Create a new RuntimeAnimation object
  76716. * @param target defines the target of the animation
  76717. * @param animation defines the source animation object
  76718. * @param scene defines the hosting scene
  76719. * @param host defines the initiating Animatable
  76720. */
  76721. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76722. /**
  76723. * Gets the animation from the runtime animation
  76724. */
  76725. readonly animation: Animation;
  76726. /**
  76727. * Resets the runtime animation to the beginning
  76728. * @param restoreOriginal defines whether to restore the target property to the original value
  76729. */
  76730. reset(restoreOriginal?: boolean): void;
  76731. /**
  76732. * Specifies if the runtime animation is stopped
  76733. * @returns Boolean specifying if the runtime animation is stopped
  76734. */
  76735. isStopped(): boolean;
  76736. /**
  76737. * Disposes of the runtime animation
  76738. */
  76739. dispose(): void;
  76740. /**
  76741. * Interpolates the animation from the current frame
  76742. * @param currentFrame The frame to interpolate the animation to
  76743. * @param repeatCount The number of times that the animation should loop
  76744. * @param loopMode The type of looping mode to use
  76745. * @param offsetValue Animation offset value
  76746. * @param highLimitValue The high limit value
  76747. * @returns The interpolated value
  76748. */
  76749. private _interpolate;
  76750. /**
  76751. * Apply the interpolated value to the target
  76752. * @param currentValue defines the value computed by the animation
  76753. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76754. */
  76755. setValue(currentValue: any, weight?: number): void;
  76756. private _setValue;
  76757. /**
  76758. * Gets the loop pmode of the runtime animation
  76759. * @returns Loop Mode
  76760. */
  76761. private _getCorrectLoopMode;
  76762. /**
  76763. * Move the current animation to a given frame
  76764. * @param frame defines the frame to move to
  76765. */
  76766. goToFrame(frame: number): void;
  76767. /**
  76768. * @hidden Internal use only
  76769. */
  76770. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76771. /**
  76772. * Execute the current animation
  76773. * @param delay defines the delay to add to the current frame
  76774. * @param from defines the lower bound of the animation range
  76775. * @param to defines the upper bound of the animation range
  76776. * @param loop defines if the current animation must loop
  76777. * @param speedRatio defines the current speed ratio
  76778. * @param weight defines the weight of the animation (default is -1 so no weight)
  76779. * @param onLoop optional callback called when animation loops
  76780. * @returns a boolean indicating if the animation is running
  76781. */
  76782. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76783. }
  76784. }
  76785. declare module BABYLON {
  76786. /**
  76787. * Class used to store an actual running animation
  76788. */
  76789. export class Animatable {
  76790. /** defines the target object */
  76791. target: any;
  76792. /** defines the starting frame number (default is 0) */
  76793. fromFrame: number;
  76794. /** defines the ending frame number (default is 100) */
  76795. toFrame: number;
  76796. /** defines if the animation must loop (default is false) */
  76797. loopAnimation: boolean;
  76798. /** defines a callback to call when animation ends if it is not looping */
  76799. onAnimationEnd?: (() => void) | null | undefined;
  76800. /** defines a callback to call when animation loops */
  76801. onAnimationLoop?: (() => void) | null | undefined;
  76802. private _localDelayOffset;
  76803. private _pausedDelay;
  76804. private _runtimeAnimations;
  76805. private _paused;
  76806. private _scene;
  76807. private _speedRatio;
  76808. private _weight;
  76809. private _syncRoot;
  76810. /**
  76811. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76812. * This will only apply for non looping animation (default is true)
  76813. */
  76814. disposeOnEnd: boolean;
  76815. /**
  76816. * Gets a boolean indicating if the animation has started
  76817. */
  76818. animationStarted: boolean;
  76819. /**
  76820. * Observer raised when the animation ends
  76821. */
  76822. onAnimationEndObservable: Observable<Animatable>;
  76823. /**
  76824. * Observer raised when the animation loops
  76825. */
  76826. onAnimationLoopObservable: Observable<Animatable>;
  76827. /**
  76828. * Gets the root Animatable used to synchronize and normalize animations
  76829. */
  76830. readonly syncRoot: Animatable;
  76831. /**
  76832. * Gets the current frame of the first RuntimeAnimation
  76833. * Used to synchronize Animatables
  76834. */
  76835. readonly masterFrame: number;
  76836. /**
  76837. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76838. */
  76839. weight: number;
  76840. /**
  76841. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76842. */
  76843. speedRatio: number;
  76844. /**
  76845. * Creates a new Animatable
  76846. * @param scene defines the hosting scene
  76847. * @param target defines the target object
  76848. * @param fromFrame defines the starting frame number (default is 0)
  76849. * @param toFrame defines the ending frame number (default is 100)
  76850. * @param loopAnimation defines if the animation must loop (default is false)
  76851. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76852. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76853. * @param animations defines a group of animation to add to the new Animatable
  76854. * @param onAnimationLoop defines a callback to call when animation loops
  76855. */
  76856. constructor(scene: Scene,
  76857. /** defines the target object */
  76858. target: any,
  76859. /** defines the starting frame number (default is 0) */
  76860. fromFrame?: number,
  76861. /** defines the ending frame number (default is 100) */
  76862. toFrame?: number,
  76863. /** defines if the animation must loop (default is false) */
  76864. loopAnimation?: boolean, speedRatio?: number,
  76865. /** defines a callback to call when animation ends if it is not looping */
  76866. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76867. /** defines a callback to call when animation loops */
  76868. onAnimationLoop?: (() => void) | null | undefined);
  76869. /**
  76870. * Synchronize and normalize current Animatable with a source Animatable
  76871. * This is useful when using animation weights and when animations are not of the same length
  76872. * @param root defines the root Animatable to synchronize with
  76873. * @returns the current Animatable
  76874. */
  76875. syncWith(root: Animatable): Animatable;
  76876. /**
  76877. * Gets the list of runtime animations
  76878. * @returns an array of RuntimeAnimation
  76879. */
  76880. getAnimations(): RuntimeAnimation[];
  76881. /**
  76882. * Adds more animations to the current animatable
  76883. * @param target defines the target of the animations
  76884. * @param animations defines the new animations to add
  76885. */
  76886. appendAnimations(target: any, animations: Animation[]): void;
  76887. /**
  76888. * Gets the source animation for a specific property
  76889. * @param property defines the propertyu to look for
  76890. * @returns null or the source animation for the given property
  76891. */
  76892. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76893. /**
  76894. * Gets the runtime animation for a specific property
  76895. * @param property defines the propertyu to look for
  76896. * @returns null or the runtime animation for the given property
  76897. */
  76898. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76899. /**
  76900. * Resets the animatable to its original state
  76901. */
  76902. reset(): void;
  76903. /**
  76904. * Allows the animatable to blend with current running animations
  76905. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76906. * @param blendingSpeed defines the blending speed to use
  76907. */
  76908. enableBlending(blendingSpeed: number): void;
  76909. /**
  76910. * Disable animation blending
  76911. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76912. */
  76913. disableBlending(): void;
  76914. /**
  76915. * Jump directly to a given frame
  76916. * @param frame defines the frame to jump to
  76917. */
  76918. goToFrame(frame: number): void;
  76919. /**
  76920. * Pause the animation
  76921. */
  76922. pause(): void;
  76923. /**
  76924. * Restart the animation
  76925. */
  76926. restart(): void;
  76927. private _raiseOnAnimationEnd;
  76928. /**
  76929. * Stop and delete the current animation
  76930. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76931. * @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)
  76932. */
  76933. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76934. /**
  76935. * Wait asynchronously for the animation to end
  76936. * @returns a promise which will be fullfilled when the animation ends
  76937. */
  76938. waitAsync(): Promise<Animatable>;
  76939. /** @hidden */
  76940. _animate(delay: number): boolean;
  76941. }
  76942. interface Scene {
  76943. /** @hidden */
  76944. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76945. /** @hidden */
  76946. _processLateAnimationBindingsForMatrices(holder: {
  76947. totalWeight: number;
  76948. animations: RuntimeAnimation[];
  76949. originalValue: Matrix;
  76950. }): any;
  76951. /** @hidden */
  76952. _processLateAnimationBindingsForQuaternions(holder: {
  76953. totalWeight: number;
  76954. animations: RuntimeAnimation[];
  76955. originalValue: Quaternion;
  76956. }, refQuaternion: Quaternion): Quaternion;
  76957. /** @hidden */
  76958. _processLateAnimationBindings(): void;
  76959. /**
  76960. * Will start the animation sequence of a given target
  76961. * @param target defines the target
  76962. * @param from defines from which frame should animation start
  76963. * @param to defines until which frame should animation run.
  76964. * @param weight defines the weight to apply to the animation (1.0 by default)
  76965. * @param loop defines if the animation loops
  76966. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76967. * @param onAnimationEnd defines the function to be executed when the animation ends
  76968. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76969. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76970. * @param onAnimationLoop defines the callback to call when an animation loops
  76971. * @returns the animatable object created for this animation
  76972. */
  76973. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76974. /**
  76975. * Will start the animation sequence of a given target
  76976. * @param target defines the target
  76977. * @param from defines from which frame should animation start
  76978. * @param to defines until which frame should animation run.
  76979. * @param loop defines if the animation loops
  76980. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76981. * @param onAnimationEnd defines the function to be executed when the animation ends
  76982. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76983. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76984. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76985. * @param onAnimationLoop defines the callback to call when an animation loops
  76986. * @returns the animatable object created for this animation
  76987. */
  76988. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76989. /**
  76990. * Will start the animation sequence of a given target and its hierarchy
  76991. * @param target defines the target
  76992. * @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.
  76993. * @param from defines from which frame should animation start
  76994. * @param to defines until which frame should animation run.
  76995. * @param loop defines if the animation loops
  76996. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76997. * @param onAnimationEnd defines the function to be executed when the animation ends
  76998. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76999. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  77000. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  77001. * @param onAnimationLoop defines the callback to call when an animation loops
  77002. * @returns the list of created animatables
  77003. */
  77004. 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[];
  77005. /**
  77006. * Begin a new animation on a given node
  77007. * @param target defines the target where the animation will take place
  77008. * @param animations defines the list of animations to start
  77009. * @param from defines the initial value
  77010. * @param to defines the final value
  77011. * @param loop defines if you want animation to loop (off by default)
  77012. * @param speedRatio defines the speed ratio to apply to all animations
  77013. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77014. * @param onAnimationLoop defines the callback to call when an animation loops
  77015. * @returns the list of created animatables
  77016. */
  77017. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  77018. /**
  77019. * Begin a new animation on a given node and its hierarchy
  77020. * @param target defines the root node where the animation will take place
  77021. * @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.
  77022. * @param animations defines the list of animations to start
  77023. * @param from defines the initial value
  77024. * @param to defines the final value
  77025. * @param loop defines if you want animation to loop (off by default)
  77026. * @param speedRatio defines the speed ratio to apply to all animations
  77027. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  77028. * @param onAnimationLoop defines the callback to call when an animation loops
  77029. * @returns the list of animatables created for all nodes
  77030. */
  77031. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  77032. /**
  77033. * Gets the animatable associated with a specific target
  77034. * @param target defines the target of the animatable
  77035. * @returns the required animatable if found
  77036. */
  77037. getAnimatableByTarget(target: any): Nullable<Animatable>;
  77038. /**
  77039. * Gets all animatables associated with a given target
  77040. * @param target defines the target to look animatables for
  77041. * @returns an array of Animatables
  77042. */
  77043. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77044. /**
  77045. * Will stop the animation of the given target
  77046. * @param target - the target
  77047. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77048. * @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)
  77049. */
  77050. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77051. /**
  77052. * Stops and removes all animations that have been applied to the scene
  77053. */
  77054. stopAllAnimations(): void;
  77055. }
  77056. interface Bone {
  77057. /**
  77058. * Copy an animation range from another bone
  77059. * @param source defines the source bone
  77060. * @param rangeName defines the range name to copy
  77061. * @param frameOffset defines the frame offset
  77062. * @param rescaleAsRequired defines if rescaling must be applied if required
  77063. * @param skelDimensionsRatio defines the scaling ratio
  77064. * @returns true if operation was successful
  77065. */
  77066. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77067. }
  77068. }
  77069. declare module BABYLON {
  77070. /**
  77071. * Class used to handle skinning animations
  77072. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77073. */
  77074. export class Skeleton implements IAnimatable {
  77075. /** defines the skeleton name */
  77076. name: string;
  77077. /** defines the skeleton Id */
  77078. id: string;
  77079. /**
  77080. * Defines the list of child bones
  77081. */
  77082. bones: Bone[];
  77083. /**
  77084. * Defines an estimate of the dimension of the skeleton at rest
  77085. */
  77086. dimensionsAtRest: Vector3;
  77087. /**
  77088. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77089. */
  77090. needInitialSkinMatrix: boolean;
  77091. /**
  77092. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77093. */
  77094. overrideMesh: Nullable<AbstractMesh>;
  77095. /**
  77096. * Gets the list of animations attached to this skeleton
  77097. */
  77098. animations: Array<Animation>;
  77099. private _scene;
  77100. private _isDirty;
  77101. private _transformMatrices;
  77102. private _transformMatrixTexture;
  77103. private _meshesWithPoseMatrix;
  77104. private _animatables;
  77105. private _identity;
  77106. private _synchronizedWithMesh;
  77107. private _ranges;
  77108. private _lastAbsoluteTransformsUpdateId;
  77109. private _canUseTextureForBones;
  77110. private _uniqueId;
  77111. /** @hidden */
  77112. _numBonesWithLinkedTransformNode: number;
  77113. /**
  77114. * Specifies if the skeleton should be serialized
  77115. */
  77116. doNotSerialize: boolean;
  77117. private _useTextureToStoreBoneMatrices;
  77118. /**
  77119. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77120. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77121. */
  77122. useTextureToStoreBoneMatrices: boolean;
  77123. private _animationPropertiesOverride;
  77124. /**
  77125. * Gets or sets the animation properties override
  77126. */
  77127. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77128. /**
  77129. * List of inspectable custom properties (used by the Inspector)
  77130. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77131. */
  77132. inspectableCustomProperties: IInspectable[];
  77133. /**
  77134. * An observable triggered before computing the skeleton's matrices
  77135. */
  77136. onBeforeComputeObservable: Observable<Skeleton>;
  77137. /**
  77138. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77139. */
  77140. readonly isUsingTextureForMatrices: boolean;
  77141. /**
  77142. * Gets the unique ID of this skeleton
  77143. */
  77144. readonly uniqueId: number;
  77145. /**
  77146. * Creates a new skeleton
  77147. * @param name defines the skeleton name
  77148. * @param id defines the skeleton Id
  77149. * @param scene defines the hosting scene
  77150. */
  77151. constructor(
  77152. /** defines the skeleton name */
  77153. name: string,
  77154. /** defines the skeleton Id */
  77155. id: string, scene: Scene);
  77156. /**
  77157. * Gets the current object class name.
  77158. * @return the class name
  77159. */
  77160. getClassName(): string;
  77161. /**
  77162. * Returns an array containing the root bones
  77163. * @returns an array containing the root bones
  77164. */
  77165. getChildren(): Array<Bone>;
  77166. /**
  77167. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77168. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77169. * @returns a Float32Array containing matrices data
  77170. */
  77171. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77172. /**
  77173. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77174. * @returns a raw texture containing the data
  77175. */
  77176. getTransformMatrixTexture(): Nullable<RawTexture>;
  77177. /**
  77178. * Gets the current hosting scene
  77179. * @returns a scene object
  77180. */
  77181. getScene(): Scene;
  77182. /**
  77183. * Gets a string representing the current skeleton data
  77184. * @param fullDetails defines a boolean indicating if we want a verbose version
  77185. * @returns a string representing the current skeleton data
  77186. */
  77187. toString(fullDetails?: boolean): string;
  77188. /**
  77189. * Get bone's index searching by name
  77190. * @param name defines bone's name to search for
  77191. * @return the indice of the bone. Returns -1 if not found
  77192. */
  77193. getBoneIndexByName(name: string): number;
  77194. /**
  77195. * Creater a new animation range
  77196. * @param name defines the name of the range
  77197. * @param from defines the start key
  77198. * @param to defines the end key
  77199. */
  77200. createAnimationRange(name: string, from: number, to: number): void;
  77201. /**
  77202. * Delete a specific animation range
  77203. * @param name defines the name of the range
  77204. * @param deleteFrames defines if frames must be removed as well
  77205. */
  77206. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77207. /**
  77208. * Gets a specific animation range
  77209. * @param name defines the name of the range to look for
  77210. * @returns the requested animation range or null if not found
  77211. */
  77212. getAnimationRange(name: string): Nullable<AnimationRange>;
  77213. /**
  77214. * Gets the list of all animation ranges defined on this skeleton
  77215. * @returns an array
  77216. */
  77217. getAnimationRanges(): Nullable<AnimationRange>[];
  77218. /**
  77219. * Copy animation range from a source skeleton.
  77220. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77221. * @param source defines the source skeleton
  77222. * @param name defines the name of the range to copy
  77223. * @param rescaleAsRequired defines if rescaling must be applied if required
  77224. * @returns true if operation was successful
  77225. */
  77226. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77227. /**
  77228. * Forces the skeleton to go to rest pose
  77229. */
  77230. returnToRest(): void;
  77231. private _getHighestAnimationFrame;
  77232. /**
  77233. * Begin a specific animation range
  77234. * @param name defines the name of the range to start
  77235. * @param loop defines if looping must be turned on (false by default)
  77236. * @param speedRatio defines the speed ratio to apply (1 by default)
  77237. * @param onAnimationEnd defines a callback which will be called when animation will end
  77238. * @returns a new animatable
  77239. */
  77240. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77241. /** @hidden */
  77242. _markAsDirty(): void;
  77243. /** @hidden */
  77244. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77245. /** @hidden */
  77246. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77247. private _computeTransformMatrices;
  77248. /**
  77249. * Build all resources required to render a skeleton
  77250. */
  77251. prepare(): void;
  77252. /**
  77253. * Gets the list of animatables currently running for this skeleton
  77254. * @returns an array of animatables
  77255. */
  77256. getAnimatables(): IAnimatable[];
  77257. /**
  77258. * Clone the current skeleton
  77259. * @param name defines the name of the new skeleton
  77260. * @param id defines the id of the enw skeleton
  77261. * @returns the new skeleton
  77262. */
  77263. clone(name: string, id: string): Skeleton;
  77264. /**
  77265. * Enable animation blending for this skeleton
  77266. * @param blendingSpeed defines the blending speed to apply
  77267. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77268. */
  77269. enableBlending(blendingSpeed?: number): void;
  77270. /**
  77271. * Releases all resources associated with the current skeleton
  77272. */
  77273. dispose(): void;
  77274. /**
  77275. * Serialize the skeleton in a JSON object
  77276. * @returns a JSON object
  77277. */
  77278. serialize(): any;
  77279. /**
  77280. * Creates a new skeleton from serialized data
  77281. * @param parsedSkeleton defines the serialized data
  77282. * @param scene defines the hosting scene
  77283. * @returns a new skeleton
  77284. */
  77285. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77286. /**
  77287. * Compute all node absolute transforms
  77288. * @param forceUpdate defines if computation must be done even if cache is up to date
  77289. */
  77290. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77291. /**
  77292. * Gets the root pose matrix
  77293. * @returns a matrix
  77294. */
  77295. getPoseMatrix(): Nullable<Matrix>;
  77296. /**
  77297. * Sorts bones per internal index
  77298. */
  77299. sortBones(): void;
  77300. private _sortBones;
  77301. }
  77302. }
  77303. declare module BABYLON {
  77304. /**
  77305. * Defines a target to use with MorphTargetManager
  77306. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77307. */
  77308. export class MorphTarget implements IAnimatable {
  77309. /** defines the name of the target */
  77310. name: string;
  77311. /**
  77312. * Gets or sets the list of animations
  77313. */
  77314. animations: Animation[];
  77315. private _scene;
  77316. private _positions;
  77317. private _normals;
  77318. private _tangents;
  77319. private _influence;
  77320. /**
  77321. * Observable raised when the influence changes
  77322. */
  77323. onInfluenceChanged: Observable<boolean>;
  77324. /** @hidden */
  77325. _onDataLayoutChanged: Observable<void>;
  77326. /**
  77327. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77328. */
  77329. influence: number;
  77330. /**
  77331. * Gets or sets the id of the morph Target
  77332. */
  77333. id: string;
  77334. private _animationPropertiesOverride;
  77335. /**
  77336. * Gets or sets the animation properties override
  77337. */
  77338. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77339. /**
  77340. * Creates a new MorphTarget
  77341. * @param name defines the name of the target
  77342. * @param influence defines the influence to use
  77343. * @param scene defines the scene the morphtarget belongs to
  77344. */
  77345. constructor(
  77346. /** defines the name of the target */
  77347. name: string, influence?: number, scene?: Nullable<Scene>);
  77348. /**
  77349. * Gets a boolean defining if the target contains position data
  77350. */
  77351. readonly hasPositions: boolean;
  77352. /**
  77353. * Gets a boolean defining if the target contains normal data
  77354. */
  77355. readonly hasNormals: boolean;
  77356. /**
  77357. * Gets a boolean defining if the target contains tangent data
  77358. */
  77359. readonly hasTangents: boolean;
  77360. /**
  77361. * Affects position data to this target
  77362. * @param data defines the position data to use
  77363. */
  77364. setPositions(data: Nullable<FloatArray>): void;
  77365. /**
  77366. * Gets the position data stored in this target
  77367. * @returns a FloatArray containing the position data (or null if not present)
  77368. */
  77369. getPositions(): Nullable<FloatArray>;
  77370. /**
  77371. * Affects normal data to this target
  77372. * @param data defines the normal data to use
  77373. */
  77374. setNormals(data: Nullable<FloatArray>): void;
  77375. /**
  77376. * Gets the normal data stored in this target
  77377. * @returns a FloatArray containing the normal data (or null if not present)
  77378. */
  77379. getNormals(): Nullable<FloatArray>;
  77380. /**
  77381. * Affects tangent data to this target
  77382. * @param data defines the tangent data to use
  77383. */
  77384. setTangents(data: Nullable<FloatArray>): void;
  77385. /**
  77386. * Gets the tangent data stored in this target
  77387. * @returns a FloatArray containing the tangent data (or null if not present)
  77388. */
  77389. getTangents(): Nullable<FloatArray>;
  77390. /**
  77391. * Serializes the current target into a Serialization object
  77392. * @returns the serialized object
  77393. */
  77394. serialize(): any;
  77395. /**
  77396. * Returns the string "MorphTarget"
  77397. * @returns "MorphTarget"
  77398. */
  77399. getClassName(): string;
  77400. /**
  77401. * Creates a new target from serialized data
  77402. * @param serializationObject defines the serialized data to use
  77403. * @returns a new MorphTarget
  77404. */
  77405. static Parse(serializationObject: any): MorphTarget;
  77406. /**
  77407. * Creates a MorphTarget from mesh data
  77408. * @param mesh defines the source mesh
  77409. * @param name defines the name to use for the new target
  77410. * @param influence defines the influence to attach to the target
  77411. * @returns a new MorphTarget
  77412. */
  77413. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77414. }
  77415. }
  77416. declare module BABYLON {
  77417. /**
  77418. * This class is used to deform meshes using morphing between different targets
  77419. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77420. */
  77421. export class MorphTargetManager {
  77422. private _targets;
  77423. private _targetInfluenceChangedObservers;
  77424. private _targetDataLayoutChangedObservers;
  77425. private _activeTargets;
  77426. private _scene;
  77427. private _influences;
  77428. private _supportsNormals;
  77429. private _supportsTangents;
  77430. private _vertexCount;
  77431. private _uniqueId;
  77432. private _tempInfluences;
  77433. /**
  77434. * Creates a new MorphTargetManager
  77435. * @param scene defines the current scene
  77436. */
  77437. constructor(scene?: Nullable<Scene>);
  77438. /**
  77439. * Gets the unique ID of this manager
  77440. */
  77441. readonly uniqueId: number;
  77442. /**
  77443. * Gets the number of vertices handled by this manager
  77444. */
  77445. readonly vertexCount: number;
  77446. /**
  77447. * Gets a boolean indicating if this manager supports morphing of normals
  77448. */
  77449. readonly supportsNormals: boolean;
  77450. /**
  77451. * Gets a boolean indicating if this manager supports morphing of tangents
  77452. */
  77453. readonly supportsTangents: boolean;
  77454. /**
  77455. * Gets the number of targets stored in this manager
  77456. */
  77457. readonly numTargets: number;
  77458. /**
  77459. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77460. */
  77461. readonly numInfluencers: number;
  77462. /**
  77463. * Gets the list of influences (one per target)
  77464. */
  77465. readonly influences: Float32Array;
  77466. /**
  77467. * Gets the active target at specified index. An active target is a target with an influence > 0
  77468. * @param index defines the index to check
  77469. * @returns the requested target
  77470. */
  77471. getActiveTarget(index: number): MorphTarget;
  77472. /**
  77473. * Gets the target at specified index
  77474. * @param index defines the index to check
  77475. * @returns the requested target
  77476. */
  77477. getTarget(index: number): MorphTarget;
  77478. /**
  77479. * Add a new target to this manager
  77480. * @param target defines the target to add
  77481. */
  77482. addTarget(target: MorphTarget): void;
  77483. /**
  77484. * Removes a target from the manager
  77485. * @param target defines the target to remove
  77486. */
  77487. removeTarget(target: MorphTarget): void;
  77488. /**
  77489. * Serializes the current manager into a Serialization object
  77490. * @returns the serialized object
  77491. */
  77492. serialize(): any;
  77493. private _syncActiveTargets;
  77494. /**
  77495. * Syncrhonize the targets with all the meshes using this morph target manager
  77496. */
  77497. synchronize(): void;
  77498. /**
  77499. * Creates a new MorphTargetManager from serialized data
  77500. * @param serializationObject defines the serialized data
  77501. * @param scene defines the hosting scene
  77502. * @returns the new MorphTargetManager
  77503. */
  77504. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77505. }
  77506. }
  77507. declare module BABYLON {
  77508. /**
  77509. * Mesh representing the gorund
  77510. */
  77511. export class GroundMesh extends Mesh {
  77512. /** If octree should be generated */
  77513. generateOctree: boolean;
  77514. private _heightQuads;
  77515. /** @hidden */
  77516. _subdivisionsX: number;
  77517. /** @hidden */
  77518. _subdivisionsY: number;
  77519. /** @hidden */
  77520. _width: number;
  77521. /** @hidden */
  77522. _height: number;
  77523. /** @hidden */
  77524. _minX: number;
  77525. /** @hidden */
  77526. _maxX: number;
  77527. /** @hidden */
  77528. _minZ: number;
  77529. /** @hidden */
  77530. _maxZ: number;
  77531. constructor(name: string, scene: Scene);
  77532. /**
  77533. * "GroundMesh"
  77534. * @returns "GroundMesh"
  77535. */
  77536. getClassName(): string;
  77537. /**
  77538. * The minimum of x and y subdivisions
  77539. */
  77540. readonly subdivisions: number;
  77541. /**
  77542. * X subdivisions
  77543. */
  77544. readonly subdivisionsX: number;
  77545. /**
  77546. * Y subdivisions
  77547. */
  77548. readonly subdivisionsY: number;
  77549. /**
  77550. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77551. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77552. * @param chunksCount the number of subdivisions for x and y
  77553. * @param octreeBlocksSize (Default: 32)
  77554. */
  77555. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77556. /**
  77557. * Returns a height (y) value in the Worl system :
  77558. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77559. * @param x x coordinate
  77560. * @param z z coordinate
  77561. * @returns the ground y position if (x, z) are outside the ground surface.
  77562. */
  77563. getHeightAtCoordinates(x: number, z: number): number;
  77564. /**
  77565. * Returns a normalized vector (Vector3) orthogonal to the ground
  77566. * at the ground coordinates (x, z) expressed in the World system.
  77567. * @param x x coordinate
  77568. * @param z z coordinate
  77569. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77570. */
  77571. getNormalAtCoordinates(x: number, z: number): Vector3;
  77572. /**
  77573. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77574. * at the ground coordinates (x, z) expressed in the World system.
  77575. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77576. * @param x x coordinate
  77577. * @param z z coordinate
  77578. * @param ref vector to store the result
  77579. * @returns the GroundMesh.
  77580. */
  77581. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77582. /**
  77583. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77584. * if the ground has been updated.
  77585. * This can be used in the render loop.
  77586. * @returns the GroundMesh.
  77587. */
  77588. updateCoordinateHeights(): GroundMesh;
  77589. private _getFacetAt;
  77590. private _initHeightQuads;
  77591. private _computeHeightQuads;
  77592. /**
  77593. * Serializes this ground mesh
  77594. * @param serializationObject object to write serialization to
  77595. */
  77596. serialize(serializationObject: any): void;
  77597. /**
  77598. * Parses a serialized ground mesh
  77599. * @param parsedMesh the serialized mesh
  77600. * @param scene the scene to create the ground mesh in
  77601. * @returns the created ground mesh
  77602. */
  77603. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77604. }
  77605. }
  77606. declare module BABYLON {
  77607. /**
  77608. * Interface for Physics-Joint data
  77609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77610. */
  77611. export interface PhysicsJointData {
  77612. /**
  77613. * The main pivot of the joint
  77614. */
  77615. mainPivot?: Vector3;
  77616. /**
  77617. * The connected pivot of the joint
  77618. */
  77619. connectedPivot?: Vector3;
  77620. /**
  77621. * The main axis of the joint
  77622. */
  77623. mainAxis?: Vector3;
  77624. /**
  77625. * The connected axis of the joint
  77626. */
  77627. connectedAxis?: Vector3;
  77628. /**
  77629. * The collision of the joint
  77630. */
  77631. collision?: boolean;
  77632. /**
  77633. * Native Oimo/Cannon/Energy data
  77634. */
  77635. nativeParams?: any;
  77636. }
  77637. /**
  77638. * This is a holder class for the physics joint created by the physics plugin
  77639. * It holds a set of functions to control the underlying joint
  77640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77641. */
  77642. export class PhysicsJoint {
  77643. /**
  77644. * The type of the physics joint
  77645. */
  77646. type: number;
  77647. /**
  77648. * The data for the physics joint
  77649. */
  77650. jointData: PhysicsJointData;
  77651. private _physicsJoint;
  77652. protected _physicsPlugin: IPhysicsEnginePlugin;
  77653. /**
  77654. * Initializes the physics joint
  77655. * @param type The type of the physics joint
  77656. * @param jointData The data for the physics joint
  77657. */
  77658. constructor(
  77659. /**
  77660. * The type of the physics joint
  77661. */
  77662. type: number,
  77663. /**
  77664. * The data for the physics joint
  77665. */
  77666. jointData: PhysicsJointData);
  77667. /**
  77668. * Gets the physics joint
  77669. */
  77670. /**
  77671. * Sets the physics joint
  77672. */
  77673. physicsJoint: any;
  77674. /**
  77675. * Sets the physics plugin
  77676. */
  77677. physicsPlugin: IPhysicsEnginePlugin;
  77678. /**
  77679. * Execute a function that is physics-plugin specific.
  77680. * @param {Function} func the function that will be executed.
  77681. * It accepts two parameters: the physics world and the physics joint
  77682. */
  77683. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  77684. /**
  77685. * Distance-Joint type
  77686. */
  77687. static DistanceJoint: number;
  77688. /**
  77689. * Hinge-Joint type
  77690. */
  77691. static HingeJoint: number;
  77692. /**
  77693. * Ball-and-Socket joint type
  77694. */
  77695. static BallAndSocketJoint: number;
  77696. /**
  77697. * Wheel-Joint type
  77698. */
  77699. static WheelJoint: number;
  77700. /**
  77701. * Slider-Joint type
  77702. */
  77703. static SliderJoint: number;
  77704. /**
  77705. * Prismatic-Joint type
  77706. */
  77707. static PrismaticJoint: number;
  77708. /**
  77709. * Universal-Joint type
  77710. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77711. */
  77712. static UniversalJoint: number;
  77713. /**
  77714. * Hinge-Joint 2 type
  77715. */
  77716. static Hinge2Joint: number;
  77717. /**
  77718. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77719. */
  77720. static PointToPointJoint: number;
  77721. /**
  77722. * Spring-Joint type
  77723. */
  77724. static SpringJoint: number;
  77725. /**
  77726. * Lock-Joint type
  77727. */
  77728. static LockJoint: number;
  77729. }
  77730. /**
  77731. * A class representing a physics distance joint
  77732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77733. */
  77734. export class DistanceJoint extends PhysicsJoint {
  77735. /**
  77736. *
  77737. * @param jointData The data for the Distance-Joint
  77738. */
  77739. constructor(jointData: DistanceJointData);
  77740. /**
  77741. * Update the predefined distance.
  77742. * @param maxDistance The maximum preferred distance
  77743. * @param minDistance The minimum preferred distance
  77744. */
  77745. updateDistance(maxDistance: number, minDistance?: number): void;
  77746. }
  77747. /**
  77748. * Represents a Motor-Enabled Joint
  77749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77750. */
  77751. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77752. /**
  77753. * Initializes the Motor-Enabled Joint
  77754. * @param type The type of the joint
  77755. * @param jointData The physica joint data for the joint
  77756. */
  77757. constructor(type: number, jointData: PhysicsJointData);
  77758. /**
  77759. * Set the motor values.
  77760. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77761. * @param force the force to apply
  77762. * @param maxForce max force for this motor.
  77763. */
  77764. setMotor(force?: number, maxForce?: number): void;
  77765. /**
  77766. * Set the motor's limits.
  77767. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77768. * @param upperLimit The upper limit of the motor
  77769. * @param lowerLimit The lower limit of the motor
  77770. */
  77771. setLimit(upperLimit: number, lowerLimit?: number): void;
  77772. }
  77773. /**
  77774. * This class represents a single physics Hinge-Joint
  77775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77776. */
  77777. export class HingeJoint extends MotorEnabledJoint {
  77778. /**
  77779. * Initializes the Hinge-Joint
  77780. * @param jointData The joint data for the Hinge-Joint
  77781. */
  77782. constructor(jointData: PhysicsJointData);
  77783. /**
  77784. * Set the motor values.
  77785. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77786. * @param {number} force the force to apply
  77787. * @param {number} maxForce max force for this motor.
  77788. */
  77789. setMotor(force?: number, maxForce?: number): void;
  77790. /**
  77791. * Set the motor's limits.
  77792. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77793. * @param upperLimit The upper limit of the motor
  77794. * @param lowerLimit The lower limit of the motor
  77795. */
  77796. setLimit(upperLimit: number, lowerLimit?: number): void;
  77797. }
  77798. /**
  77799. * This class represents a dual hinge physics joint (same as wheel joint)
  77800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77801. */
  77802. export class Hinge2Joint extends MotorEnabledJoint {
  77803. /**
  77804. * Initializes the Hinge2-Joint
  77805. * @param jointData The joint data for the Hinge2-Joint
  77806. */
  77807. constructor(jointData: PhysicsJointData);
  77808. /**
  77809. * Set the motor values.
  77810. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77811. * @param {number} targetSpeed the speed the motor is to reach
  77812. * @param {number} maxForce max force for this motor.
  77813. * @param {motorIndex} the motor's index, 0 or 1.
  77814. */
  77815. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77816. /**
  77817. * Set the motor limits.
  77818. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77819. * @param {number} upperLimit the upper limit
  77820. * @param {number} lowerLimit lower limit
  77821. * @param {motorIndex} the motor's index, 0 or 1.
  77822. */
  77823. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77824. }
  77825. /**
  77826. * Interface for a motor enabled joint
  77827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77828. */
  77829. export interface IMotorEnabledJoint {
  77830. /**
  77831. * Physics joint
  77832. */
  77833. physicsJoint: any;
  77834. /**
  77835. * Sets the motor of the motor-enabled joint
  77836. * @param force The force of the motor
  77837. * @param maxForce The maximum force of the motor
  77838. * @param motorIndex The index of the motor
  77839. */
  77840. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77841. /**
  77842. * Sets the limit of the motor
  77843. * @param upperLimit The upper limit of the motor
  77844. * @param lowerLimit The lower limit of the motor
  77845. * @param motorIndex The index of the motor
  77846. */
  77847. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77848. }
  77849. /**
  77850. * Joint data for a Distance-Joint
  77851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77852. */
  77853. export interface DistanceJointData extends PhysicsJointData {
  77854. /**
  77855. * Max distance the 2 joint objects can be apart
  77856. */
  77857. maxDistance: number;
  77858. }
  77859. /**
  77860. * Joint data from a spring joint
  77861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77862. */
  77863. export interface SpringJointData extends PhysicsJointData {
  77864. /**
  77865. * Length of the spring
  77866. */
  77867. length: number;
  77868. /**
  77869. * Stiffness of the spring
  77870. */
  77871. stiffness: number;
  77872. /**
  77873. * Damping of the spring
  77874. */
  77875. damping: number;
  77876. /** this callback will be called when applying the force to the impostors. */
  77877. forceApplicationCallback: () => void;
  77878. }
  77879. }
  77880. declare module BABYLON {
  77881. /**
  77882. * Holds the data for the raycast result
  77883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77884. */
  77885. export class PhysicsRaycastResult {
  77886. private _hasHit;
  77887. private _hitDistance;
  77888. private _hitNormalWorld;
  77889. private _hitPointWorld;
  77890. private _rayFromWorld;
  77891. private _rayToWorld;
  77892. /**
  77893. * Gets if there was a hit
  77894. */
  77895. readonly hasHit: boolean;
  77896. /**
  77897. * Gets the distance from the hit
  77898. */
  77899. readonly hitDistance: number;
  77900. /**
  77901. * Gets the hit normal/direction in the world
  77902. */
  77903. readonly hitNormalWorld: Vector3;
  77904. /**
  77905. * Gets the hit point in the world
  77906. */
  77907. readonly hitPointWorld: Vector3;
  77908. /**
  77909. * Gets the ray "start point" of the ray in the world
  77910. */
  77911. readonly rayFromWorld: Vector3;
  77912. /**
  77913. * Gets the ray "end point" of the ray in the world
  77914. */
  77915. readonly rayToWorld: Vector3;
  77916. /**
  77917. * Sets the hit data (normal & point in world space)
  77918. * @param hitNormalWorld defines the normal in world space
  77919. * @param hitPointWorld defines the point in world space
  77920. */
  77921. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  77922. /**
  77923. * Sets the distance from the start point to the hit point
  77924. * @param distance
  77925. */
  77926. setHitDistance(distance: number): void;
  77927. /**
  77928. * Calculates the distance manually
  77929. */
  77930. calculateHitDistance(): void;
  77931. /**
  77932. * Resets all the values to default
  77933. * @param from The from point on world space
  77934. * @param to The to point on world space
  77935. */
  77936. reset(from?: Vector3, to?: Vector3): void;
  77937. }
  77938. /**
  77939. * Interface for the size containing width and height
  77940. */
  77941. interface IXYZ {
  77942. /**
  77943. * X
  77944. */
  77945. x: number;
  77946. /**
  77947. * Y
  77948. */
  77949. y: number;
  77950. /**
  77951. * Z
  77952. */
  77953. z: number;
  77954. }
  77955. }
  77956. declare module BABYLON {
  77957. /**
  77958. * Interface used to describe a physics joint
  77959. */
  77960. export interface PhysicsImpostorJoint {
  77961. /** Defines the main impostor to which the joint is linked */
  77962. mainImpostor: PhysicsImpostor;
  77963. /** Defines the impostor that is connected to the main impostor using this joint */
  77964. connectedImpostor: PhysicsImpostor;
  77965. /** Defines the joint itself */
  77966. joint: PhysicsJoint;
  77967. }
  77968. /** @hidden */
  77969. export interface IPhysicsEnginePlugin {
  77970. world: any;
  77971. name: string;
  77972. setGravity(gravity: Vector3): void;
  77973. setTimeStep(timeStep: number): void;
  77974. getTimeStep(): number;
  77975. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77976. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77977. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77978. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77979. removePhysicsBody(impostor: PhysicsImpostor): void;
  77980. generateJoint(joint: PhysicsImpostorJoint): void;
  77981. removeJoint(joint: PhysicsImpostorJoint): void;
  77982. isSupported(): boolean;
  77983. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77984. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77985. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77986. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77987. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77988. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77989. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77990. getBodyMass(impostor: PhysicsImpostor): number;
  77991. getBodyFriction(impostor: PhysicsImpostor): number;
  77992. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77993. getBodyRestitution(impostor: PhysicsImpostor): number;
  77994. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77995. getBodyPressure?(impostor: PhysicsImpostor): number;
  77996. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  77997. getBodyStiffness?(impostor: PhysicsImpostor): number;
  77998. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  77999. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  78000. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  78001. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  78002. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  78003. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78004. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  78005. sleepBody(impostor: PhysicsImpostor): void;
  78006. wakeUpBody(impostor: PhysicsImpostor): void;
  78007. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78008. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  78009. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  78010. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78011. getRadius(impostor: PhysicsImpostor): number;
  78012. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  78013. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  78014. dispose(): void;
  78015. }
  78016. /**
  78017. * Interface used to define a physics engine
  78018. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  78019. */
  78020. export interface IPhysicsEngine {
  78021. /**
  78022. * Gets the gravity vector used by the simulation
  78023. */
  78024. gravity: Vector3;
  78025. /**
  78026. * Sets the gravity vector used by the simulation
  78027. * @param gravity defines the gravity vector to use
  78028. */
  78029. setGravity(gravity: Vector3): void;
  78030. /**
  78031. * Set the time step of the physics engine.
  78032. * Default is 1/60.
  78033. * To slow it down, enter 1/600 for example.
  78034. * To speed it up, 1/30
  78035. * @param newTimeStep the new timestep to apply to this world.
  78036. */
  78037. setTimeStep(newTimeStep: number): void;
  78038. /**
  78039. * Get the time step of the physics engine.
  78040. * @returns the current time step
  78041. */
  78042. getTimeStep(): number;
  78043. /**
  78044. * Release all resources
  78045. */
  78046. dispose(): void;
  78047. /**
  78048. * Gets the name of the current physics plugin
  78049. * @returns the name of the plugin
  78050. */
  78051. getPhysicsPluginName(): string;
  78052. /**
  78053. * Adding a new impostor for the impostor tracking.
  78054. * This will be done by the impostor itself.
  78055. * @param impostor the impostor to add
  78056. */
  78057. addImpostor(impostor: PhysicsImpostor): void;
  78058. /**
  78059. * Remove an impostor from the engine.
  78060. * This impostor and its mesh will not longer be updated by the physics engine.
  78061. * @param impostor the impostor to remove
  78062. */
  78063. removeImpostor(impostor: PhysicsImpostor): void;
  78064. /**
  78065. * Add a joint to the physics engine
  78066. * @param mainImpostor defines the main impostor to which the joint is added.
  78067. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78068. * @param joint defines the joint that will connect both impostors.
  78069. */
  78070. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78071. /**
  78072. * Removes a joint from the simulation
  78073. * @param mainImpostor defines the impostor used with the joint
  78074. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78075. * @param joint defines the joint to remove
  78076. */
  78077. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78078. /**
  78079. * Gets the current plugin used to run the simulation
  78080. * @returns current plugin
  78081. */
  78082. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78083. /**
  78084. * Gets the list of physic impostors
  78085. * @returns an array of PhysicsImpostor
  78086. */
  78087. getImpostors(): Array<PhysicsImpostor>;
  78088. /**
  78089. * Gets the impostor for a physics enabled object
  78090. * @param object defines the object impersonated by the impostor
  78091. * @returns the PhysicsImpostor or null if not found
  78092. */
  78093. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78094. /**
  78095. * Gets the impostor for a physics body object
  78096. * @param body defines physics body used by the impostor
  78097. * @returns the PhysicsImpostor or null if not found
  78098. */
  78099. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78100. /**
  78101. * Does a raycast in the physics world
  78102. * @param from when should the ray start?
  78103. * @param to when should the ray end?
  78104. * @returns PhysicsRaycastResult
  78105. */
  78106. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78107. /**
  78108. * Called by the scene. No need to call it.
  78109. * @param delta defines the timespam between frames
  78110. */
  78111. _step(delta: number): void;
  78112. }
  78113. }
  78114. declare module BABYLON {
  78115. /**
  78116. * The interface for the physics imposter parameters
  78117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78118. */
  78119. export interface PhysicsImpostorParameters {
  78120. /**
  78121. * The mass of the physics imposter
  78122. */
  78123. mass: number;
  78124. /**
  78125. * The friction of the physics imposter
  78126. */
  78127. friction?: number;
  78128. /**
  78129. * The coefficient of restitution of the physics imposter
  78130. */
  78131. restitution?: number;
  78132. /**
  78133. * The native options of the physics imposter
  78134. */
  78135. nativeOptions?: any;
  78136. /**
  78137. * Specifies if the parent should be ignored
  78138. */
  78139. ignoreParent?: boolean;
  78140. /**
  78141. * Specifies if bi-directional transformations should be disabled
  78142. */
  78143. disableBidirectionalTransformation?: boolean;
  78144. /**
  78145. * The pressure inside the physics imposter, soft object only
  78146. */
  78147. pressure?: number;
  78148. /**
  78149. * The stiffness the physics imposter, soft object only
  78150. */
  78151. stiffness?: number;
  78152. /**
  78153. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78154. */
  78155. velocityIterations?: number;
  78156. /**
  78157. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78158. */
  78159. positionIterations?: number;
  78160. /**
  78161. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78162. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78163. * Add to fix multiple points
  78164. */
  78165. fixedPoints?: number;
  78166. /**
  78167. * The collision margin around a soft object
  78168. */
  78169. margin?: number;
  78170. /**
  78171. * The collision margin around a soft object
  78172. */
  78173. damping?: number;
  78174. /**
  78175. * The path for a rope based on an extrusion
  78176. */
  78177. path?: any;
  78178. /**
  78179. * The shape of an extrusion used for a rope based on an extrusion
  78180. */
  78181. shape?: any;
  78182. }
  78183. /**
  78184. * Interface for a physics-enabled object
  78185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78186. */
  78187. export interface IPhysicsEnabledObject {
  78188. /**
  78189. * The position of the physics-enabled object
  78190. */
  78191. position: Vector3;
  78192. /**
  78193. * The rotation of the physics-enabled object
  78194. */
  78195. rotationQuaternion: Nullable<Quaternion>;
  78196. /**
  78197. * The scale of the physics-enabled object
  78198. */
  78199. scaling: Vector3;
  78200. /**
  78201. * The rotation of the physics-enabled object
  78202. */
  78203. rotation?: Vector3;
  78204. /**
  78205. * The parent of the physics-enabled object
  78206. */
  78207. parent?: any;
  78208. /**
  78209. * The bounding info of the physics-enabled object
  78210. * @returns The bounding info of the physics-enabled object
  78211. */
  78212. getBoundingInfo(): BoundingInfo;
  78213. /**
  78214. * Computes the world matrix
  78215. * @param force Specifies if the world matrix should be computed by force
  78216. * @returns A world matrix
  78217. */
  78218. computeWorldMatrix(force: boolean): Matrix;
  78219. /**
  78220. * Gets the world matrix
  78221. * @returns A world matrix
  78222. */
  78223. getWorldMatrix?(): Matrix;
  78224. /**
  78225. * Gets the child meshes
  78226. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78227. * @returns An array of abstract meshes
  78228. */
  78229. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78230. /**
  78231. * Gets the vertex data
  78232. * @param kind The type of vertex data
  78233. * @returns A nullable array of numbers, or a float32 array
  78234. */
  78235. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78236. /**
  78237. * Gets the indices from the mesh
  78238. * @returns A nullable array of index arrays
  78239. */
  78240. getIndices?(): Nullable<IndicesArray>;
  78241. /**
  78242. * Gets the scene from the mesh
  78243. * @returns the indices array or null
  78244. */
  78245. getScene?(): Scene;
  78246. /**
  78247. * Gets the absolute position from the mesh
  78248. * @returns the absolute position
  78249. */
  78250. getAbsolutePosition(): Vector3;
  78251. /**
  78252. * Gets the absolute pivot point from the mesh
  78253. * @returns the absolute pivot point
  78254. */
  78255. getAbsolutePivotPoint(): Vector3;
  78256. /**
  78257. * Rotates the mesh
  78258. * @param axis The axis of rotation
  78259. * @param amount The amount of rotation
  78260. * @param space The space of the rotation
  78261. * @returns The rotation transform node
  78262. */
  78263. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78264. /**
  78265. * Translates the mesh
  78266. * @param axis The axis of translation
  78267. * @param distance The distance of translation
  78268. * @param space The space of the translation
  78269. * @returns The transform node
  78270. */
  78271. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78272. /**
  78273. * Sets the absolute position of the mesh
  78274. * @param absolutePosition The absolute position of the mesh
  78275. * @returns The transform node
  78276. */
  78277. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78278. /**
  78279. * Gets the class name of the mesh
  78280. * @returns The class name
  78281. */
  78282. getClassName(): string;
  78283. }
  78284. /**
  78285. * Represents a physics imposter
  78286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78287. */
  78288. export class PhysicsImpostor {
  78289. /**
  78290. * The physics-enabled object used as the physics imposter
  78291. */
  78292. object: IPhysicsEnabledObject;
  78293. /**
  78294. * The type of the physics imposter
  78295. */
  78296. type: number;
  78297. private _options;
  78298. private _scene?;
  78299. /**
  78300. * The default object size of the imposter
  78301. */
  78302. static DEFAULT_OBJECT_SIZE: Vector3;
  78303. /**
  78304. * The identity quaternion of the imposter
  78305. */
  78306. static IDENTITY_QUATERNION: Quaternion;
  78307. /** @hidden */
  78308. _pluginData: any;
  78309. private _physicsEngine;
  78310. private _physicsBody;
  78311. private _bodyUpdateRequired;
  78312. private _onBeforePhysicsStepCallbacks;
  78313. private _onAfterPhysicsStepCallbacks;
  78314. /** @hidden */
  78315. _onPhysicsCollideCallbacks: Array<{
  78316. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78317. otherImpostors: Array<PhysicsImpostor>;
  78318. }>;
  78319. private _deltaPosition;
  78320. private _deltaRotation;
  78321. private _deltaRotationConjugated;
  78322. /** hidden */
  78323. _isFromLine: boolean;
  78324. private _parent;
  78325. private _isDisposed;
  78326. private static _tmpVecs;
  78327. private static _tmpQuat;
  78328. /**
  78329. * Specifies if the physics imposter is disposed
  78330. */
  78331. readonly isDisposed: boolean;
  78332. /**
  78333. * Gets the mass of the physics imposter
  78334. */
  78335. mass: number;
  78336. /**
  78337. * Gets the coefficient of friction
  78338. */
  78339. /**
  78340. * Sets the coefficient of friction
  78341. */
  78342. friction: number;
  78343. /**
  78344. * Gets the coefficient of restitution
  78345. */
  78346. /**
  78347. * Sets the coefficient of restitution
  78348. */
  78349. restitution: number;
  78350. /**
  78351. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78352. */
  78353. /**
  78354. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78355. */
  78356. pressure: number;
  78357. /**
  78358. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78359. */
  78360. /**
  78361. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78362. */
  78363. stiffness: number;
  78364. /**
  78365. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78366. */
  78367. /**
  78368. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78369. */
  78370. velocityIterations: number;
  78371. /**
  78372. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78373. */
  78374. /**
  78375. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78376. */
  78377. positionIterations: number;
  78378. /**
  78379. * The unique id of the physics imposter
  78380. * set by the physics engine when adding this impostor to the array
  78381. */
  78382. uniqueId: number;
  78383. /**
  78384. * @hidden
  78385. */
  78386. soft: boolean;
  78387. /**
  78388. * @hidden
  78389. */
  78390. segments: number;
  78391. private _joints;
  78392. /**
  78393. * Initializes the physics imposter
  78394. * @param object The physics-enabled object used as the physics imposter
  78395. * @param type The type of the physics imposter
  78396. * @param _options The options for the physics imposter
  78397. * @param _scene The Babylon scene
  78398. */
  78399. constructor(
  78400. /**
  78401. * The physics-enabled object used as the physics imposter
  78402. */
  78403. object: IPhysicsEnabledObject,
  78404. /**
  78405. * The type of the physics imposter
  78406. */
  78407. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78408. /**
  78409. * This function will completly initialize this impostor.
  78410. * It will create a new body - but only if this mesh has no parent.
  78411. * If it has, this impostor will not be used other than to define the impostor
  78412. * of the child mesh.
  78413. * @hidden
  78414. */
  78415. _init(): void;
  78416. private _getPhysicsParent;
  78417. /**
  78418. * Should a new body be generated.
  78419. * @returns boolean specifying if body initialization is required
  78420. */
  78421. isBodyInitRequired(): boolean;
  78422. /**
  78423. * Sets the updated scaling
  78424. * @param updated Specifies if the scaling is updated
  78425. */
  78426. setScalingUpdated(): void;
  78427. /**
  78428. * Force a regeneration of this or the parent's impostor's body.
  78429. * Use under cautious - This will remove all joints already implemented.
  78430. */
  78431. forceUpdate(): void;
  78432. /**
  78433. * Gets the body that holds this impostor. Either its own, or its parent.
  78434. */
  78435. /**
  78436. * Set the physics body. Used mainly by the physics engine/plugin
  78437. */
  78438. physicsBody: any;
  78439. /**
  78440. * Get the parent of the physics imposter
  78441. * @returns Physics imposter or null
  78442. */
  78443. /**
  78444. * Sets the parent of the physics imposter
  78445. */
  78446. parent: Nullable<PhysicsImpostor>;
  78447. /**
  78448. * Resets the update flags
  78449. */
  78450. resetUpdateFlags(): void;
  78451. /**
  78452. * Gets the object extend size
  78453. * @returns the object extend size
  78454. */
  78455. getObjectExtendSize(): Vector3;
  78456. /**
  78457. * Gets the object center
  78458. * @returns The object center
  78459. */
  78460. getObjectCenter(): Vector3;
  78461. /**
  78462. * Get a specific parametes from the options parameter
  78463. * @param paramName The object parameter name
  78464. * @returns The object parameter
  78465. */
  78466. getParam(paramName: string): any;
  78467. /**
  78468. * Sets a specific parameter in the options given to the physics plugin
  78469. * @param paramName The parameter name
  78470. * @param value The value of the parameter
  78471. */
  78472. setParam(paramName: string, value: number): void;
  78473. /**
  78474. * Specifically change the body's mass option. Won't recreate the physics body object
  78475. * @param mass The mass of the physics imposter
  78476. */
  78477. setMass(mass: number): void;
  78478. /**
  78479. * Gets the linear velocity
  78480. * @returns linear velocity or null
  78481. */
  78482. getLinearVelocity(): Nullable<Vector3>;
  78483. /**
  78484. * Sets the linear velocity
  78485. * @param velocity linear velocity or null
  78486. */
  78487. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78488. /**
  78489. * Gets the angular velocity
  78490. * @returns angular velocity or null
  78491. */
  78492. getAngularVelocity(): Nullable<Vector3>;
  78493. /**
  78494. * Sets the angular velocity
  78495. * @param velocity The velocity or null
  78496. */
  78497. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78498. /**
  78499. * Execute a function with the physics plugin native code
  78500. * Provide a function the will have two variables - the world object and the physics body object
  78501. * @param func The function to execute with the physics plugin native code
  78502. */
  78503. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78504. /**
  78505. * Register a function that will be executed before the physics world is stepping forward
  78506. * @param func The function to execute before the physics world is stepped forward
  78507. */
  78508. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78509. /**
  78510. * Unregister a function that will be executed before the physics world is stepping forward
  78511. * @param func The function to execute before the physics world is stepped forward
  78512. */
  78513. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78514. /**
  78515. * Register a function that will be executed after the physics step
  78516. * @param func The function to execute after physics step
  78517. */
  78518. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78519. /**
  78520. * Unregisters a function that will be executed after the physics step
  78521. * @param func The function to execute after physics step
  78522. */
  78523. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78524. /**
  78525. * register a function that will be executed when this impostor collides against a different body
  78526. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78527. * @param func Callback that is executed on collision
  78528. */
  78529. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78530. /**
  78531. * Unregisters the physics imposter on contact
  78532. * @param collideAgainst The physics object to collide against
  78533. * @param func Callback to execute on collision
  78534. */
  78535. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78536. private _tmpQuat;
  78537. private _tmpQuat2;
  78538. /**
  78539. * Get the parent rotation
  78540. * @returns The parent rotation
  78541. */
  78542. getParentsRotation(): Quaternion;
  78543. /**
  78544. * this function is executed by the physics engine.
  78545. */
  78546. beforeStep: () => void;
  78547. /**
  78548. * this function is executed by the physics engine
  78549. */
  78550. afterStep: () => void;
  78551. /**
  78552. * Legacy collision detection event support
  78553. */
  78554. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78555. /**
  78556. * event and body object due to cannon's event-based architecture.
  78557. */
  78558. onCollide: (e: {
  78559. body: any;
  78560. }) => void;
  78561. /**
  78562. * Apply a force
  78563. * @param force The force to apply
  78564. * @param contactPoint The contact point for the force
  78565. * @returns The physics imposter
  78566. */
  78567. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78568. /**
  78569. * Apply an impulse
  78570. * @param force The impulse force
  78571. * @param contactPoint The contact point for the impulse force
  78572. * @returns The physics imposter
  78573. */
  78574. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78575. /**
  78576. * A help function to create a joint
  78577. * @param otherImpostor A physics imposter used to create a joint
  78578. * @param jointType The type of joint
  78579. * @param jointData The data for the joint
  78580. * @returns The physics imposter
  78581. */
  78582. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78583. /**
  78584. * Add a joint to this impostor with a different impostor
  78585. * @param otherImpostor A physics imposter used to add a joint
  78586. * @param joint The joint to add
  78587. * @returns The physics imposter
  78588. */
  78589. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78590. /**
  78591. * Add an anchor to a cloth impostor
  78592. * @param otherImpostor rigid impostor to anchor to
  78593. * @param width ratio across width from 0 to 1
  78594. * @param height ratio up height from 0 to 1
  78595. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  78596. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  78597. * @returns impostor the soft imposter
  78598. */
  78599. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78600. /**
  78601. * Add a hook to a rope impostor
  78602. * @param otherImpostor rigid impostor to anchor to
  78603. * @param length ratio across rope from 0 to 1
  78604. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  78605. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  78606. * @returns impostor the rope imposter
  78607. */
  78608. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78609. /**
  78610. * Will keep this body still, in a sleep mode.
  78611. * @returns the physics imposter
  78612. */
  78613. sleep(): PhysicsImpostor;
  78614. /**
  78615. * Wake the body up.
  78616. * @returns The physics imposter
  78617. */
  78618. wakeUp(): PhysicsImpostor;
  78619. /**
  78620. * Clones the physics imposter
  78621. * @param newObject The physics imposter clones to this physics-enabled object
  78622. * @returns A nullable physics imposter
  78623. */
  78624. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78625. /**
  78626. * Disposes the physics imposter
  78627. */
  78628. dispose(): void;
  78629. /**
  78630. * Sets the delta position
  78631. * @param position The delta position amount
  78632. */
  78633. setDeltaPosition(position: Vector3): void;
  78634. /**
  78635. * Sets the delta rotation
  78636. * @param rotation The delta rotation amount
  78637. */
  78638. setDeltaRotation(rotation: Quaternion): void;
  78639. /**
  78640. * Gets the box size of the physics imposter and stores the result in the input parameter
  78641. * @param result Stores the box size
  78642. * @returns The physics imposter
  78643. */
  78644. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78645. /**
  78646. * Gets the radius of the physics imposter
  78647. * @returns Radius of the physics imposter
  78648. */
  78649. getRadius(): number;
  78650. /**
  78651. * Sync a bone with this impostor
  78652. * @param bone The bone to sync to the impostor.
  78653. * @param boneMesh The mesh that the bone is influencing.
  78654. * @param jointPivot The pivot of the joint / bone in local space.
  78655. * @param distToJoint Optional distance from the impostor to the joint.
  78656. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78657. */
  78658. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78659. /**
  78660. * Sync impostor to a bone
  78661. * @param bone The bone that the impostor will be synced to.
  78662. * @param boneMesh The mesh that the bone is influencing.
  78663. * @param jointPivot The pivot of the joint / bone in local space.
  78664. * @param distToJoint Optional distance from the impostor to the joint.
  78665. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78666. * @param boneAxis Optional vector3 axis the bone is aligned with
  78667. */
  78668. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  78669. /**
  78670. * No-Imposter type
  78671. */
  78672. static NoImpostor: number;
  78673. /**
  78674. * Sphere-Imposter type
  78675. */
  78676. static SphereImpostor: number;
  78677. /**
  78678. * Box-Imposter type
  78679. */
  78680. static BoxImpostor: number;
  78681. /**
  78682. * Plane-Imposter type
  78683. */
  78684. static PlaneImpostor: number;
  78685. /**
  78686. * Mesh-imposter type
  78687. */
  78688. static MeshImpostor: number;
  78689. /**
  78690. * Cylinder-Imposter type
  78691. */
  78692. static CylinderImpostor: number;
  78693. /**
  78694. * Particle-Imposter type
  78695. */
  78696. static ParticleImpostor: number;
  78697. /**
  78698. * Heightmap-Imposter type
  78699. */
  78700. static HeightmapImpostor: number;
  78701. /**
  78702. * ConvexHull-Impostor type (Ammo.js plugin only)
  78703. */
  78704. static ConvexHullImpostor: number;
  78705. /**
  78706. * Rope-Imposter type
  78707. */
  78708. static RopeImpostor: number;
  78709. /**
  78710. * Cloth-Imposter type
  78711. */
  78712. static ClothImpostor: number;
  78713. /**
  78714. * Softbody-Imposter type
  78715. */
  78716. static SoftbodyImpostor: number;
  78717. }
  78718. }
  78719. declare module BABYLON {
  78720. /**
  78721. * Class used to represent a specific level of detail of a mesh
  78722. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78723. */
  78724. export class MeshLODLevel {
  78725. /** Defines the distance where this level should star being displayed */
  78726. distance: number;
  78727. /** Defines the mesh to use to render this level */
  78728. mesh: Nullable<Mesh>;
  78729. /**
  78730. * Creates a new LOD level
  78731. * @param distance defines the distance where this level should star being displayed
  78732. * @param mesh defines the mesh to use to render this level
  78733. */
  78734. constructor(
  78735. /** Defines the distance where this level should star being displayed */
  78736. distance: number,
  78737. /** Defines the mesh to use to render this level */
  78738. mesh: Nullable<Mesh>);
  78739. }
  78740. /**
  78741. * @hidden
  78742. **/
  78743. export class _CreationDataStorage {
  78744. closePath?: boolean;
  78745. closeArray?: boolean;
  78746. idx: number[];
  78747. dashSize: number;
  78748. gapSize: number;
  78749. path3D: Path3D;
  78750. pathArray: Vector3[][];
  78751. arc: number;
  78752. radius: number;
  78753. cap: number;
  78754. tessellation: number;
  78755. }
  78756. /**
  78757. * @hidden
  78758. **/
  78759. class _InstanceDataStorage {
  78760. visibleInstances: any;
  78761. renderIdForInstances: number[];
  78762. batchCache: _InstancesBatch;
  78763. instancesBufferSize: number;
  78764. instancesBuffer: Nullable<Buffer>;
  78765. instancesData: Float32Array;
  78766. overridenInstanceCount: number;
  78767. }
  78768. /**
  78769. * @hidden
  78770. **/
  78771. export class _InstancesBatch {
  78772. mustReturn: boolean;
  78773. visibleInstances: Nullable<InstancedMesh[]>[];
  78774. renderSelf: boolean[];
  78775. }
  78776. /**
  78777. * Class used to represent renderable models
  78778. */
  78779. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  78780. /**
  78781. * Mesh side orientation : usually the external or front surface
  78782. */
  78783. static readonly FRONTSIDE: number;
  78784. /**
  78785. * Mesh side orientation : usually the internal or back surface
  78786. */
  78787. static readonly BACKSIDE: number;
  78788. /**
  78789. * Mesh side orientation : both internal and external or front and back surfaces
  78790. */
  78791. static readonly DOUBLESIDE: number;
  78792. /**
  78793. * Mesh side orientation : by default, `FRONTSIDE`
  78794. */
  78795. static readonly DEFAULTSIDE: number;
  78796. /**
  78797. * Mesh cap setting : no cap
  78798. */
  78799. static readonly NO_CAP: number;
  78800. /**
  78801. * Mesh cap setting : one cap at the beginning of the mesh
  78802. */
  78803. static readonly CAP_START: number;
  78804. /**
  78805. * Mesh cap setting : one cap at the end of the mesh
  78806. */
  78807. static readonly CAP_END: number;
  78808. /**
  78809. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  78810. */
  78811. static readonly CAP_ALL: number;
  78812. /**
  78813. * Gets the default side orientation.
  78814. * @param orientation the orientation to value to attempt to get
  78815. * @returns the default orientation
  78816. * @hidden
  78817. */
  78818. static _GetDefaultSideOrientation(orientation?: number): number;
  78819. private _onBeforeRenderObservable;
  78820. private _onBeforeBindObservable;
  78821. private _onAfterRenderObservable;
  78822. private _onBeforeDrawObservable;
  78823. /**
  78824. * An event triggered before rendering the mesh
  78825. */
  78826. readonly onBeforeRenderObservable: Observable<Mesh>;
  78827. /**
  78828. * An event triggered before binding the mesh
  78829. */
  78830. readonly onBeforeBindObservable: Observable<Mesh>;
  78831. /**
  78832. * An event triggered after rendering the mesh
  78833. */
  78834. readonly onAfterRenderObservable: Observable<Mesh>;
  78835. /**
  78836. * An event triggered before drawing the mesh
  78837. */
  78838. readonly onBeforeDrawObservable: Observable<Mesh>;
  78839. private _onBeforeDrawObserver;
  78840. /**
  78841. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  78842. */
  78843. onBeforeDraw: () => void;
  78844. /**
  78845. * Gets the delay loading state of the mesh (when delay loading is turned on)
  78846. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  78847. */
  78848. delayLoadState: number;
  78849. /**
  78850. * Gets the list of instances created from this mesh
  78851. * it is not supposed to be modified manually.
  78852. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  78853. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78854. */
  78855. instances: InstancedMesh[];
  78856. /**
  78857. * Gets the file containing delay loading data for this mesh
  78858. */
  78859. delayLoadingFile: string;
  78860. /** @hidden */
  78861. _binaryInfo: any;
  78862. private _LODLevels;
  78863. /**
  78864. * User defined function used to change how LOD level selection is done
  78865. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78866. */
  78867. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  78868. private _morphTargetManager;
  78869. /**
  78870. * Gets or sets the morph target manager
  78871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78872. */
  78873. morphTargetManager: Nullable<MorphTargetManager>;
  78874. /** @hidden */
  78875. _creationDataStorage: Nullable<_CreationDataStorage>;
  78876. /** @hidden */
  78877. _geometry: Nullable<Geometry>;
  78878. /** @hidden */
  78879. _delayInfo: Array<string>;
  78880. /** @hidden */
  78881. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  78882. /** @hidden */
  78883. _instanceDataStorage: _InstanceDataStorage;
  78884. private _effectiveMaterial;
  78885. /** @hidden */
  78886. _shouldGenerateFlatShading: boolean;
  78887. private _preActivateId;
  78888. /** @hidden */
  78889. _originalBuilderSideOrientation: number;
  78890. /**
  78891. * Use this property to change the original side orientation defined at construction time
  78892. */
  78893. overrideMaterialSideOrientation: Nullable<number>;
  78894. private _areNormalsFrozen;
  78895. private _sourcePositions;
  78896. private _sourceNormals;
  78897. private _source;
  78898. private meshMap;
  78899. /**
  78900. * Gets the source mesh (the one used to clone this one from)
  78901. */
  78902. readonly source: Nullable<Mesh>;
  78903. /**
  78904. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78905. */
  78906. isUnIndexed: boolean;
  78907. /**
  78908. * @constructor
  78909. * @param name The value used by scene.getMeshByName() to do a lookup.
  78910. * @param scene The scene to add this mesh to.
  78911. * @param parent The parent of this mesh, if it has one
  78912. * @param source An optional Mesh from which geometry is shared, cloned.
  78913. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78914. * When false, achieved by calling a clone(), also passing False.
  78915. * This will make creation of children, recursive.
  78916. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78917. */
  78918. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78919. /**
  78920. * Gets the class name
  78921. * @returns the string "Mesh".
  78922. */
  78923. getClassName(): string;
  78924. /** @hidden */
  78925. readonly _isMesh: boolean;
  78926. /**
  78927. * Returns a description of this mesh
  78928. * @param fullDetails define if full details about this mesh must be used
  78929. * @returns a descriptive string representing this mesh
  78930. */
  78931. toString(fullDetails?: boolean): string;
  78932. /** @hidden */
  78933. _unBindEffect(): void;
  78934. /**
  78935. * Gets a boolean indicating if this mesh has LOD
  78936. */
  78937. readonly hasLODLevels: boolean;
  78938. /**
  78939. * Gets the list of MeshLODLevel associated with the current mesh
  78940. * @returns an array of MeshLODLevel
  78941. */
  78942. getLODLevels(): MeshLODLevel[];
  78943. private _sortLODLevels;
  78944. /**
  78945. * Add a mesh as LOD level triggered at the given distance.
  78946. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78947. * @param distance The distance from the center of the object to show this level
  78948. * @param mesh The mesh to be added as LOD level (can be null)
  78949. * @return This mesh (for chaining)
  78950. */
  78951. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78952. /**
  78953. * Returns the LOD level mesh at the passed distance or null if not found.
  78954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78955. * @param distance The distance from the center of the object to show this level
  78956. * @returns a Mesh or `null`
  78957. */
  78958. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78959. /**
  78960. * Remove a mesh from the LOD array
  78961. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78962. * @param mesh defines the mesh to be removed
  78963. * @return This mesh (for chaining)
  78964. */
  78965. removeLODLevel(mesh: Mesh): Mesh;
  78966. /**
  78967. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78968. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78969. * @param camera defines the camera to use to compute distance
  78970. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78971. * @return This mesh (for chaining)
  78972. */
  78973. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78974. /**
  78975. * Gets the mesh internal Geometry object
  78976. */
  78977. readonly geometry: Nullable<Geometry>;
  78978. /**
  78979. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78980. * @returns the total number of vertices
  78981. */
  78982. getTotalVertices(): number;
  78983. /**
  78984. * Returns the content of an associated vertex buffer
  78985. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78986. * - VertexBuffer.PositionKind
  78987. * - VertexBuffer.UVKind
  78988. * - VertexBuffer.UV2Kind
  78989. * - VertexBuffer.UV3Kind
  78990. * - VertexBuffer.UV4Kind
  78991. * - VertexBuffer.UV5Kind
  78992. * - VertexBuffer.UV6Kind
  78993. * - VertexBuffer.ColorKind
  78994. * - VertexBuffer.MatricesIndicesKind
  78995. * - VertexBuffer.MatricesIndicesExtraKind
  78996. * - VertexBuffer.MatricesWeightsKind
  78997. * - VertexBuffer.MatricesWeightsExtraKind
  78998. * @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
  78999. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  79000. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  79001. */
  79002. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  79003. /**
  79004. * Returns the mesh VertexBuffer object from the requested `kind`
  79005. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79006. * - VertexBuffer.PositionKind
  79007. * - VertexBuffer.UVKind
  79008. * - VertexBuffer.UV2Kind
  79009. * - VertexBuffer.UV3Kind
  79010. * - VertexBuffer.UV4Kind
  79011. * - VertexBuffer.UV5Kind
  79012. * - VertexBuffer.UV6Kind
  79013. * - VertexBuffer.ColorKind
  79014. * - VertexBuffer.MatricesIndicesKind
  79015. * - VertexBuffer.MatricesIndicesExtraKind
  79016. * - VertexBuffer.MatricesWeightsKind
  79017. * - VertexBuffer.MatricesWeightsExtraKind
  79018. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  79019. */
  79020. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  79021. /**
  79022. * Tests if a specific vertex buffer is associated with this mesh
  79023. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79024. * - VertexBuffer.PositionKind
  79025. * - VertexBuffer.UVKind
  79026. * - VertexBuffer.UV2Kind
  79027. * - VertexBuffer.UV3Kind
  79028. * - VertexBuffer.UV4Kind
  79029. * - VertexBuffer.UV5Kind
  79030. * - VertexBuffer.UV6Kind
  79031. * - VertexBuffer.ColorKind
  79032. * - VertexBuffer.MatricesIndicesKind
  79033. * - VertexBuffer.MatricesIndicesExtraKind
  79034. * - VertexBuffer.MatricesWeightsKind
  79035. * - VertexBuffer.MatricesWeightsExtraKind
  79036. * @returns a boolean
  79037. */
  79038. isVerticesDataPresent(kind: string): boolean;
  79039. /**
  79040. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  79041. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  79042. * - VertexBuffer.PositionKind
  79043. * - VertexBuffer.UVKind
  79044. * - VertexBuffer.UV2Kind
  79045. * - VertexBuffer.UV3Kind
  79046. * - VertexBuffer.UV4Kind
  79047. * - VertexBuffer.UV5Kind
  79048. * - VertexBuffer.UV6Kind
  79049. * - VertexBuffer.ColorKind
  79050. * - VertexBuffer.MatricesIndicesKind
  79051. * - VertexBuffer.MatricesIndicesExtraKind
  79052. * - VertexBuffer.MatricesWeightsKind
  79053. * - VertexBuffer.MatricesWeightsExtraKind
  79054. * @returns a boolean
  79055. */
  79056. isVertexBufferUpdatable(kind: string): boolean;
  79057. /**
  79058. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  79059. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  79060. * - VertexBuffer.PositionKind
  79061. * - VertexBuffer.UVKind
  79062. * - VertexBuffer.UV2Kind
  79063. * - VertexBuffer.UV3Kind
  79064. * - VertexBuffer.UV4Kind
  79065. * - VertexBuffer.UV5Kind
  79066. * - VertexBuffer.UV6Kind
  79067. * - VertexBuffer.ColorKind
  79068. * - VertexBuffer.MatricesIndicesKind
  79069. * - VertexBuffer.MatricesIndicesExtraKind
  79070. * - VertexBuffer.MatricesWeightsKind
  79071. * - VertexBuffer.MatricesWeightsExtraKind
  79072. * @returns an array of strings
  79073. */
  79074. getVerticesDataKinds(): string[];
  79075. /**
  79076. * Returns a positive integer : the total number of indices in this mesh geometry.
  79077. * @returns the numner of indices or zero if the mesh has no geometry.
  79078. */
  79079. getTotalIndices(): number;
  79080. /**
  79081. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79082. * @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.
  79083. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79084. * @returns the indices array or an empty array if the mesh has no geometry
  79085. */
  79086. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79087. readonly isBlocked: boolean;
  79088. /**
  79089. * Determine if the current mesh is ready to be rendered
  79090. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79091. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79092. * @returns true if all associated assets are ready (material, textures, shaders)
  79093. */
  79094. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79095. /**
  79096. * 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.
  79097. */
  79098. readonly areNormalsFrozen: boolean;
  79099. /**
  79100. * 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.
  79101. * @returns the current mesh
  79102. */
  79103. freezeNormals(): Mesh;
  79104. /**
  79105. * 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
  79106. * @returns the current mesh
  79107. */
  79108. unfreezeNormals(): Mesh;
  79109. /**
  79110. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79111. */
  79112. overridenInstanceCount: number;
  79113. /** @hidden */
  79114. _preActivate(): Mesh;
  79115. /** @hidden */
  79116. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79117. /** @hidden */
  79118. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79119. /**
  79120. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79121. * This means the mesh underlying bounding box and sphere are recomputed.
  79122. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79123. * @returns the current mesh
  79124. */
  79125. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79126. /** @hidden */
  79127. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79128. /**
  79129. * This function will subdivide the mesh into multiple submeshes
  79130. * @param count defines the expected number of submeshes
  79131. */
  79132. subdivide(count: number): void;
  79133. /**
  79134. * Copy a FloatArray into a specific associated vertex buffer
  79135. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79136. * - VertexBuffer.PositionKind
  79137. * - VertexBuffer.UVKind
  79138. * - VertexBuffer.UV2Kind
  79139. * - VertexBuffer.UV3Kind
  79140. * - VertexBuffer.UV4Kind
  79141. * - VertexBuffer.UV5Kind
  79142. * - VertexBuffer.UV6Kind
  79143. * - VertexBuffer.ColorKind
  79144. * - VertexBuffer.MatricesIndicesKind
  79145. * - VertexBuffer.MatricesIndicesExtraKind
  79146. * - VertexBuffer.MatricesWeightsKind
  79147. * - VertexBuffer.MatricesWeightsExtraKind
  79148. * @param data defines the data source
  79149. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79150. * @param stride defines the data stride size (can be null)
  79151. * @returns the current mesh
  79152. */
  79153. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79154. /**
  79155. * Flags an associated vertex buffer as updatable
  79156. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79157. * - VertexBuffer.PositionKind
  79158. * - VertexBuffer.UVKind
  79159. * - VertexBuffer.UV2Kind
  79160. * - VertexBuffer.UV3Kind
  79161. * - VertexBuffer.UV4Kind
  79162. * - VertexBuffer.UV5Kind
  79163. * - VertexBuffer.UV6Kind
  79164. * - VertexBuffer.ColorKind
  79165. * - VertexBuffer.MatricesIndicesKind
  79166. * - VertexBuffer.MatricesIndicesExtraKind
  79167. * - VertexBuffer.MatricesWeightsKind
  79168. * - VertexBuffer.MatricesWeightsExtraKind
  79169. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79170. */
  79171. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79172. /**
  79173. * Sets the mesh global Vertex Buffer
  79174. * @param buffer defines the buffer to use
  79175. * @returns the current mesh
  79176. */
  79177. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79178. /**
  79179. * Update a specific associated vertex buffer
  79180. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79181. * - VertexBuffer.PositionKind
  79182. * - VertexBuffer.UVKind
  79183. * - VertexBuffer.UV2Kind
  79184. * - VertexBuffer.UV3Kind
  79185. * - VertexBuffer.UV4Kind
  79186. * - VertexBuffer.UV5Kind
  79187. * - VertexBuffer.UV6Kind
  79188. * - VertexBuffer.ColorKind
  79189. * - VertexBuffer.MatricesIndicesKind
  79190. * - VertexBuffer.MatricesIndicesExtraKind
  79191. * - VertexBuffer.MatricesWeightsKind
  79192. * - VertexBuffer.MatricesWeightsExtraKind
  79193. * @param data defines the data source
  79194. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79195. * @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)
  79196. * @returns the current mesh
  79197. */
  79198. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79199. /**
  79200. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79201. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79202. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79203. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79204. * @returns the current mesh
  79205. */
  79206. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79207. /**
  79208. * Creates a un-shared specific occurence of the geometry for the mesh.
  79209. * @returns the current mesh
  79210. */
  79211. makeGeometryUnique(): Mesh;
  79212. /**
  79213. * Set the index buffer of this mesh
  79214. * @param indices defines the source data
  79215. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79216. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79217. * @returns the current mesh
  79218. */
  79219. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79220. /**
  79221. * Update the current index buffer
  79222. * @param indices defines the source data
  79223. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79224. * @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)
  79225. * @returns the current mesh
  79226. */
  79227. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79228. /**
  79229. * Invert the geometry to move from a right handed system to a left handed one.
  79230. * @returns the current mesh
  79231. */
  79232. toLeftHanded(): Mesh;
  79233. /** @hidden */
  79234. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79235. /** @hidden */
  79236. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  79237. /**
  79238. * Registers for this mesh a javascript function called just before the rendering process
  79239. * @param func defines the function to call before rendering this mesh
  79240. * @returns the current mesh
  79241. */
  79242. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79243. /**
  79244. * Disposes a previously registered javascript function called before the rendering
  79245. * @param func defines the function to remove
  79246. * @returns the current mesh
  79247. */
  79248. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79249. /**
  79250. * Registers for this mesh a javascript function called just after the rendering is complete
  79251. * @param func defines the function to call after rendering this mesh
  79252. * @returns the current mesh
  79253. */
  79254. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79255. /**
  79256. * Disposes a previously registered javascript function called after the rendering.
  79257. * @param func defines the function to remove
  79258. * @returns the current mesh
  79259. */
  79260. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79261. /** @hidden */
  79262. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79263. /** @hidden */
  79264. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79265. /** @hidden */
  79266. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79267. /**
  79268. * 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
  79269. * @param subMesh defines the subMesh to render
  79270. * @param enableAlphaMode defines if alpha mode can be changed
  79271. * @returns the current mesh
  79272. */
  79273. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79274. private _onBeforeDraw;
  79275. /**
  79276. * Renormalize the mesh and patch it up if there are no weights
  79277. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79278. * However in the case of zero weights then we set just a single influence to 1.
  79279. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79280. */
  79281. cleanMatrixWeights(): void;
  79282. private normalizeSkinFourWeights;
  79283. private normalizeSkinWeightsAndExtra;
  79284. /**
  79285. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79286. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79287. * the user know there was an issue with importing the mesh
  79288. * @returns a validation object with skinned, valid and report string
  79289. */
  79290. validateSkinning(): {
  79291. skinned: boolean;
  79292. valid: boolean;
  79293. report: string;
  79294. };
  79295. /** @hidden */
  79296. _checkDelayState(): Mesh;
  79297. private _queueLoad;
  79298. /**
  79299. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79300. * A mesh is in the frustum if its bounding box intersects the frustum
  79301. * @param frustumPlanes defines the frustum to test
  79302. * @returns true if the mesh is in the frustum planes
  79303. */
  79304. isInFrustum(frustumPlanes: Plane[]): boolean;
  79305. /**
  79306. * Sets the mesh material by the material or multiMaterial `id` property
  79307. * @param id is a string identifying the material or the multiMaterial
  79308. * @returns the current mesh
  79309. */
  79310. setMaterialByID(id: string): Mesh;
  79311. /**
  79312. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79313. * @returns an array of IAnimatable
  79314. */
  79315. getAnimatables(): IAnimatable[];
  79316. /**
  79317. * Modifies the mesh geometry according to the passed transformation matrix.
  79318. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79319. * The mesh normals are modified using the same transformation.
  79320. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79321. * @param transform defines the transform matrix to use
  79322. * @see http://doc.babylonjs.com/resources/baking_transformations
  79323. * @returns the current mesh
  79324. */
  79325. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79326. /**
  79327. * Modifies the mesh geometry according to its own current World Matrix.
  79328. * The mesh World Matrix is then reset.
  79329. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79330. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79331. * @see http://doc.babylonjs.com/resources/baking_transformations
  79332. * @returns the current mesh
  79333. */
  79334. bakeCurrentTransformIntoVertices(): Mesh;
  79335. /** @hidden */
  79336. readonly _positions: Nullable<Vector3[]>;
  79337. /** @hidden */
  79338. _resetPointsArrayCache(): Mesh;
  79339. /** @hidden */
  79340. _generatePointsArray(): boolean;
  79341. /**
  79342. * Returns a new Mesh object generated from the current mesh properties.
  79343. * This method must not get confused with createInstance()
  79344. * @param name is a string, the name given to the new mesh
  79345. * @param newParent can be any Node object (default `null`)
  79346. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79347. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79348. * @returns a new mesh
  79349. */
  79350. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79351. /**
  79352. * Releases resources associated with this mesh.
  79353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79355. */
  79356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79357. /**
  79358. * Modifies the mesh geometry according to a displacement map.
  79359. * 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.
  79360. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79361. * @param url is a string, the URL from the image file is to be downloaded.
  79362. * @param minHeight is the lower limit of the displacement.
  79363. * @param maxHeight is the upper limit of the displacement.
  79364. * @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.
  79365. * @param uvOffset is an optional vector2 used to offset UV.
  79366. * @param uvScale is an optional vector2 used to scale UV.
  79367. * @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.
  79368. * @returns the Mesh.
  79369. */
  79370. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79371. /**
  79372. * Modifies the mesh geometry according to a displacementMap buffer.
  79373. * 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.
  79374. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79375. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79376. * @param heightMapWidth is the width of the buffer image.
  79377. * @param heightMapHeight is the height of the buffer image.
  79378. * @param minHeight is the lower limit of the displacement.
  79379. * @param maxHeight is the upper limit of the displacement.
  79380. * @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.
  79381. * @param uvOffset is an optional vector2 used to offset UV.
  79382. * @param uvScale is an optional vector2 used to scale UV.
  79383. * @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.
  79384. * @returns the Mesh.
  79385. */
  79386. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79387. /**
  79388. * Modify the mesh to get a flat shading rendering.
  79389. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79390. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79391. * @returns current mesh
  79392. */
  79393. convertToFlatShadedMesh(): Mesh;
  79394. /**
  79395. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79396. * In other words, more vertices, no more indices and a single bigger VBO.
  79397. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79398. * @returns current mesh
  79399. */
  79400. convertToUnIndexedMesh(): Mesh;
  79401. /**
  79402. * Inverses facet orientations.
  79403. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79404. * @param flipNormals will also inverts the normals
  79405. * @returns current mesh
  79406. */
  79407. flipFaces(flipNormals?: boolean): Mesh;
  79408. /**
  79409. * Increase the number of facets and hence vertices in a mesh
  79410. * Vertex normals are interpolated from existing vertex normals
  79411. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79412. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79413. */
  79414. increaseVertices(numberPerEdge: number): void;
  79415. /**
  79416. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79417. * This will undo any application of covertToFlatShadedMesh
  79418. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79419. */
  79420. forceSharedVertices(): void;
  79421. /** @hidden */
  79422. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79423. /** @hidden */
  79424. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79425. /**
  79426. * Creates a new InstancedMesh object from the mesh model.
  79427. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79428. * @param name defines the name of the new instance
  79429. * @returns a new InstancedMesh
  79430. */
  79431. createInstance(name: string): InstancedMesh;
  79432. /**
  79433. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79434. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79435. * @returns the current mesh
  79436. */
  79437. synchronizeInstances(): Mesh;
  79438. /**
  79439. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79440. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79441. * This should be used together with the simplification to avoid disappearing triangles.
  79442. * @param successCallback an optional success callback to be called after the optimization finished.
  79443. * @returns the current mesh
  79444. */
  79445. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79446. /**
  79447. * Serialize current mesh
  79448. * @param serializationObject defines the object which will receive the serialization data
  79449. */
  79450. serialize(serializationObject: any): void;
  79451. /** @hidden */
  79452. _syncGeometryWithMorphTargetManager(): void;
  79453. /** @hidden */
  79454. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79455. /**
  79456. * Returns a new Mesh object parsed from the source provided.
  79457. * @param parsedMesh is the source
  79458. * @param scene defines the hosting scene
  79459. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79460. * @returns a new Mesh
  79461. */
  79462. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79463. /**
  79464. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79465. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79466. * @param name defines the name of the mesh to create
  79467. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79468. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79469. * @param closePath creates a seam between the first and the last points of each path of the path array
  79470. * @param offset is taken in account only if the `pathArray` is containing a single path
  79471. * @param scene defines the hosting scene
  79472. * @param updatable defines if the mesh must be flagged as updatable
  79473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79474. * @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)
  79475. * @returns a new Mesh
  79476. */
  79477. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79478. /**
  79479. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79480. * @param name defines the name of the mesh to create
  79481. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79482. * @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
  79483. * @param scene defines the hosting scene
  79484. * @param updatable defines if the mesh must be flagged as updatable
  79485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79486. * @returns a new Mesh
  79487. */
  79488. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79489. /**
  79490. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79491. * @param name defines the name of the mesh to create
  79492. * @param size sets the size (float) of each box side (default 1)
  79493. * @param scene defines the hosting scene
  79494. * @param updatable defines if the mesh must be flagged as updatable
  79495. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79496. * @returns a new Mesh
  79497. */
  79498. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79499. /**
  79500. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79501. * @param name defines the name of the mesh to create
  79502. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79503. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79504. * @param scene defines the hosting scene
  79505. * @param updatable defines if the mesh must be flagged as updatable
  79506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79507. * @returns a new Mesh
  79508. */
  79509. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79510. /**
  79511. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79512. * @param name defines the name of the mesh to create
  79513. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79514. * @param diameterTop set the top cap diameter (floats, default 1)
  79515. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79516. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79517. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79518. * @param scene defines the hosting scene
  79519. * @param updatable defines if the mesh must be flagged as updatable
  79520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79521. * @returns a new Mesh
  79522. */
  79523. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79524. /**
  79525. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79526. * @param name defines the name of the mesh to create
  79527. * @param diameter sets the diameter size (float) of the torus (default 1)
  79528. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79529. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79530. * @param scene defines the hosting scene
  79531. * @param updatable defines if the mesh must be flagged as updatable
  79532. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79533. * @returns a new Mesh
  79534. */
  79535. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79536. /**
  79537. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79538. * @param name defines the name of the mesh to create
  79539. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79540. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79541. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79542. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79543. * @param p the number of windings on X axis (positive integers, default 2)
  79544. * @param q the number of windings on Y axis (positive integers, default 3)
  79545. * @param scene defines the hosting scene
  79546. * @param updatable defines if the mesh must be flagged as updatable
  79547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79548. * @returns a new Mesh
  79549. */
  79550. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79551. /**
  79552. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79553. * @param name defines the name of the mesh to create
  79554. * @param points is an array successive Vector3
  79555. * @param scene defines the hosting scene
  79556. * @param updatable defines if the mesh must be flagged as updatable
  79557. * @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).
  79558. * @returns a new Mesh
  79559. */
  79560. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79561. /**
  79562. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79563. * @param name defines the name of the mesh to create
  79564. * @param points is an array successive Vector3
  79565. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79566. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79567. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79568. * @param scene defines the hosting scene
  79569. * @param updatable defines if the mesh must be flagged as updatable
  79570. * @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)
  79571. * @returns a new Mesh
  79572. */
  79573. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79574. /**
  79575. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79576. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79577. * 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.
  79578. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79579. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79580. * Remember you can only change the shape positions, not their number when updating a polygon.
  79581. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79582. * @param name defines the name of the mesh to create
  79583. * @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
  79584. * @param scene defines the hosting scene
  79585. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79586. * @param updatable defines if the mesh must be flagged as updatable
  79587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79588. * @param earcutInjection can be used to inject your own earcut reference
  79589. * @returns a new Mesh
  79590. */
  79591. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79592. /**
  79593. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79595. * @param name defines the name of the mesh to create
  79596. * @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
  79597. * @param depth defines the height of extrusion
  79598. * @param scene defines the hosting scene
  79599. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79600. * @param updatable defines if the mesh must be flagged as updatable
  79601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79602. * @param earcutInjection can be used to inject your own earcut reference
  79603. * @returns a new Mesh
  79604. */
  79605. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79606. /**
  79607. * Creates an extruded shape mesh.
  79608. * 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
  79609. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79610. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79611. * @param name defines the name of the mesh to create
  79612. * @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
  79613. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79614. * @param scale is the value to scale the shape
  79615. * @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
  79616. * @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
  79617. * @param scene defines the hosting scene
  79618. * @param updatable defines if the mesh must be flagged as updatable
  79619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79620. * @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)
  79621. * @returns a new Mesh
  79622. */
  79623. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79624. /**
  79625. * Creates an custom extruded shape mesh.
  79626. * The custom extrusion is a parametric shape.
  79627. * It has no predefined shape. Its final shape will depend on the input parameters.
  79628. * Please consider using the same method from the MeshBuilder class instead
  79629. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79630. * @param name defines the name of the mesh to create
  79631. * @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
  79632. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79633. * @param scaleFunction is a custom Javascript function called on each path point
  79634. * @param rotationFunction is a custom Javascript function called on each path point
  79635. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79636. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79637. * @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
  79638. * @param scene defines the hosting scene
  79639. * @param updatable defines if the mesh must be flagged as updatable
  79640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79641. * @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)
  79642. * @returns a new Mesh
  79643. */
  79644. 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;
  79645. /**
  79646. * Creates lathe mesh.
  79647. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79648. * Please consider using the same method from the MeshBuilder class instead
  79649. * @param name defines the name of the mesh to create
  79650. * @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
  79651. * @param radius is the radius value of the lathe
  79652. * @param tessellation is the side number of the lathe.
  79653. * @param scene defines the hosting scene
  79654. * @param updatable defines if the mesh must be flagged as updatable
  79655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79656. * @returns a new Mesh
  79657. */
  79658. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79659. /**
  79660. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79661. * @param name defines the name of the mesh to create
  79662. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79663. * @param scene defines the hosting scene
  79664. * @param updatable defines if the mesh must be flagged as updatable
  79665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79666. * @returns a new Mesh
  79667. */
  79668. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79669. /**
  79670. * Creates a ground mesh.
  79671. * Please consider using the same method from the MeshBuilder class instead
  79672. * @param name defines the name of the mesh to create
  79673. * @param width set the width of the ground
  79674. * @param height set the height of the ground
  79675. * @param subdivisions sets the number of subdivisions per side
  79676. * @param scene defines the hosting scene
  79677. * @param updatable defines if the mesh must be flagged as updatable
  79678. * @returns a new Mesh
  79679. */
  79680. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  79681. /**
  79682. * Creates a tiled ground mesh.
  79683. * Please consider using the same method from the MeshBuilder class instead
  79684. * @param name defines the name of the mesh to create
  79685. * @param xmin set the ground minimum X coordinate
  79686. * @param zmin set the ground minimum Y coordinate
  79687. * @param xmax set the ground maximum X coordinate
  79688. * @param zmax set the ground maximum Z coordinate
  79689. * @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
  79690. * @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
  79691. * @param scene defines the hosting scene
  79692. * @param updatable defines if the mesh must be flagged as updatable
  79693. * @returns a new Mesh
  79694. */
  79695. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  79696. w: number;
  79697. h: number;
  79698. }, precision: {
  79699. w: number;
  79700. h: number;
  79701. }, scene: Scene, updatable?: boolean): Mesh;
  79702. /**
  79703. * Creates a ground mesh from a height map.
  79704. * Please consider using the same method from the MeshBuilder class instead
  79705. * @see http://doc.babylonjs.com/babylon101/height_map
  79706. * @param name defines the name of the mesh to create
  79707. * @param url sets the URL of the height map image resource
  79708. * @param width set the ground width size
  79709. * @param height set the ground height size
  79710. * @param subdivisions sets the number of subdivision per side
  79711. * @param minHeight is the minimum altitude on the ground
  79712. * @param maxHeight is the maximum altitude on the ground
  79713. * @param scene defines the hosting scene
  79714. * @param updatable defines if the mesh must be flagged as updatable
  79715. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  79716. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79717. * @returns a new Mesh
  79718. */
  79719. 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;
  79720. /**
  79721. * Creates a tube mesh.
  79722. * The tube is a parametric shape.
  79723. * It has no predefined shape. Its final shape will depend on the input parameters.
  79724. * Please consider using the same method from the MeshBuilder class instead
  79725. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79726. * @param name defines the name of the mesh to create
  79727. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  79728. * @param radius sets the tube radius size
  79729. * @param tessellation is the number of sides on the tubular surface
  79730. * @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
  79731. * @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
  79732. * @param scene defines the hosting scene
  79733. * @param updatable defines if the mesh must be flagged as updatable
  79734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79735. * @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)
  79736. * @returns a new Mesh
  79737. */
  79738. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  79739. (i: number, distance: number): number;
  79740. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79741. /**
  79742. * Creates a polyhedron mesh.
  79743. * Please consider using the same method from the MeshBuilder class instead.
  79744. * * 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
  79745. * * The parameter `size` (positive float, default 1) sets the polygon size
  79746. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79747. * * 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`
  79748. * * 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
  79749. * * 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)`)
  79750. * * 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
  79751. * * 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
  79752. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79753. * * If you create a double-sided mesh, you can choose what parts of 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
  79754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79755. * @param name defines the name of the mesh to create
  79756. * @param options defines the options used to create the mesh
  79757. * @param scene defines the hosting scene
  79758. * @returns a new Mesh
  79759. */
  79760. static CreatePolyhedron(name: string, options: {
  79761. type?: number;
  79762. size?: number;
  79763. sizeX?: number;
  79764. sizeY?: number;
  79765. sizeZ?: number;
  79766. custom?: any;
  79767. faceUV?: Vector4[];
  79768. faceColors?: Color4[];
  79769. updatable?: boolean;
  79770. sideOrientation?: number;
  79771. }, scene: Scene): Mesh;
  79772. /**
  79773. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79774. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79775. * * 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`)
  79776. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79777. * * 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
  79778. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79779. * * If you create a double-sided mesh, you can choose what parts of 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
  79780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79781. * @param name defines the name of the mesh
  79782. * @param options defines the options used to create the mesh
  79783. * @param scene defines the hosting scene
  79784. * @returns a new Mesh
  79785. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79786. */
  79787. static CreateIcoSphere(name: string, options: {
  79788. radius?: number;
  79789. flat?: boolean;
  79790. subdivisions?: number;
  79791. sideOrientation?: number;
  79792. updatable?: boolean;
  79793. }, scene: Scene): Mesh;
  79794. /**
  79795. * Creates a decal mesh.
  79796. * Please consider using the same method from the MeshBuilder class instead.
  79797. * A decal is a mesh usually applied as a model onto the surface of another mesh
  79798. * @param name defines the name of the mesh
  79799. * @param sourceMesh defines the mesh receiving the decal
  79800. * @param position sets the position of the decal in world coordinates
  79801. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  79802. * @param size sets the decal scaling
  79803. * @param angle sets the angle to rotate the decal
  79804. * @returns a new Mesh
  79805. */
  79806. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  79807. /**
  79808. * Prepare internal position array for software CPU skinning
  79809. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  79810. */
  79811. setPositionsForCPUSkinning(): Float32Array;
  79812. /**
  79813. * Prepare internal normal array for software CPU skinning
  79814. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  79815. */
  79816. setNormalsForCPUSkinning(): Float32Array;
  79817. /**
  79818. * Updates the vertex buffer by applying transformation from the bones
  79819. * @param skeleton defines the skeleton to apply to current mesh
  79820. * @returns the current mesh
  79821. */
  79822. applySkeleton(skeleton: Skeleton): Mesh;
  79823. /**
  79824. * 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
  79825. * @param meshes defines the list of meshes to scan
  79826. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  79827. */
  79828. static MinMax(meshes: AbstractMesh[]): {
  79829. min: Vector3;
  79830. max: Vector3;
  79831. };
  79832. /**
  79833. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  79834. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  79835. * @returns a vector3
  79836. */
  79837. static Center(meshesOrMinMaxVector: {
  79838. min: Vector3;
  79839. max: Vector3;
  79840. } | AbstractMesh[]): Vector3;
  79841. /**
  79842. * Merge the array of meshes into a single mesh for performance reasons.
  79843. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  79844. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  79845. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  79846. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  79847. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  79848. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  79849. * @returns a new mesh
  79850. */
  79851. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  79852. /** @hidden */
  79853. addInstance(instance: InstancedMesh): void;
  79854. /** @hidden */
  79855. removeInstance(instance: InstancedMesh): void;
  79856. }
  79857. }
  79858. declare module BABYLON {
  79859. /**
  79860. * Base class for the main features of a material in Babylon.js
  79861. */
  79862. export class Material implements IAnimatable {
  79863. /**
  79864. * Returns the triangle fill mode
  79865. */
  79866. static readonly TriangleFillMode: number;
  79867. /**
  79868. * Returns the wireframe mode
  79869. */
  79870. static readonly WireFrameFillMode: number;
  79871. /**
  79872. * Returns the point fill mode
  79873. */
  79874. static readonly PointFillMode: number;
  79875. /**
  79876. * Returns the point list draw mode
  79877. */
  79878. static readonly PointListDrawMode: number;
  79879. /**
  79880. * Returns the line list draw mode
  79881. */
  79882. static readonly LineListDrawMode: number;
  79883. /**
  79884. * Returns the line loop draw mode
  79885. */
  79886. static readonly LineLoopDrawMode: number;
  79887. /**
  79888. * Returns the line strip draw mode
  79889. */
  79890. static readonly LineStripDrawMode: number;
  79891. /**
  79892. * Returns the triangle strip draw mode
  79893. */
  79894. static readonly TriangleStripDrawMode: number;
  79895. /**
  79896. * Returns the triangle fan draw mode
  79897. */
  79898. static readonly TriangleFanDrawMode: number;
  79899. /**
  79900. * Stores the clock-wise side orientation
  79901. */
  79902. static readonly ClockWiseSideOrientation: number;
  79903. /**
  79904. * Stores the counter clock-wise side orientation
  79905. */
  79906. static readonly CounterClockWiseSideOrientation: number;
  79907. /**
  79908. * The dirty texture flag value
  79909. */
  79910. static readonly TextureDirtyFlag: number;
  79911. /**
  79912. * The dirty light flag value
  79913. */
  79914. static readonly LightDirtyFlag: number;
  79915. /**
  79916. * The dirty fresnel flag value
  79917. */
  79918. static readonly FresnelDirtyFlag: number;
  79919. /**
  79920. * The dirty attribute flag value
  79921. */
  79922. static readonly AttributesDirtyFlag: number;
  79923. /**
  79924. * The dirty misc flag value
  79925. */
  79926. static readonly MiscDirtyFlag: number;
  79927. /**
  79928. * The all dirty flag value
  79929. */
  79930. static readonly AllDirtyFlag: number;
  79931. /**
  79932. * The ID of the material
  79933. */
  79934. id: string;
  79935. /**
  79936. * Gets or sets the unique id of the material
  79937. */
  79938. uniqueId: number;
  79939. /**
  79940. * The name of the material
  79941. */
  79942. name: string;
  79943. /**
  79944. * Gets or sets user defined metadata
  79945. */
  79946. metadata: any;
  79947. /**
  79948. * For internal use only. Please do not use.
  79949. */
  79950. reservedDataStore: any;
  79951. /**
  79952. * Specifies if the ready state should be checked on each call
  79953. */
  79954. checkReadyOnEveryCall: boolean;
  79955. /**
  79956. * Specifies if the ready state should be checked once
  79957. */
  79958. checkReadyOnlyOnce: boolean;
  79959. /**
  79960. * The state of the material
  79961. */
  79962. state: string;
  79963. /**
  79964. * The alpha value of the material
  79965. */
  79966. protected _alpha: number;
  79967. /**
  79968. * List of inspectable custom properties (used by the Inspector)
  79969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79970. */
  79971. inspectableCustomProperties: IInspectable[];
  79972. /**
  79973. * Sets the alpha value of the material
  79974. */
  79975. /**
  79976. * Gets the alpha value of the material
  79977. */
  79978. alpha: number;
  79979. /**
  79980. * Specifies if back face culling is enabled
  79981. */
  79982. protected _backFaceCulling: boolean;
  79983. /**
  79984. * Sets the back-face culling state
  79985. */
  79986. /**
  79987. * Gets the back-face culling state
  79988. */
  79989. backFaceCulling: boolean;
  79990. /**
  79991. * Stores the value for side orientation
  79992. */
  79993. sideOrientation: number;
  79994. /**
  79995. * Callback triggered when the material is compiled
  79996. */
  79997. onCompiled: (effect: Effect) => void;
  79998. /**
  79999. * Callback triggered when an error occurs
  80000. */
  80001. onError: (effect: Effect, errors: string) => void;
  80002. /**
  80003. * Callback triggered to get the render target textures
  80004. */
  80005. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  80006. /**
  80007. * Gets a boolean indicating that current material needs to register RTT
  80008. */
  80009. readonly hasRenderTargetTextures: boolean;
  80010. /**
  80011. * Specifies if the material should be serialized
  80012. */
  80013. doNotSerialize: boolean;
  80014. /**
  80015. * @hidden
  80016. */
  80017. _storeEffectOnSubMeshes: boolean;
  80018. /**
  80019. * Stores the animations for the material
  80020. */
  80021. animations: Array<Animation>;
  80022. /**
  80023. * An event triggered when the material is disposed
  80024. */
  80025. onDisposeObservable: Observable<Material>;
  80026. /**
  80027. * An observer which watches for dispose events
  80028. */
  80029. private _onDisposeObserver;
  80030. private _onUnBindObservable;
  80031. /**
  80032. * Called during a dispose event
  80033. */
  80034. onDispose: () => void;
  80035. private _onBindObservable;
  80036. /**
  80037. * An event triggered when the material is bound
  80038. */
  80039. readonly onBindObservable: Observable<AbstractMesh>;
  80040. /**
  80041. * An observer which watches for bind events
  80042. */
  80043. private _onBindObserver;
  80044. /**
  80045. * Called during a bind event
  80046. */
  80047. onBind: (Mesh: AbstractMesh) => void;
  80048. /**
  80049. * An event triggered when the material is unbound
  80050. */
  80051. readonly onUnBindObservable: Observable<Material>;
  80052. /**
  80053. * Stores the value of the alpha mode
  80054. */
  80055. private _alphaMode;
  80056. /**
  80057. * Sets the value of the alpha mode.
  80058. *
  80059. * | Value | Type | Description |
  80060. * | --- | --- | --- |
  80061. * | 0 | ALPHA_DISABLE | |
  80062. * | 1 | ALPHA_ADD | |
  80063. * | 2 | ALPHA_COMBINE | |
  80064. * | 3 | ALPHA_SUBTRACT | |
  80065. * | 4 | ALPHA_MULTIPLY | |
  80066. * | 5 | ALPHA_MAXIMIZED | |
  80067. * | 6 | ALPHA_ONEONE | |
  80068. * | 7 | ALPHA_PREMULTIPLIED | |
  80069. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80070. * | 9 | ALPHA_INTERPOLATE | |
  80071. * | 10 | ALPHA_SCREENMODE | |
  80072. *
  80073. */
  80074. /**
  80075. * Gets the value of the alpha mode
  80076. */
  80077. alphaMode: number;
  80078. /**
  80079. * Stores the state of the need depth pre-pass value
  80080. */
  80081. private _needDepthPrePass;
  80082. /**
  80083. * Sets the need depth pre-pass value
  80084. */
  80085. /**
  80086. * Gets the depth pre-pass value
  80087. */
  80088. needDepthPrePass: boolean;
  80089. /**
  80090. * Specifies if depth writing should be disabled
  80091. */
  80092. disableDepthWrite: boolean;
  80093. /**
  80094. * Specifies if depth writing should be forced
  80095. */
  80096. forceDepthWrite: boolean;
  80097. /**
  80098. * Specifies if there should be a separate pass for culling
  80099. */
  80100. separateCullingPass: boolean;
  80101. /**
  80102. * Stores the state specifing if fog should be enabled
  80103. */
  80104. private _fogEnabled;
  80105. /**
  80106. * Sets the state for enabling fog
  80107. */
  80108. /**
  80109. * Gets the value of the fog enabled state
  80110. */
  80111. fogEnabled: boolean;
  80112. /**
  80113. * Stores the size of points
  80114. */
  80115. pointSize: number;
  80116. /**
  80117. * Stores the z offset value
  80118. */
  80119. zOffset: number;
  80120. /**
  80121. * Gets a value specifying if wireframe mode is enabled
  80122. */
  80123. /**
  80124. * Sets the state of wireframe mode
  80125. */
  80126. wireframe: boolean;
  80127. /**
  80128. * Gets the value specifying if point clouds are enabled
  80129. */
  80130. /**
  80131. * Sets the state of point cloud mode
  80132. */
  80133. pointsCloud: boolean;
  80134. /**
  80135. * Gets the material fill mode
  80136. */
  80137. /**
  80138. * Sets the material fill mode
  80139. */
  80140. fillMode: number;
  80141. /**
  80142. * @hidden
  80143. * Stores the effects for the material
  80144. */
  80145. _effect: Nullable<Effect>;
  80146. /**
  80147. * @hidden
  80148. * Specifies if the material was previously ready
  80149. */
  80150. _wasPreviouslyReady: boolean;
  80151. /**
  80152. * Specifies if uniform buffers should be used
  80153. */
  80154. private _useUBO;
  80155. /**
  80156. * Stores a reference to the scene
  80157. */
  80158. private _scene;
  80159. /**
  80160. * Stores the fill mode state
  80161. */
  80162. private _fillMode;
  80163. /**
  80164. * Specifies if the depth write state should be cached
  80165. */
  80166. private _cachedDepthWriteState;
  80167. /**
  80168. * Stores the uniform buffer
  80169. */
  80170. protected _uniformBuffer: UniformBuffer;
  80171. /** @hidden */
  80172. _indexInSceneMaterialArray: number;
  80173. /** @hidden */
  80174. meshMap: Nullable<{
  80175. [id: string]: AbstractMesh | undefined;
  80176. }>;
  80177. /**
  80178. * Creates a material instance
  80179. * @param name defines the name of the material
  80180. * @param scene defines the scene to reference
  80181. * @param doNotAdd specifies if the material should be added to the scene
  80182. */
  80183. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80184. /**
  80185. * Returns a string representation of the current material
  80186. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80187. * @returns a string with material information
  80188. */
  80189. toString(fullDetails?: boolean): string;
  80190. /**
  80191. * Gets the class name of the material
  80192. * @returns a string with the class name of the material
  80193. */
  80194. getClassName(): string;
  80195. /**
  80196. * Specifies if updates for the material been locked
  80197. */
  80198. readonly isFrozen: boolean;
  80199. /**
  80200. * Locks updates for the material
  80201. */
  80202. freeze(): void;
  80203. /**
  80204. * Unlocks updates for the material
  80205. */
  80206. unfreeze(): void;
  80207. /**
  80208. * Specifies if the material is ready to be used
  80209. * @param mesh defines the mesh to check
  80210. * @param useInstances specifies if instances should be used
  80211. * @returns a boolean indicating if the material is ready to be used
  80212. */
  80213. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80214. /**
  80215. * Specifies that the submesh is ready to be used
  80216. * @param mesh defines the mesh to check
  80217. * @param subMesh defines which submesh to check
  80218. * @param useInstances specifies that instances should be used
  80219. * @returns a boolean indicating that the submesh is ready or not
  80220. */
  80221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80222. /**
  80223. * Returns the material effect
  80224. * @returns the effect associated with the material
  80225. */
  80226. getEffect(): Nullable<Effect>;
  80227. /**
  80228. * Returns the current scene
  80229. * @returns a Scene
  80230. */
  80231. getScene(): Scene;
  80232. /**
  80233. * Specifies if the material will require alpha blending
  80234. * @returns a boolean specifying if alpha blending is needed
  80235. */
  80236. needAlphaBlending(): boolean;
  80237. /**
  80238. * Specifies if the mesh will require alpha blending
  80239. * @param mesh defines the mesh to check
  80240. * @returns a boolean specifying if alpha blending is needed for the mesh
  80241. */
  80242. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80243. /**
  80244. * Specifies if this material should be rendered in alpha test mode
  80245. * @returns a boolean specifying if an alpha test is needed.
  80246. */
  80247. needAlphaTesting(): boolean;
  80248. /**
  80249. * Gets the texture used for the alpha test
  80250. * @returns the texture to use for alpha testing
  80251. */
  80252. getAlphaTestTexture(): Nullable<BaseTexture>;
  80253. /**
  80254. * Marks the material to indicate that it needs to be re-calculated
  80255. */
  80256. markDirty(): void;
  80257. /** @hidden */
  80258. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80259. /**
  80260. * Binds the material to the mesh
  80261. * @param world defines the world transformation matrix
  80262. * @param mesh defines the mesh to bind the material to
  80263. */
  80264. bind(world: Matrix, mesh?: Mesh): void;
  80265. /**
  80266. * Binds the submesh to the material
  80267. * @param world defines the world transformation matrix
  80268. * @param mesh defines the mesh containing the submesh
  80269. * @param subMesh defines the submesh to bind the material to
  80270. */
  80271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80272. /**
  80273. * Binds the world matrix to the material
  80274. * @param world defines the world transformation matrix
  80275. */
  80276. bindOnlyWorldMatrix(world: Matrix): void;
  80277. /**
  80278. * Binds the scene's uniform buffer to the effect.
  80279. * @param effect defines the effect to bind to the scene uniform buffer
  80280. * @param sceneUbo defines the uniform buffer storing scene data
  80281. */
  80282. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80283. /**
  80284. * Binds the view matrix to the effect
  80285. * @param effect defines the effect to bind the view matrix to
  80286. */
  80287. bindView(effect: Effect): void;
  80288. /**
  80289. * Binds the view projection matrix to the effect
  80290. * @param effect defines the effect to bind the view projection matrix to
  80291. */
  80292. bindViewProjection(effect: Effect): void;
  80293. /**
  80294. * Specifies if material alpha testing should be turned on for the mesh
  80295. * @param mesh defines the mesh to check
  80296. */
  80297. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80298. /**
  80299. * Processes to execute after binding the material to a mesh
  80300. * @param mesh defines the rendered mesh
  80301. */
  80302. protected _afterBind(mesh?: Mesh): void;
  80303. /**
  80304. * Unbinds the material from the mesh
  80305. */
  80306. unbind(): void;
  80307. /**
  80308. * Gets the active textures from the material
  80309. * @returns an array of textures
  80310. */
  80311. getActiveTextures(): BaseTexture[];
  80312. /**
  80313. * Specifies if the material uses a texture
  80314. * @param texture defines the texture to check against the material
  80315. * @returns a boolean specifying if the material uses the texture
  80316. */
  80317. hasTexture(texture: BaseTexture): boolean;
  80318. /**
  80319. * Makes a duplicate of the material, and gives it a new name
  80320. * @param name defines the new name for the duplicated material
  80321. * @returns the cloned material
  80322. */
  80323. clone(name: string): Nullable<Material>;
  80324. /**
  80325. * Gets the meshes bound to the material
  80326. * @returns an array of meshes bound to the material
  80327. */
  80328. getBindedMeshes(): AbstractMesh[];
  80329. /**
  80330. * Force shader compilation
  80331. * @param mesh defines the mesh associated with this material
  80332. * @param onCompiled defines a function to execute once the material is compiled
  80333. * @param options defines the options to configure the compilation
  80334. */
  80335. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80336. clipPlane: boolean;
  80337. }>): void;
  80338. /**
  80339. * Force shader compilation
  80340. * @param mesh defines the mesh that will use this material
  80341. * @param options defines additional options for compiling the shaders
  80342. * @returns a promise that resolves when the compilation completes
  80343. */
  80344. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80345. clipPlane: boolean;
  80346. }>): Promise<void>;
  80347. private static readonly _ImageProcessingDirtyCallBack;
  80348. private static readonly _TextureDirtyCallBack;
  80349. private static readonly _FresnelDirtyCallBack;
  80350. private static readonly _MiscDirtyCallBack;
  80351. private static readonly _LightsDirtyCallBack;
  80352. private static readonly _AttributeDirtyCallBack;
  80353. private static _FresnelAndMiscDirtyCallBack;
  80354. private static _TextureAndMiscDirtyCallBack;
  80355. private static readonly _DirtyCallbackArray;
  80356. private static readonly _RunDirtyCallBacks;
  80357. /**
  80358. * Marks a define in the material to indicate that it needs to be re-computed
  80359. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80360. */
  80361. markAsDirty(flag: number): void;
  80362. /**
  80363. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80364. * @param func defines a function which checks material defines against the submeshes
  80365. */
  80366. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80367. /**
  80368. * Indicates that image processing needs to be re-calculated for all submeshes
  80369. */
  80370. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80371. /**
  80372. * Indicates that textures need to be re-calculated for all submeshes
  80373. */
  80374. protected _markAllSubMeshesAsTexturesDirty(): void;
  80375. /**
  80376. * Indicates that fresnel needs to be re-calculated for all submeshes
  80377. */
  80378. protected _markAllSubMeshesAsFresnelDirty(): void;
  80379. /**
  80380. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80381. */
  80382. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80383. /**
  80384. * Indicates that lights need to be re-calculated for all submeshes
  80385. */
  80386. protected _markAllSubMeshesAsLightsDirty(): void;
  80387. /**
  80388. * Indicates that attributes need to be re-calculated for all submeshes
  80389. */
  80390. protected _markAllSubMeshesAsAttributesDirty(): void;
  80391. /**
  80392. * Indicates that misc needs to be re-calculated for all submeshes
  80393. */
  80394. protected _markAllSubMeshesAsMiscDirty(): void;
  80395. /**
  80396. * Indicates that textures and misc need to be re-calculated for all submeshes
  80397. */
  80398. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80399. /**
  80400. * Disposes the material
  80401. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80402. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80403. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80404. */
  80405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80406. /** @hidden */
  80407. private releaseVertexArrayObject;
  80408. /**
  80409. * Serializes this material
  80410. * @returns the serialized material object
  80411. */
  80412. serialize(): any;
  80413. /**
  80414. * Creates a material from parsed material data
  80415. * @param parsedMaterial defines parsed material data
  80416. * @param scene defines the hosting scene
  80417. * @param rootUrl defines the root URL to use to load textures
  80418. * @returns a new material
  80419. */
  80420. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80421. }
  80422. }
  80423. declare module BABYLON {
  80424. /**
  80425. * Base class for submeshes
  80426. */
  80427. export class BaseSubMesh {
  80428. /** @hidden */
  80429. _materialDefines: Nullable<MaterialDefines>;
  80430. /** @hidden */
  80431. _materialEffect: Nullable<Effect>;
  80432. /**
  80433. * Gets associated effect
  80434. */
  80435. readonly effect: Nullable<Effect>;
  80436. /**
  80437. * Sets associated effect (effect used to render this submesh)
  80438. * @param effect defines the effect to associate with
  80439. * @param defines defines the set of defines used to compile this effect
  80440. */
  80441. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80442. }
  80443. /**
  80444. * Defines a subdivision inside a mesh
  80445. */
  80446. export class SubMesh extends BaseSubMesh implements ICullable {
  80447. /** the material index to use */
  80448. materialIndex: number;
  80449. /** vertex index start */
  80450. verticesStart: number;
  80451. /** vertices count */
  80452. verticesCount: number;
  80453. /** index start */
  80454. indexStart: number;
  80455. /** indices count */
  80456. indexCount: number;
  80457. /** @hidden */
  80458. _linesIndexCount: number;
  80459. private _mesh;
  80460. private _renderingMesh;
  80461. private _boundingInfo;
  80462. private _linesIndexBuffer;
  80463. /** @hidden */
  80464. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80465. /** @hidden */
  80466. _trianglePlanes: Plane[];
  80467. /** @hidden */
  80468. _lastColliderTransformMatrix: Matrix;
  80469. /** @hidden */
  80470. _renderId: number;
  80471. /** @hidden */
  80472. _alphaIndex: number;
  80473. /** @hidden */
  80474. _distanceToCamera: number;
  80475. /** @hidden */
  80476. _id: number;
  80477. private _currentMaterial;
  80478. /**
  80479. * Add a new submesh to a mesh
  80480. * @param materialIndex defines the material index to use
  80481. * @param verticesStart defines vertex index start
  80482. * @param verticesCount defines vertices count
  80483. * @param indexStart defines index start
  80484. * @param indexCount defines indices count
  80485. * @param mesh defines the parent mesh
  80486. * @param renderingMesh defines an optional rendering mesh
  80487. * @param createBoundingBox defines if bounding box should be created for this submesh
  80488. * @returns the new submesh
  80489. */
  80490. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80491. /**
  80492. * Creates a new submesh
  80493. * @param materialIndex defines the material index to use
  80494. * @param verticesStart defines vertex index start
  80495. * @param verticesCount defines vertices count
  80496. * @param indexStart defines index start
  80497. * @param indexCount defines indices count
  80498. * @param mesh defines the parent mesh
  80499. * @param renderingMesh defines an optional rendering mesh
  80500. * @param createBoundingBox defines if bounding box should be created for this submesh
  80501. */
  80502. constructor(
  80503. /** the material index to use */
  80504. materialIndex: number,
  80505. /** vertex index start */
  80506. verticesStart: number,
  80507. /** vertices count */
  80508. verticesCount: number,
  80509. /** index start */
  80510. indexStart: number,
  80511. /** indices count */
  80512. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80513. /**
  80514. * Returns true if this submesh covers the entire parent mesh
  80515. * @ignorenaming
  80516. */
  80517. readonly IsGlobal: boolean;
  80518. /**
  80519. * Returns the submesh BoudingInfo object
  80520. * @returns current bounding info (or mesh's one if the submesh is global)
  80521. */
  80522. getBoundingInfo(): BoundingInfo;
  80523. /**
  80524. * Sets the submesh BoundingInfo
  80525. * @param boundingInfo defines the new bounding info to use
  80526. * @returns the SubMesh
  80527. */
  80528. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80529. /**
  80530. * Returns the mesh of the current submesh
  80531. * @return the parent mesh
  80532. */
  80533. getMesh(): AbstractMesh;
  80534. /**
  80535. * Returns the rendering mesh of the submesh
  80536. * @returns the rendering mesh (could be different from parent mesh)
  80537. */
  80538. getRenderingMesh(): Mesh;
  80539. /**
  80540. * Returns the submesh material
  80541. * @returns null or the current material
  80542. */
  80543. getMaterial(): Nullable<Material>;
  80544. /**
  80545. * Sets a new updated BoundingInfo object to the submesh
  80546. * @returns the SubMesh
  80547. */
  80548. refreshBoundingInfo(): SubMesh;
  80549. /** @hidden */
  80550. _checkCollision(collider: Collider): boolean;
  80551. /**
  80552. * Updates the submesh BoundingInfo
  80553. * @param world defines the world matrix to use to update the bounding info
  80554. * @returns the submesh
  80555. */
  80556. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80557. /**
  80558. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80559. * @param frustumPlanes defines the frustum planes
  80560. * @returns true if the submesh is intersecting with the frustum
  80561. */
  80562. isInFrustum(frustumPlanes: Plane[]): boolean;
  80563. /**
  80564. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80565. * @param frustumPlanes defines the frustum planes
  80566. * @returns true if the submesh is inside the frustum
  80567. */
  80568. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80569. /**
  80570. * Renders the submesh
  80571. * @param enableAlphaMode defines if alpha needs to be used
  80572. * @returns the submesh
  80573. */
  80574. render(enableAlphaMode: boolean): SubMesh;
  80575. /**
  80576. * @hidden
  80577. */
  80578. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80579. /**
  80580. * Checks if the submesh intersects with a ray
  80581. * @param ray defines the ray to test
  80582. * @returns true is the passed ray intersects the submesh bounding box
  80583. */
  80584. canIntersects(ray: Ray): boolean;
  80585. /**
  80586. * Intersects current submesh with a ray
  80587. * @param ray defines the ray to test
  80588. * @param positions defines mesh's positions array
  80589. * @param indices defines mesh's indices array
  80590. * @param fastCheck defines if only bounding info should be used
  80591. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80592. * @returns intersection info or null if no intersection
  80593. */
  80594. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80595. /** @hidden */
  80596. private _intersectLines;
  80597. /** @hidden */
  80598. private _intersectTriangles;
  80599. /** @hidden */
  80600. _rebuild(): void;
  80601. /**
  80602. * Creates a new submesh from the passed mesh
  80603. * @param newMesh defines the new hosting mesh
  80604. * @param newRenderingMesh defines an optional rendering mesh
  80605. * @returns the new submesh
  80606. */
  80607. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80608. /**
  80609. * Release associated resources
  80610. */
  80611. dispose(): void;
  80612. /**
  80613. * Gets the class name
  80614. * @returns the string "SubMesh".
  80615. */
  80616. getClassName(): string;
  80617. /**
  80618. * Creates a new submesh from indices data
  80619. * @param materialIndex the index of the main mesh material
  80620. * @param startIndex the index where to start the copy in the mesh indices array
  80621. * @param indexCount the number of indices to copy then from the startIndex
  80622. * @param mesh the main mesh to create the submesh from
  80623. * @param renderingMesh the optional rendering mesh
  80624. * @returns a new submesh
  80625. */
  80626. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80627. }
  80628. }
  80629. declare module BABYLON {
  80630. /**
  80631. * Class used to store geometry data (vertex buffers + index buffer)
  80632. */
  80633. export class Geometry implements IGetSetVerticesData {
  80634. /**
  80635. * Gets or sets the ID of the geometry
  80636. */
  80637. id: string;
  80638. /**
  80639. * Gets or sets the unique ID of the geometry
  80640. */
  80641. uniqueId: number;
  80642. /**
  80643. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80644. */
  80645. delayLoadState: number;
  80646. /**
  80647. * Gets the file containing the data to load when running in delay load state
  80648. */
  80649. delayLoadingFile: Nullable<string>;
  80650. /**
  80651. * Callback called when the geometry is updated
  80652. */
  80653. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80654. private _scene;
  80655. private _engine;
  80656. private _meshes;
  80657. private _totalVertices;
  80658. /** @hidden */
  80659. _indices: IndicesArray;
  80660. /** @hidden */
  80661. _vertexBuffers: {
  80662. [key: string]: VertexBuffer;
  80663. };
  80664. private _isDisposed;
  80665. private _extend;
  80666. private _boundingBias;
  80667. /** @hidden */
  80668. _delayInfo: Array<string>;
  80669. private _indexBuffer;
  80670. private _indexBufferIsUpdatable;
  80671. /** @hidden */
  80672. _boundingInfo: Nullable<BoundingInfo>;
  80673. /** @hidden */
  80674. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  80675. /** @hidden */
  80676. _softwareSkinningFrameId: number;
  80677. private _vertexArrayObjects;
  80678. private _updatable;
  80679. /** @hidden */
  80680. _positions: Nullable<Vector3[]>;
  80681. /**
  80682. * 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
  80683. */
  80684. /**
  80685. * 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
  80686. */
  80687. boundingBias: Vector2;
  80688. /**
  80689. * Static function used to attach a new empty geometry to a mesh
  80690. * @param mesh defines the mesh to attach the geometry to
  80691. * @returns the new Geometry
  80692. */
  80693. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  80694. /**
  80695. * Creates a new geometry
  80696. * @param id defines the unique ID
  80697. * @param scene defines the hosting scene
  80698. * @param vertexData defines the VertexData used to get geometry data
  80699. * @param updatable defines if geometry must be updatable (false by default)
  80700. * @param mesh defines the mesh that will be associated with the geometry
  80701. */
  80702. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  80703. /**
  80704. * Gets the current extend of the geometry
  80705. */
  80706. readonly extend: {
  80707. minimum: Vector3;
  80708. maximum: Vector3;
  80709. };
  80710. /**
  80711. * Gets the hosting scene
  80712. * @returns the hosting Scene
  80713. */
  80714. getScene(): Scene;
  80715. /**
  80716. * Gets the hosting engine
  80717. * @returns the hosting Engine
  80718. */
  80719. getEngine(): Engine;
  80720. /**
  80721. * Defines if the geometry is ready to use
  80722. * @returns true if the geometry is ready to be used
  80723. */
  80724. isReady(): boolean;
  80725. /**
  80726. * Gets a value indicating that the geometry should not be serialized
  80727. */
  80728. readonly doNotSerialize: boolean;
  80729. /** @hidden */
  80730. _rebuild(): void;
  80731. /**
  80732. * Affects all geometry data in one call
  80733. * @param vertexData defines the geometry data
  80734. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  80735. */
  80736. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  80737. /**
  80738. * Set specific vertex data
  80739. * @param kind defines the data kind (Position, normal, etc...)
  80740. * @param data defines the vertex data to use
  80741. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80742. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80743. */
  80744. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  80745. /**
  80746. * Removes a specific vertex data
  80747. * @param kind defines the data kind (Position, normal, etc...)
  80748. */
  80749. removeVerticesData(kind: string): void;
  80750. /**
  80751. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  80752. * @param buffer defines the vertex buffer to use
  80753. * @param totalVertices defines the total number of vertices for position kind (could be null)
  80754. */
  80755. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  80756. /**
  80757. * Update a specific vertex buffer
  80758. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  80759. * It will do nothing if the buffer is not updatable
  80760. * @param kind defines the data kind (Position, normal, etc...)
  80761. * @param data defines the data to use
  80762. * @param offset defines the offset in the target buffer where to store the data
  80763. * @param useBytes set to true if the offset is in bytes
  80764. */
  80765. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  80766. /**
  80767. * Update a specific vertex buffer
  80768. * This function will create a new buffer if the current one is not updatable
  80769. * @param kind defines the data kind (Position, normal, etc...)
  80770. * @param data defines the data to use
  80771. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  80772. */
  80773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  80774. private _updateBoundingInfo;
  80775. /** @hidden */
  80776. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  80777. /**
  80778. * Gets total number of vertices
  80779. * @returns the total number of vertices
  80780. */
  80781. getTotalVertices(): number;
  80782. /**
  80783. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80784. * @param kind defines the data kind (Position, normal, etc...)
  80785. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80786. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80787. * @returns a float array containing vertex data
  80788. */
  80789. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80790. /**
  80791. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  80792. * @param kind defines the data kind (Position, normal, etc...)
  80793. * @returns true if the vertex buffer with the specified kind is updatable
  80794. */
  80795. isVertexBufferUpdatable(kind: string): boolean;
  80796. /**
  80797. * Gets a specific vertex buffer
  80798. * @param kind defines the data kind (Position, normal, etc...)
  80799. * @returns a VertexBuffer
  80800. */
  80801. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80802. /**
  80803. * Returns all vertex buffers
  80804. * @return an object holding all vertex buffers indexed by kind
  80805. */
  80806. getVertexBuffers(): Nullable<{
  80807. [key: string]: VertexBuffer;
  80808. }>;
  80809. /**
  80810. * Gets a boolean indicating if specific vertex buffer is present
  80811. * @param kind defines the data kind (Position, normal, etc...)
  80812. * @returns true if data is present
  80813. */
  80814. isVerticesDataPresent(kind: string): boolean;
  80815. /**
  80816. * Gets a list of all attached data kinds (Position, normal, etc...)
  80817. * @returns a list of string containing all kinds
  80818. */
  80819. getVerticesDataKinds(): string[];
  80820. /**
  80821. * Update index buffer
  80822. * @param indices defines the indices to store in the index buffer
  80823. * @param offset defines the offset in the target buffer where to store the data
  80824. * @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)
  80825. */
  80826. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  80827. /**
  80828. * Creates a new index buffer
  80829. * @param indices defines the indices to store in the index buffer
  80830. * @param totalVertices defines the total number of vertices (could be null)
  80831. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80832. */
  80833. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  80834. /**
  80835. * Return the total number of indices
  80836. * @returns the total number of indices
  80837. */
  80838. getTotalIndices(): number;
  80839. /**
  80840. * Gets the index buffer array
  80841. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80842. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80843. * @returns the index buffer array
  80844. */
  80845. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80846. /**
  80847. * Gets the index buffer
  80848. * @return the index buffer
  80849. */
  80850. getIndexBuffer(): Nullable<WebGLBuffer>;
  80851. /** @hidden */
  80852. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  80853. /**
  80854. * Release the associated resources for a specific mesh
  80855. * @param mesh defines the source mesh
  80856. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  80857. */
  80858. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  80859. /**
  80860. * Apply current geometry to a given mesh
  80861. * @param mesh defines the mesh to apply geometry to
  80862. */
  80863. applyToMesh(mesh: Mesh): void;
  80864. private _updateExtend;
  80865. private _applyToMesh;
  80866. private notifyUpdate;
  80867. /**
  80868. * Load the geometry if it was flagged as delay loaded
  80869. * @param scene defines the hosting scene
  80870. * @param onLoaded defines a callback called when the geometry is loaded
  80871. */
  80872. load(scene: Scene, onLoaded?: () => void): void;
  80873. private _queueLoad;
  80874. /**
  80875. * Invert the geometry to move from a right handed system to a left handed one.
  80876. */
  80877. toLeftHanded(): void;
  80878. /** @hidden */
  80879. _resetPointsArrayCache(): void;
  80880. /** @hidden */
  80881. _generatePointsArray(): boolean;
  80882. /**
  80883. * Gets a value indicating if the geometry is disposed
  80884. * @returns true if the geometry was disposed
  80885. */
  80886. isDisposed(): boolean;
  80887. private _disposeVertexArrayObjects;
  80888. /**
  80889. * Free all associated resources
  80890. */
  80891. dispose(): void;
  80892. /**
  80893. * Clone the current geometry into a new geometry
  80894. * @param id defines the unique ID of the new geometry
  80895. * @returns a new geometry object
  80896. */
  80897. copy(id: string): Geometry;
  80898. /**
  80899. * Serialize the current geometry info (and not the vertices data) into a JSON object
  80900. * @return a JSON representation of the current geometry data (without the vertices data)
  80901. */
  80902. serialize(): any;
  80903. private toNumberArray;
  80904. /**
  80905. * Serialize all vertices data into a JSON oject
  80906. * @returns a JSON representation of the current geometry data
  80907. */
  80908. serializeVerticeData(): any;
  80909. /**
  80910. * Extracts a clone of a mesh geometry
  80911. * @param mesh defines the source mesh
  80912. * @param id defines the unique ID of the new geometry object
  80913. * @returns the new geometry object
  80914. */
  80915. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  80916. /**
  80917. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  80918. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80919. * Be aware Math.random() could cause collisions, but:
  80920. * "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"
  80921. * @returns a string containing a new GUID
  80922. */
  80923. static RandomId(): string;
  80924. /** @hidden */
  80925. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80926. private static _CleanMatricesWeights;
  80927. /**
  80928. * Create a new geometry from persisted data (Using .babylon file format)
  80929. * @param parsedVertexData defines the persisted data
  80930. * @param scene defines the hosting scene
  80931. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80932. * @returns the new geometry object
  80933. */
  80934. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80935. }
  80936. }
  80937. declare module BABYLON {
  80938. /**
  80939. * Define an interface for all classes that will get and set the data on vertices
  80940. */
  80941. export interface IGetSetVerticesData {
  80942. /**
  80943. * Gets a boolean indicating if specific vertex data is present
  80944. * @param kind defines the vertex data kind to use
  80945. * @returns true is data kind is present
  80946. */
  80947. isVerticesDataPresent(kind: string): boolean;
  80948. /**
  80949. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80950. * @param kind defines the data kind (Position, normal, etc...)
  80951. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80952. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80953. * @returns a float array containing vertex data
  80954. */
  80955. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80956. /**
  80957. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80958. * @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.
  80959. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80960. * @returns the indices array or an empty array if the mesh has no geometry
  80961. */
  80962. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80963. /**
  80964. * Set specific vertex data
  80965. * @param kind defines the data kind (Position, normal, etc...)
  80966. * @param data defines the vertex data to use
  80967. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80968. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80969. */
  80970. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80971. /**
  80972. * Update a specific associated vertex buffer
  80973. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80974. * - VertexBuffer.PositionKind
  80975. * - VertexBuffer.UVKind
  80976. * - VertexBuffer.UV2Kind
  80977. * - VertexBuffer.UV3Kind
  80978. * - VertexBuffer.UV4Kind
  80979. * - VertexBuffer.UV5Kind
  80980. * - VertexBuffer.UV6Kind
  80981. * - VertexBuffer.ColorKind
  80982. * - VertexBuffer.MatricesIndicesKind
  80983. * - VertexBuffer.MatricesIndicesExtraKind
  80984. * - VertexBuffer.MatricesWeightsKind
  80985. * - VertexBuffer.MatricesWeightsExtraKind
  80986. * @param data defines the data source
  80987. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80988. * @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)
  80989. */
  80990. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80991. /**
  80992. * Creates a new index buffer
  80993. * @param indices defines the indices to store in the index buffer
  80994. * @param totalVertices defines the total number of vertices (could be null)
  80995. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80996. */
  80997. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80998. }
  80999. /**
  81000. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  81001. */
  81002. export class VertexData {
  81003. /**
  81004. * Mesh side orientation : usually the external or front surface
  81005. */
  81006. static readonly FRONTSIDE: number;
  81007. /**
  81008. * Mesh side orientation : usually the internal or back surface
  81009. */
  81010. static readonly BACKSIDE: number;
  81011. /**
  81012. * Mesh side orientation : both internal and external or front and back surfaces
  81013. */
  81014. static readonly DOUBLESIDE: number;
  81015. /**
  81016. * Mesh side orientation : by default, `FRONTSIDE`
  81017. */
  81018. static readonly DEFAULTSIDE: number;
  81019. /**
  81020. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  81021. */
  81022. positions: Nullable<FloatArray>;
  81023. /**
  81024. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  81025. */
  81026. normals: Nullable<FloatArray>;
  81027. /**
  81028. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  81029. */
  81030. tangents: Nullable<FloatArray>;
  81031. /**
  81032. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81033. */
  81034. uvs: Nullable<FloatArray>;
  81035. /**
  81036. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81037. */
  81038. uvs2: Nullable<FloatArray>;
  81039. /**
  81040. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81041. */
  81042. uvs3: Nullable<FloatArray>;
  81043. /**
  81044. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81045. */
  81046. uvs4: Nullable<FloatArray>;
  81047. /**
  81048. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81049. */
  81050. uvs5: Nullable<FloatArray>;
  81051. /**
  81052. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  81053. */
  81054. uvs6: Nullable<FloatArray>;
  81055. /**
  81056. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  81057. */
  81058. colors: Nullable<FloatArray>;
  81059. /**
  81060. * 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).
  81061. */
  81062. matricesIndices: Nullable<FloatArray>;
  81063. /**
  81064. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81065. */
  81066. matricesWeights: Nullable<FloatArray>;
  81067. /**
  81068. * An array extending the number of possible indices
  81069. */
  81070. matricesIndicesExtra: Nullable<FloatArray>;
  81071. /**
  81072. * An array extending the number of possible weights when the number of indices is extended
  81073. */
  81074. matricesWeightsExtra: Nullable<FloatArray>;
  81075. /**
  81076. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81077. */
  81078. indices: Nullable<IndicesArray>;
  81079. /**
  81080. * Uses the passed data array to set the set the values for the specified kind of data
  81081. * @param data a linear array of floating numbers
  81082. * @param kind the type of data that is being set, eg positions, colors etc
  81083. */
  81084. set(data: FloatArray, kind: string): void;
  81085. /**
  81086. * Associates the vertexData to the passed Mesh.
  81087. * Sets it as updatable or not (default `false`)
  81088. * @param mesh the mesh the vertexData is applied to
  81089. * @param updatable when used and having the value true allows new data to update the vertexData
  81090. * @returns the VertexData
  81091. */
  81092. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81093. /**
  81094. * Associates the vertexData to the passed Geometry.
  81095. * Sets it as updatable or not (default `false`)
  81096. * @param geometry the geometry the vertexData is applied to
  81097. * @param updatable when used and having the value true allows new data to update the vertexData
  81098. * @returns VertexData
  81099. */
  81100. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81101. /**
  81102. * Updates the associated mesh
  81103. * @param mesh the mesh to be updated
  81104. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81105. * @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
  81106. * @returns VertexData
  81107. */
  81108. updateMesh(mesh: Mesh): VertexData;
  81109. /**
  81110. * Updates the associated geometry
  81111. * @param geometry the geometry to be updated
  81112. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81113. * @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
  81114. * @returns VertexData.
  81115. */
  81116. updateGeometry(geometry: Geometry): VertexData;
  81117. private _applyTo;
  81118. private _update;
  81119. /**
  81120. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81121. * @param matrix the transforming matrix
  81122. * @returns the VertexData
  81123. */
  81124. transform(matrix: Matrix): VertexData;
  81125. /**
  81126. * Merges the passed VertexData into the current one
  81127. * @param other the VertexData to be merged into the current one
  81128. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81129. * @returns the modified VertexData
  81130. */
  81131. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81132. private _mergeElement;
  81133. private _validate;
  81134. /**
  81135. * Serializes the VertexData
  81136. * @returns a serialized object
  81137. */
  81138. serialize(): any;
  81139. /**
  81140. * Extracts the vertexData from a mesh
  81141. * @param mesh the mesh from which to extract the VertexData
  81142. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81143. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81144. * @returns the object VertexData associated to the passed mesh
  81145. */
  81146. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81147. /**
  81148. * Extracts the vertexData from the geometry
  81149. * @param geometry the geometry from which to extract the VertexData
  81150. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81151. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81152. * @returns the object VertexData associated to the passed mesh
  81153. */
  81154. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81155. private static _ExtractFrom;
  81156. /**
  81157. * Creates the VertexData for a Ribbon
  81158. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81159. * * pathArray array of paths, each of which an array of successive Vector3
  81160. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81161. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81162. * * 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
  81163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81164. * * 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)
  81165. * * 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)
  81166. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81167. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81168. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81169. * @returns the VertexData of the ribbon
  81170. */
  81171. static CreateRibbon(options: {
  81172. pathArray: Vector3[][];
  81173. closeArray?: boolean;
  81174. closePath?: boolean;
  81175. offset?: number;
  81176. sideOrientation?: number;
  81177. frontUVs?: Vector4;
  81178. backUVs?: Vector4;
  81179. invertUV?: boolean;
  81180. uvs?: Vector2[];
  81181. colors?: Color4[];
  81182. }): VertexData;
  81183. /**
  81184. * Creates the VertexData for a box
  81185. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81186. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81187. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81188. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81189. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81190. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81191. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81192. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81193. * * 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)
  81194. * * 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)
  81195. * @returns the VertexData of the box
  81196. */
  81197. static CreateBox(options: {
  81198. size?: number;
  81199. width?: number;
  81200. height?: number;
  81201. depth?: number;
  81202. faceUV?: Vector4[];
  81203. faceColors?: Color4[];
  81204. sideOrientation?: number;
  81205. frontUVs?: Vector4;
  81206. backUVs?: Vector4;
  81207. }): VertexData;
  81208. /**
  81209. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81210. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81211. * * segments sets the number of horizontal strips optional, default 32
  81212. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81213. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81214. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81215. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81216. * * 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
  81217. * * 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
  81218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81219. * * 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)
  81220. * * 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)
  81221. * @returns the VertexData of the ellipsoid
  81222. */
  81223. static CreateSphere(options: {
  81224. segments?: number;
  81225. diameter?: number;
  81226. diameterX?: number;
  81227. diameterY?: number;
  81228. diameterZ?: number;
  81229. arc?: number;
  81230. slice?: number;
  81231. sideOrientation?: number;
  81232. frontUVs?: Vector4;
  81233. backUVs?: Vector4;
  81234. }): VertexData;
  81235. /**
  81236. * Creates the VertexData for a cylinder, cone or prism
  81237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81238. * * height sets the height (y direction) of the cylinder, optional, default 2
  81239. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81240. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81241. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81242. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81243. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81244. * * 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
  81245. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81246. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81247. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81248. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81250. * * 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)
  81251. * * 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)
  81252. * @returns the VertexData of the cylinder, cone or prism
  81253. */
  81254. static CreateCylinder(options: {
  81255. height?: number;
  81256. diameterTop?: number;
  81257. diameterBottom?: number;
  81258. diameter?: number;
  81259. tessellation?: number;
  81260. subdivisions?: number;
  81261. arc?: number;
  81262. faceColors?: Color4[];
  81263. faceUV?: Vector4[];
  81264. hasRings?: boolean;
  81265. enclose?: boolean;
  81266. sideOrientation?: number;
  81267. frontUVs?: Vector4;
  81268. backUVs?: Vector4;
  81269. }): VertexData;
  81270. /**
  81271. * Creates the VertexData for a torus
  81272. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81273. * * diameter the diameter of the torus, optional default 1
  81274. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81275. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81277. * * 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)
  81278. * * 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)
  81279. * @returns the VertexData of the torus
  81280. */
  81281. static CreateTorus(options: {
  81282. diameter?: number;
  81283. thickness?: number;
  81284. tessellation?: number;
  81285. sideOrientation?: number;
  81286. frontUVs?: Vector4;
  81287. backUVs?: Vector4;
  81288. }): VertexData;
  81289. /**
  81290. * Creates the VertexData of the LineSystem
  81291. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81292. * - lines an array of lines, each line being an array of successive Vector3
  81293. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81294. * @returns the VertexData of the LineSystem
  81295. */
  81296. static CreateLineSystem(options: {
  81297. lines: Vector3[][];
  81298. colors?: Nullable<Color4[][]>;
  81299. }): VertexData;
  81300. /**
  81301. * Create the VertexData for a DashedLines
  81302. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81303. * - points an array successive Vector3
  81304. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81305. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81306. * - dashNb the intended total number of dashes, optional, default 200
  81307. * @returns the VertexData for the DashedLines
  81308. */
  81309. static CreateDashedLines(options: {
  81310. points: Vector3[];
  81311. dashSize?: number;
  81312. gapSize?: number;
  81313. dashNb?: number;
  81314. }): VertexData;
  81315. /**
  81316. * Creates the VertexData for a Ground
  81317. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81318. * - width the width (x direction) of the ground, optional, default 1
  81319. * - height the height (z direction) of the ground, optional, default 1
  81320. * - subdivisions the number of subdivisions per side, optional, default 1
  81321. * @returns the VertexData of the Ground
  81322. */
  81323. static CreateGround(options: {
  81324. width?: number;
  81325. height?: number;
  81326. subdivisions?: number;
  81327. subdivisionsX?: number;
  81328. subdivisionsY?: number;
  81329. }): VertexData;
  81330. /**
  81331. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81332. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81333. * * xmin the ground minimum X coordinate, optional, default -1
  81334. * * zmin the ground minimum Z coordinate, optional, default -1
  81335. * * xmax the ground maximum X coordinate, optional, default 1
  81336. * * zmax the ground maximum Z coordinate, optional, default 1
  81337. * * 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}
  81338. * * 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}
  81339. * @returns the VertexData of the TiledGround
  81340. */
  81341. static CreateTiledGround(options: {
  81342. xmin: number;
  81343. zmin: number;
  81344. xmax: number;
  81345. zmax: number;
  81346. subdivisions?: {
  81347. w: number;
  81348. h: number;
  81349. };
  81350. precision?: {
  81351. w: number;
  81352. h: number;
  81353. };
  81354. }): VertexData;
  81355. /**
  81356. * Creates the VertexData of the Ground designed from a heightmap
  81357. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81358. * * width the width (x direction) of the ground
  81359. * * height the height (z direction) of the ground
  81360. * * subdivisions the number of subdivisions per side
  81361. * * minHeight the minimum altitude on the ground, optional, default 0
  81362. * * maxHeight the maximum altitude on the ground, optional default 1
  81363. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81364. * * buffer the array holding the image color data
  81365. * * bufferWidth the width of image
  81366. * * bufferHeight the height of image
  81367. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81368. * @returns the VertexData of the Ground designed from a heightmap
  81369. */
  81370. static CreateGroundFromHeightMap(options: {
  81371. width: number;
  81372. height: number;
  81373. subdivisions: number;
  81374. minHeight: number;
  81375. maxHeight: number;
  81376. colorFilter: Color3;
  81377. buffer: Uint8Array;
  81378. bufferWidth: number;
  81379. bufferHeight: number;
  81380. alphaFilter: number;
  81381. }): VertexData;
  81382. /**
  81383. * Creates the VertexData for a Plane
  81384. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81385. * * size sets the width and height of the plane to the value of size, optional default 1
  81386. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81387. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81389. * * 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)
  81390. * * 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)
  81391. * @returns the VertexData of the box
  81392. */
  81393. static CreatePlane(options: {
  81394. size?: number;
  81395. width?: number;
  81396. height?: number;
  81397. sideOrientation?: number;
  81398. frontUVs?: Vector4;
  81399. backUVs?: Vector4;
  81400. }): VertexData;
  81401. /**
  81402. * Creates the VertexData of the Disc or regular Polygon
  81403. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81404. * * radius the radius of the disc, optional default 0.5
  81405. * * tessellation the number of polygon sides, optional, default 64
  81406. * * 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
  81407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81408. * * 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)
  81409. * * 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)
  81410. * @returns the VertexData of the box
  81411. */
  81412. static CreateDisc(options: {
  81413. radius?: number;
  81414. tessellation?: number;
  81415. arc?: number;
  81416. sideOrientation?: number;
  81417. frontUVs?: Vector4;
  81418. backUVs?: Vector4;
  81419. }): VertexData;
  81420. /**
  81421. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81422. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81423. * @param polygon a mesh built from polygonTriangulation.build()
  81424. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81425. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81426. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81427. * @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)
  81428. * @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)
  81429. * @returns the VertexData of the Polygon
  81430. */
  81431. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81432. /**
  81433. * Creates the VertexData of the IcoSphere
  81434. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81435. * * radius the radius of the IcoSphere, optional default 1
  81436. * * radiusX allows stretching in the x direction, optional, default radius
  81437. * * radiusY allows stretching in the y direction, optional, default radius
  81438. * * radiusZ allows stretching in the z direction, optional, default radius
  81439. * * flat when true creates a flat shaded mesh, optional, default true
  81440. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81442. * * 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)
  81443. * * 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)
  81444. * @returns the VertexData of the IcoSphere
  81445. */
  81446. static CreateIcoSphere(options: {
  81447. radius?: number;
  81448. radiusX?: number;
  81449. radiusY?: number;
  81450. radiusZ?: number;
  81451. flat?: boolean;
  81452. subdivisions?: number;
  81453. sideOrientation?: number;
  81454. frontUVs?: Vector4;
  81455. backUVs?: Vector4;
  81456. }): VertexData;
  81457. /**
  81458. * Creates the VertexData for a Polyhedron
  81459. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81460. * * type provided types are:
  81461. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81462. * * 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)
  81463. * * size the size of the IcoSphere, optional default 1
  81464. * * sizeX allows stretching in the x direction, optional, default size
  81465. * * sizeY allows stretching in the y direction, optional, default size
  81466. * * sizeZ allows stretching in the z direction, optional, default size
  81467. * * 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
  81468. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81469. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81470. * * flat when true creates a flat shaded mesh, optional, default true
  81471. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81472. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81473. * * 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)
  81474. * * 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)
  81475. * @returns the VertexData of the Polyhedron
  81476. */
  81477. static CreatePolyhedron(options: {
  81478. type?: number;
  81479. size?: number;
  81480. sizeX?: number;
  81481. sizeY?: number;
  81482. sizeZ?: number;
  81483. custom?: any;
  81484. faceUV?: Vector4[];
  81485. faceColors?: Color4[];
  81486. flat?: boolean;
  81487. sideOrientation?: number;
  81488. frontUVs?: Vector4;
  81489. backUVs?: Vector4;
  81490. }): VertexData;
  81491. /**
  81492. * Creates the VertexData for a TorusKnot
  81493. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81494. * * radius the radius of the torus knot, optional, default 2
  81495. * * tube the thickness of the tube, optional, default 0.5
  81496. * * radialSegments the number of sides on each tube segments, optional, default 32
  81497. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81498. * * p the number of windings around the z axis, optional, default 2
  81499. * * q the number of windings around the x axis, optional, default 3
  81500. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81501. * * 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)
  81502. * * 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)
  81503. * @returns the VertexData of the Torus Knot
  81504. */
  81505. static CreateTorusKnot(options: {
  81506. radius?: number;
  81507. tube?: number;
  81508. radialSegments?: number;
  81509. tubularSegments?: number;
  81510. p?: number;
  81511. q?: number;
  81512. sideOrientation?: number;
  81513. frontUVs?: Vector4;
  81514. backUVs?: Vector4;
  81515. }): VertexData;
  81516. /**
  81517. * Compute normals for given positions and indices
  81518. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81519. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81520. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81521. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81522. * * facetNormals : optional array of facet normals (vector3)
  81523. * * facetPositions : optional array of facet positions (vector3)
  81524. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81525. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81526. * * bInfo : optional bounding info, required for facetPartitioning computation
  81527. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81528. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81529. * * useRightHandedSystem: optional boolean to for right handed system computation
  81530. * * depthSort : optional boolean to enable the facet depth sort computation
  81531. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81532. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81533. */
  81534. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81535. facetNormals?: any;
  81536. facetPositions?: any;
  81537. facetPartitioning?: any;
  81538. ratio?: number;
  81539. bInfo?: any;
  81540. bbSize?: Vector3;
  81541. subDiv?: any;
  81542. useRightHandedSystem?: boolean;
  81543. depthSort?: boolean;
  81544. distanceTo?: Vector3;
  81545. depthSortedFacets?: any;
  81546. }): void;
  81547. /** @hidden */
  81548. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81549. /**
  81550. * Applies VertexData created from the imported parameters to the geometry
  81551. * @param parsedVertexData the parsed data from an imported file
  81552. * @param geometry the geometry to apply the VertexData to
  81553. */
  81554. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81555. }
  81556. }
  81557. declare module BABYLON {
  81558. /**
  81559. * Class containing static functions to help procedurally build meshes
  81560. */
  81561. export class DiscBuilder {
  81562. /**
  81563. * Creates a plane polygonal mesh. By default, this is a disc
  81564. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81565. * * 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
  81566. * * 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
  81567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81570. * @param name defines the name of the mesh
  81571. * @param options defines the options used to create the mesh
  81572. * @param scene defines the hosting scene
  81573. * @returns the plane polygonal mesh
  81574. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81575. */
  81576. static CreateDisc(name: string, options: {
  81577. radius?: number;
  81578. tessellation?: number;
  81579. arc?: number;
  81580. updatable?: boolean;
  81581. sideOrientation?: number;
  81582. frontUVs?: Vector4;
  81583. backUVs?: Vector4;
  81584. }, scene?: Nullable<Scene>): Mesh;
  81585. }
  81586. }
  81587. declare module BABYLON {
  81588. /**
  81589. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81590. *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.
  81591. * The SPS is also a particle system. It provides some methods to manage the particles.
  81592. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81593. *
  81594. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81595. */
  81596. export class SolidParticleSystem implements IDisposable {
  81597. /**
  81598. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81599. * Example : var p = SPS.particles[i];
  81600. */
  81601. particles: SolidParticle[];
  81602. /**
  81603. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81604. */
  81605. nbParticles: number;
  81606. /**
  81607. * If the particles must ever face the camera (default false). Useful for planar particles.
  81608. */
  81609. billboard: boolean;
  81610. /**
  81611. * Recompute normals when adding a shape
  81612. */
  81613. recomputeNormals: boolean;
  81614. /**
  81615. * This a counter ofr your own usage. It's not set by any SPS functions.
  81616. */
  81617. counter: number;
  81618. /**
  81619. * The SPS name. This name is also given to the underlying mesh.
  81620. */
  81621. name: string;
  81622. /**
  81623. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81624. */
  81625. mesh: Mesh;
  81626. /**
  81627. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81628. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81629. */
  81630. vars: any;
  81631. /**
  81632. * This array is populated when the SPS is set as 'pickable'.
  81633. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81634. * Each element of this array is an object `{idx: int, faceId: int}`.
  81635. * `idx` is the picked particle index in the `SPS.particles` array
  81636. * `faceId` is the picked face index counted within this particle.
  81637. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81638. */
  81639. pickedParticles: {
  81640. idx: number;
  81641. faceId: number;
  81642. }[];
  81643. /**
  81644. * This array is populated when `enableDepthSort` is set to true.
  81645. * Each element of this array is an instance of the class DepthSortedParticle.
  81646. */
  81647. depthSortedParticles: DepthSortedParticle[];
  81648. /**
  81649. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81650. * @hidden
  81651. */
  81652. _bSphereOnly: boolean;
  81653. /**
  81654. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81655. * @hidden
  81656. */
  81657. _bSphereRadiusFactor: number;
  81658. private _scene;
  81659. private _positions;
  81660. private _indices;
  81661. private _normals;
  81662. private _colors;
  81663. private _uvs;
  81664. private _indices32;
  81665. private _positions32;
  81666. private _normals32;
  81667. private _fixedNormal32;
  81668. private _colors32;
  81669. private _uvs32;
  81670. private _index;
  81671. private _updatable;
  81672. private _pickable;
  81673. private _isVisibilityBoxLocked;
  81674. private _alwaysVisible;
  81675. private _depthSort;
  81676. private _shapeCounter;
  81677. private _copy;
  81678. private _color;
  81679. private _computeParticleColor;
  81680. private _computeParticleTexture;
  81681. private _computeParticleRotation;
  81682. private _computeParticleVertex;
  81683. private _computeBoundingBox;
  81684. private _depthSortParticles;
  81685. private _camera;
  81686. private _mustUnrotateFixedNormals;
  81687. private _particlesIntersect;
  81688. private _needs32Bits;
  81689. /**
  81690. * Creates a SPS (Solid Particle System) object.
  81691. * @param name (String) is the SPS name, this will be the underlying mesh name.
  81692. * @param scene (Scene) is the scene in which the SPS is added.
  81693. * @param options defines the options of the sps e.g.
  81694. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  81695. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  81696. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  81697. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  81698. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  81699. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  81700. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  81701. */
  81702. constructor(name: string, scene: Scene, options?: {
  81703. updatable?: boolean;
  81704. isPickable?: boolean;
  81705. enableDepthSort?: boolean;
  81706. particleIntersection?: boolean;
  81707. boundingSphereOnly?: boolean;
  81708. bSphereRadiusFactor?: number;
  81709. });
  81710. /**
  81711. * Builds the SPS underlying mesh. Returns a standard Mesh.
  81712. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  81713. * @returns the created mesh
  81714. */
  81715. buildMesh(): Mesh;
  81716. /**
  81717. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  81718. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  81719. * Thus the particles generated from `digest()` have their property `position` set yet.
  81720. * @param mesh ( Mesh ) is the mesh to be digested
  81721. * @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
  81722. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  81723. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  81724. * @returns the current SPS
  81725. */
  81726. digest(mesh: Mesh, options?: {
  81727. facetNb?: number;
  81728. number?: number;
  81729. delta?: number;
  81730. }): SolidParticleSystem;
  81731. private _unrotateFixedNormals;
  81732. private _resetCopy;
  81733. private _meshBuilder;
  81734. private _posToShape;
  81735. private _uvsToShapeUV;
  81736. private _addParticle;
  81737. /**
  81738. * Adds some particles to the SPS from the model shape. Returns the shape id.
  81739. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  81740. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  81741. * @param nb (positive integer) the number of particles to be created from this model
  81742. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  81743. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  81744. * @returns the number of shapes in the system
  81745. */
  81746. addShape(mesh: Mesh, nb: number, options?: {
  81747. positionFunction?: any;
  81748. vertexFunction?: any;
  81749. }): number;
  81750. private _rebuildParticle;
  81751. /**
  81752. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  81753. * @returns the SPS.
  81754. */
  81755. rebuildMesh(): SolidParticleSystem;
  81756. /**
  81757. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  81758. * This method calls `updateParticle()` for each particle of the SPS.
  81759. * For an animated SPS, it is usually called within the render loop.
  81760. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  81761. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  81762. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  81763. * @returns the SPS.
  81764. */
  81765. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  81766. /**
  81767. * Disposes the SPS.
  81768. */
  81769. dispose(): void;
  81770. /**
  81771. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  81772. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81773. * @returns the SPS.
  81774. */
  81775. refreshVisibleSize(): SolidParticleSystem;
  81776. /**
  81777. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  81778. * @param size the size (float) of the visibility box
  81779. * note : this doesn't lock the SPS mesh bounding box.
  81780. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81781. */
  81782. setVisibilityBox(size: number): void;
  81783. /**
  81784. * Gets whether the SPS as always visible or not
  81785. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81786. */
  81787. /**
  81788. * Sets the SPS as always visible or not
  81789. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81790. */
  81791. isAlwaysVisible: boolean;
  81792. /**
  81793. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81794. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81795. */
  81796. /**
  81797. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81798. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81799. */
  81800. isVisibilityBoxLocked: boolean;
  81801. /**
  81802. * Tells to `setParticles()` to compute the particle rotations or not.
  81803. * Default value : true. The SPS is faster when it's set to false.
  81804. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81805. */
  81806. /**
  81807. * Gets if `setParticles()` computes the particle rotations or not.
  81808. * Default value : true. The SPS is faster when it's set to false.
  81809. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81810. */
  81811. computeParticleRotation: boolean;
  81812. /**
  81813. * Tells to `setParticles()` to compute the particle colors or not.
  81814. * Default value : true. The SPS is faster when it's set to false.
  81815. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81816. */
  81817. /**
  81818. * Gets if `setParticles()` computes the particle colors or not.
  81819. * Default value : true. The SPS is faster when it's set to false.
  81820. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81821. */
  81822. computeParticleColor: boolean;
  81823. /**
  81824. * Gets if `setParticles()` computes the particle textures or not.
  81825. * Default value : true. The SPS is faster when it's set to false.
  81826. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  81827. */
  81828. computeParticleTexture: boolean;
  81829. /**
  81830. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  81831. * Default value : false. The SPS is faster when it's set to false.
  81832. * Note : the particle custom vertex positions aren't stored values.
  81833. */
  81834. /**
  81835. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  81836. * Default value : false. The SPS is faster when it's set to false.
  81837. * Note : the particle custom vertex positions aren't stored values.
  81838. */
  81839. computeParticleVertex: boolean;
  81840. /**
  81841. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  81842. */
  81843. /**
  81844. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  81845. */
  81846. computeBoundingBox: boolean;
  81847. /**
  81848. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  81849. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81850. * Default : `true`
  81851. */
  81852. /**
  81853. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  81854. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81855. * Default : `true`
  81856. */
  81857. depthSortParticles: boolean;
  81858. /**
  81859. * This function does nothing. It may be overwritten to set all the particle first values.
  81860. * The SPS doesn't call this function, you may have to call it by your own.
  81861. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81862. */
  81863. initParticles(): void;
  81864. /**
  81865. * This function does nothing. It may be overwritten to recycle a particle.
  81866. * The SPS doesn't call this function, you may have to call it by your own.
  81867. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81868. * @param particle The particle to recycle
  81869. * @returns the recycled particle
  81870. */
  81871. recycleParticle(particle: SolidParticle): SolidParticle;
  81872. /**
  81873. * Updates a particle : this function should be overwritten by the user.
  81874. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  81875. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81876. * @example : just set a particle position or velocity and recycle conditions
  81877. * @param particle The particle to update
  81878. * @returns the updated particle
  81879. */
  81880. updateParticle(particle: SolidParticle): SolidParticle;
  81881. /**
  81882. * Updates a vertex of a particle : it can be overwritten by the user.
  81883. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  81884. * @param particle the current particle
  81885. * @param vertex the current index of the current particle
  81886. * @param pt the index of the current vertex in the particle shape
  81887. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  81888. * @example : just set a vertex particle position
  81889. * @returns the updated vertex
  81890. */
  81891. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  81892. /**
  81893. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  81894. * This does nothing and may be overwritten by the user.
  81895. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81896. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81897. * @param update the boolean update value actually passed to setParticles()
  81898. */
  81899. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81900. /**
  81901. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  81902. * This will be passed three parameters.
  81903. * This does nothing and may be overwritten by the user.
  81904. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81905. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81906. * @param update the boolean update value actually passed to setParticles()
  81907. */
  81908. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81909. }
  81910. }
  81911. declare module BABYLON {
  81912. /**
  81913. * Represents one particle of a solid particle system.
  81914. */
  81915. export class SolidParticle {
  81916. /**
  81917. * particle global index
  81918. */
  81919. idx: number;
  81920. /**
  81921. * The color of the particle
  81922. */
  81923. color: Nullable<Color4>;
  81924. /**
  81925. * The world space position of the particle.
  81926. */
  81927. position: Vector3;
  81928. /**
  81929. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81930. */
  81931. rotation: Vector3;
  81932. /**
  81933. * The world space rotation quaternion of the particle.
  81934. */
  81935. rotationQuaternion: Nullable<Quaternion>;
  81936. /**
  81937. * The scaling of the particle.
  81938. */
  81939. scaling: Vector3;
  81940. /**
  81941. * The uvs of the particle.
  81942. */
  81943. uvs: Vector4;
  81944. /**
  81945. * The current speed of the particle.
  81946. */
  81947. velocity: Vector3;
  81948. /**
  81949. * The pivot point in the particle local space.
  81950. */
  81951. pivot: Vector3;
  81952. /**
  81953. * Must the particle be translated from its pivot point in its local space ?
  81954. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81955. * Default : false
  81956. */
  81957. translateFromPivot: boolean;
  81958. /**
  81959. * Is the particle active or not ?
  81960. */
  81961. alive: boolean;
  81962. /**
  81963. * Is the particle visible or not ?
  81964. */
  81965. isVisible: boolean;
  81966. /**
  81967. * Index of this particle in the global "positions" array (Internal use)
  81968. * @hidden
  81969. */
  81970. _pos: number;
  81971. /**
  81972. * @hidden Index of this particle in the global "indices" array (Internal use)
  81973. */
  81974. _ind: number;
  81975. /**
  81976. * @hidden ModelShape of this particle (Internal use)
  81977. */
  81978. _model: ModelShape;
  81979. /**
  81980. * ModelShape id of this particle
  81981. */
  81982. shapeId: number;
  81983. /**
  81984. * Index of the particle in its shape id (Internal use)
  81985. */
  81986. idxInShape: number;
  81987. /**
  81988. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81989. */
  81990. _modelBoundingInfo: BoundingInfo;
  81991. /**
  81992. * @hidden Particle BoundingInfo object (Internal use)
  81993. */
  81994. _boundingInfo: BoundingInfo;
  81995. /**
  81996. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81997. */
  81998. _sps: SolidParticleSystem;
  81999. /**
  82000. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  82001. */
  82002. _stillInvisible: boolean;
  82003. /**
  82004. * @hidden Last computed particle rotation matrix
  82005. */
  82006. _rotationMatrix: number[];
  82007. /**
  82008. * Parent particle Id, if any.
  82009. * Default null.
  82010. */
  82011. parentId: Nullable<number>;
  82012. /**
  82013. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  82014. * The possible values are :
  82015. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82016. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82017. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82018. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82019. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82020. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  82021. * */
  82022. cullingStrategy: number;
  82023. /**
  82024. * @hidden Internal global position in the SPS.
  82025. */
  82026. _globalPosition: Vector3;
  82027. /**
  82028. * Creates a Solid Particle object.
  82029. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  82030. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  82031. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  82032. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  82033. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  82034. * @param shapeId (integer) is the model shape identifier in the SPS.
  82035. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  82036. * @param sps defines the sps it is associated to
  82037. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  82038. */
  82039. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  82040. /**
  82041. * Legacy support, changed scale to scaling
  82042. */
  82043. /**
  82044. * Legacy support, changed scale to scaling
  82045. */
  82046. scale: Vector3;
  82047. /**
  82048. * Legacy support, changed quaternion to rotationQuaternion
  82049. */
  82050. /**
  82051. * Legacy support, changed quaternion to rotationQuaternion
  82052. */
  82053. quaternion: Nullable<Quaternion>;
  82054. /**
  82055. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  82056. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  82057. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  82058. * @returns true if it intersects
  82059. */
  82060. intersectsMesh(target: Mesh | SolidParticle): boolean;
  82061. /**
  82062. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  82063. * A particle is in the frustum if its bounding box intersects the frustum
  82064. * @param frustumPlanes defines the frustum to test
  82065. * @returns true if the particle is in the frustum planes
  82066. */
  82067. isInFrustum(frustumPlanes: Plane[]): boolean;
  82068. /**
  82069. * get the rotation matrix of the particle
  82070. * @hidden
  82071. */
  82072. getRotationMatrix(m: Matrix): void;
  82073. }
  82074. /**
  82075. * Represents the shape of the model used by one particle of a solid particle system.
  82076. * SPS internal tool, don't use it manually.
  82077. */
  82078. export class ModelShape {
  82079. /**
  82080. * The shape id
  82081. * @hidden
  82082. */
  82083. shapeID: number;
  82084. /**
  82085. * flat array of model positions (internal use)
  82086. * @hidden
  82087. */
  82088. _shape: Vector3[];
  82089. /**
  82090. * flat array of model UVs (internal use)
  82091. * @hidden
  82092. */
  82093. _shapeUV: number[];
  82094. /**
  82095. * length of the shape in the model indices array (internal use)
  82096. * @hidden
  82097. */
  82098. _indicesLength: number;
  82099. /**
  82100. * Custom position function (internal use)
  82101. * @hidden
  82102. */
  82103. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82104. /**
  82105. * Custom vertex function (internal use)
  82106. * @hidden
  82107. */
  82108. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82109. /**
  82110. * 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.
  82111. * SPS internal tool, don't use it manually.
  82112. * @hidden
  82113. */
  82114. 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>);
  82115. }
  82116. /**
  82117. * Represents a Depth Sorted Particle in the solid particle system.
  82118. */
  82119. export class DepthSortedParticle {
  82120. /**
  82121. * Index of the particle in the "indices" array
  82122. */
  82123. ind: number;
  82124. /**
  82125. * Length of the particle shape in the "indices" array
  82126. */
  82127. indicesLength: number;
  82128. /**
  82129. * Squared distance from the particle to the camera
  82130. */
  82131. sqDistance: number;
  82132. }
  82133. }
  82134. declare module BABYLON {
  82135. /**
  82136. * Class used to store all common mesh properties
  82137. */
  82138. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82139. /** No occlusion */
  82140. static OCCLUSION_TYPE_NONE: number;
  82141. /** Occlusion set to optimisitic */
  82142. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82143. /** Occlusion set to strict */
  82144. static OCCLUSION_TYPE_STRICT: number;
  82145. /** Use an accurante occlusion algorithm */
  82146. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82147. /** Use a conservative occlusion algorithm */
  82148. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82149. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82150. * Test order :
  82151. * Is the bounding sphere outside the frustum ?
  82152. * If not, are the bounding box vertices outside the frustum ?
  82153. * It not, then the cullable object is in the frustum.
  82154. */
  82155. static readonly CULLINGSTRATEGY_STANDARD: number;
  82156. /** Culling strategy : Bounding Sphere Only.
  82157. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82158. * It's also less accurate than the standard because some not visible objects can still be selected.
  82159. * Test : is the bounding sphere outside the frustum ?
  82160. * If not, then the cullable object is in the frustum.
  82161. */
  82162. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82163. /** Culling strategy : Optimistic Inclusion.
  82164. * This in an inclusion test first, then the standard exclusion test.
  82165. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82166. * 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.
  82167. * Anyway, it's as accurate as the standard strategy.
  82168. * Test :
  82169. * Is the cullable object bounding sphere center in the frustum ?
  82170. * If not, apply the default culling strategy.
  82171. */
  82172. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82173. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82174. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82175. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82176. * 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.
  82177. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82178. * Test :
  82179. * Is the cullable object bounding sphere center in the frustum ?
  82180. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82181. */
  82182. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82183. /**
  82184. * No billboard
  82185. */
  82186. static readonly BILLBOARDMODE_NONE: number;
  82187. /** Billboard on X axis */
  82188. static readonly BILLBOARDMODE_X: number;
  82189. /** Billboard on Y axis */
  82190. static readonly BILLBOARDMODE_Y: number;
  82191. /** Billboard on Z axis */
  82192. static readonly BILLBOARDMODE_Z: number;
  82193. /** Billboard on all axes */
  82194. static readonly BILLBOARDMODE_ALL: number;
  82195. private _facetData;
  82196. /**
  82197. * The culling strategy to use to check whether the mesh must be rendered or not.
  82198. * This value can be changed at any time and will be used on the next render mesh selection.
  82199. * The possible values are :
  82200. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82201. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82202. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82203. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82204. * Please read each static variable documentation to get details about the culling process.
  82205. * */
  82206. cullingStrategy: number;
  82207. /**
  82208. * Gets the number of facets in the mesh
  82209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82210. */
  82211. readonly facetNb: number;
  82212. /**
  82213. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82215. */
  82216. partitioningSubdivisions: number;
  82217. /**
  82218. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82219. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82221. */
  82222. partitioningBBoxRatio: number;
  82223. /**
  82224. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82225. * Works only for updatable meshes.
  82226. * Doesn't work with multi-materials
  82227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82228. */
  82229. mustDepthSortFacets: boolean;
  82230. /**
  82231. * The location (Vector3) where the facet depth sort must be computed from.
  82232. * By default, the active camera position.
  82233. * Used only when facet depth sort is enabled
  82234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82235. */
  82236. facetDepthSortFrom: Vector3;
  82237. /**
  82238. * gets a boolean indicating if facetData is enabled
  82239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82240. */
  82241. readonly isFacetDataEnabled: boolean;
  82242. /** @hidden */
  82243. _updateNonUniformScalingState(value: boolean): boolean;
  82244. /**
  82245. * An event triggered when this mesh collides with another one
  82246. */
  82247. onCollideObservable: Observable<AbstractMesh>;
  82248. private _onCollideObserver;
  82249. /** Set a function to call when this mesh collides with another one */
  82250. onCollide: () => void;
  82251. /**
  82252. * An event triggered when the collision's position changes
  82253. */
  82254. onCollisionPositionChangeObservable: Observable<Vector3>;
  82255. private _onCollisionPositionChangeObserver;
  82256. /** Set a function to call when the collision's position changes */
  82257. onCollisionPositionChange: () => void;
  82258. /**
  82259. * An event triggered when material is changed
  82260. */
  82261. onMaterialChangedObservable: Observable<AbstractMesh>;
  82262. /**
  82263. * Gets or sets the orientation for POV movement & rotation
  82264. */
  82265. definedFacingForward: boolean;
  82266. /** @hidden */
  82267. _occlusionQuery: Nullable<WebGLQuery>;
  82268. private _visibility;
  82269. /**
  82270. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82271. */
  82272. /**
  82273. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82274. */
  82275. visibility: number;
  82276. /** Gets or sets the alpha index used to sort transparent meshes
  82277. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82278. */
  82279. alphaIndex: number;
  82280. /**
  82281. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82282. */
  82283. isVisible: boolean;
  82284. /**
  82285. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82286. */
  82287. isPickable: boolean;
  82288. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82289. showSubMeshesBoundingBox: boolean;
  82290. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82291. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82292. */
  82293. isBlocker: boolean;
  82294. /**
  82295. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82296. */
  82297. enablePointerMoveEvents: boolean;
  82298. /**
  82299. * Specifies the rendering group id for this mesh (0 by default)
  82300. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82301. */
  82302. renderingGroupId: number;
  82303. private _material;
  82304. /** Gets or sets current material */
  82305. material: Nullable<Material>;
  82306. private _receiveShadows;
  82307. /**
  82308. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82309. * @see http://doc.babylonjs.com/babylon101/shadows
  82310. */
  82311. receiveShadows: boolean;
  82312. /** Defines color to use when rendering outline */
  82313. outlineColor: Color3;
  82314. /** Define width to use when rendering outline */
  82315. outlineWidth: number;
  82316. /** Defines color to use when rendering overlay */
  82317. overlayColor: Color3;
  82318. /** Defines alpha to use when rendering overlay */
  82319. overlayAlpha: number;
  82320. private _hasVertexAlpha;
  82321. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82322. hasVertexAlpha: boolean;
  82323. private _useVertexColors;
  82324. /** 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) */
  82325. useVertexColors: boolean;
  82326. private _computeBonesUsingShaders;
  82327. /**
  82328. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82329. */
  82330. computeBonesUsingShaders: boolean;
  82331. private _numBoneInfluencers;
  82332. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82333. numBoneInfluencers: number;
  82334. private _applyFog;
  82335. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82336. applyFog: boolean;
  82337. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82338. useOctreeForRenderingSelection: boolean;
  82339. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82340. useOctreeForPicking: boolean;
  82341. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82342. useOctreeForCollisions: boolean;
  82343. private _layerMask;
  82344. /**
  82345. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82346. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82347. */
  82348. layerMask: number;
  82349. /**
  82350. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82351. */
  82352. alwaysSelectAsActiveMesh: boolean;
  82353. /**
  82354. * Gets or sets the current action manager
  82355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82356. */
  82357. actionManager: Nullable<AbstractActionManager>;
  82358. private _checkCollisions;
  82359. private _collisionMask;
  82360. private _collisionGroup;
  82361. /**
  82362. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82364. */
  82365. ellipsoid: Vector3;
  82366. /**
  82367. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82369. */
  82370. ellipsoidOffset: Vector3;
  82371. private _collider;
  82372. private _oldPositionForCollisions;
  82373. private _diffPositionForCollisions;
  82374. /**
  82375. * Gets or sets a collision mask used to mask collisions (default is -1).
  82376. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82377. */
  82378. collisionMask: number;
  82379. /**
  82380. * Gets or sets the current collision group mask (-1 by default).
  82381. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82382. */
  82383. collisionGroup: number;
  82384. /**
  82385. * Defines edge width used when edgesRenderer is enabled
  82386. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82387. */
  82388. edgesWidth: number;
  82389. /**
  82390. * Defines edge color used when edgesRenderer is enabled
  82391. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82392. */
  82393. edgesColor: Color4;
  82394. /** @hidden */
  82395. _edgesRenderer: Nullable<IEdgesRenderer>;
  82396. /** @hidden */
  82397. _masterMesh: Nullable<AbstractMesh>;
  82398. /** @hidden */
  82399. _boundingInfo: Nullable<BoundingInfo>;
  82400. /** @hidden */
  82401. _renderId: number;
  82402. /**
  82403. * Gets or sets the list of subMeshes
  82404. * @see http://doc.babylonjs.com/how_to/multi_materials
  82405. */
  82406. subMeshes: SubMesh[];
  82407. /** @hidden */
  82408. _intersectionsInProgress: AbstractMesh[];
  82409. /** @hidden */
  82410. _unIndexed: boolean;
  82411. /** @hidden */
  82412. _lightSources: Light[];
  82413. /** @hidden */
  82414. readonly _positions: Nullable<Vector3[]>;
  82415. /** @hidden */
  82416. _waitingActions: any;
  82417. /** @hidden */
  82418. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82419. private _skeleton;
  82420. /** @hidden */
  82421. _bonesTransformMatrices: Nullable<Float32Array>;
  82422. /**
  82423. * Gets or sets a skeleton to apply skining transformations
  82424. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82425. */
  82426. skeleton: Nullable<Skeleton>;
  82427. /**
  82428. * An event triggered when the mesh is rebuilt.
  82429. */
  82430. onRebuildObservable: Observable<AbstractMesh>;
  82431. /**
  82432. * Creates a new AbstractMesh
  82433. * @param name defines the name of the mesh
  82434. * @param scene defines the hosting scene
  82435. */
  82436. constructor(name: string, scene?: Nullable<Scene>);
  82437. /**
  82438. * Returns the string "AbstractMesh"
  82439. * @returns "AbstractMesh"
  82440. */
  82441. getClassName(): string;
  82442. /**
  82443. * Gets a string representation of the current mesh
  82444. * @param fullDetails defines a boolean indicating if full details must be included
  82445. * @returns a string representation of the current mesh
  82446. */
  82447. toString(fullDetails?: boolean): string;
  82448. /** @hidden */
  82449. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82450. /** @hidden */
  82451. _rebuild(): void;
  82452. /** @hidden */
  82453. _resyncLightSources(): void;
  82454. /** @hidden */
  82455. _resyncLighSource(light: Light): void;
  82456. /** @hidden */
  82457. _unBindEffect(): void;
  82458. /** @hidden */
  82459. _removeLightSource(light: Light): void;
  82460. private _markSubMeshesAsDirty;
  82461. /** @hidden */
  82462. _markSubMeshesAsLightDirty(): void;
  82463. /** @hidden */
  82464. _markSubMeshesAsAttributesDirty(): void;
  82465. /** @hidden */
  82466. _markSubMeshesAsMiscDirty(): void;
  82467. /**
  82468. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82469. */
  82470. scaling: Vector3;
  82471. /**
  82472. * Returns true if the mesh is blocked. Implemented by child classes
  82473. */
  82474. readonly isBlocked: boolean;
  82475. /**
  82476. * Returns the mesh itself by default. Implemented by child classes
  82477. * @param camera defines the camera to use to pick the right LOD level
  82478. * @returns the currentAbstractMesh
  82479. */
  82480. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82481. /**
  82482. * Returns 0 by default. Implemented by child classes
  82483. * @returns an integer
  82484. */
  82485. getTotalVertices(): number;
  82486. /**
  82487. * Returns a positive integer : the total number of indices in this mesh geometry.
  82488. * @returns the numner of indices or zero if the mesh has no geometry.
  82489. */
  82490. getTotalIndices(): number;
  82491. /**
  82492. * Returns null by default. Implemented by child classes
  82493. * @returns null
  82494. */
  82495. getIndices(): Nullable<IndicesArray>;
  82496. /**
  82497. * Returns the array of the requested vertex data kind. Implemented by child classes
  82498. * @param kind defines the vertex data kind to use
  82499. * @returns null
  82500. */
  82501. getVerticesData(kind: string): Nullable<FloatArray>;
  82502. /**
  82503. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82504. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82505. * Note that a new underlying VertexBuffer object is created each call.
  82506. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82507. * @param kind defines vertex data kind:
  82508. * * VertexBuffer.PositionKind
  82509. * * VertexBuffer.UVKind
  82510. * * VertexBuffer.UV2Kind
  82511. * * VertexBuffer.UV3Kind
  82512. * * VertexBuffer.UV4Kind
  82513. * * VertexBuffer.UV5Kind
  82514. * * VertexBuffer.UV6Kind
  82515. * * VertexBuffer.ColorKind
  82516. * * VertexBuffer.MatricesIndicesKind
  82517. * * VertexBuffer.MatricesIndicesExtraKind
  82518. * * VertexBuffer.MatricesWeightsKind
  82519. * * VertexBuffer.MatricesWeightsExtraKind
  82520. * @param data defines the data source
  82521. * @param updatable defines if the data must be flagged as updatable (or static)
  82522. * @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
  82523. * @returns the current mesh
  82524. */
  82525. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82526. /**
  82527. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82528. * If the mesh has no geometry, it is simply returned as it is.
  82529. * @param kind defines vertex data kind:
  82530. * * VertexBuffer.PositionKind
  82531. * * VertexBuffer.UVKind
  82532. * * VertexBuffer.UV2Kind
  82533. * * VertexBuffer.UV3Kind
  82534. * * VertexBuffer.UV4Kind
  82535. * * VertexBuffer.UV5Kind
  82536. * * VertexBuffer.UV6Kind
  82537. * * VertexBuffer.ColorKind
  82538. * * VertexBuffer.MatricesIndicesKind
  82539. * * VertexBuffer.MatricesIndicesExtraKind
  82540. * * VertexBuffer.MatricesWeightsKind
  82541. * * VertexBuffer.MatricesWeightsExtraKind
  82542. * @param data defines the data source
  82543. * @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
  82544. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82545. * @returns the current mesh
  82546. */
  82547. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82548. /**
  82549. * Sets the mesh indices,
  82550. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82551. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82552. * @param totalVertices Defines the total number of vertices
  82553. * @returns the current mesh
  82554. */
  82555. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82556. /**
  82557. * Gets a boolean indicating if specific vertex data is present
  82558. * @param kind defines the vertex data kind to use
  82559. * @returns true is data kind is present
  82560. */
  82561. isVerticesDataPresent(kind: string): boolean;
  82562. /**
  82563. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82564. * @returns a BoundingInfo
  82565. */
  82566. getBoundingInfo(): BoundingInfo;
  82567. /**
  82568. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82569. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82570. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82571. * @returns the current mesh
  82572. */
  82573. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  82574. /**
  82575. * Overwrite the current bounding info
  82576. * @param boundingInfo defines the new bounding info
  82577. * @returns the current mesh
  82578. */
  82579. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82580. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82581. readonly useBones: boolean;
  82582. /** @hidden */
  82583. _preActivate(): void;
  82584. /** @hidden */
  82585. _preActivateForIntermediateRendering(renderId: number): void;
  82586. /** @hidden */
  82587. _activate(renderId: number): void;
  82588. /**
  82589. * Gets the current world matrix
  82590. * @returns a Matrix
  82591. */
  82592. getWorldMatrix(): Matrix;
  82593. /** @hidden */
  82594. _getWorldMatrixDeterminant(): number;
  82595. /**
  82596. * Perform relative position change from the point of view of behind the front of the mesh.
  82597. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82598. * Supports definition of mesh facing forward or backward
  82599. * @param amountRight defines the distance on the right axis
  82600. * @param amountUp defines the distance on the up axis
  82601. * @param amountForward defines the distance on the forward axis
  82602. * @returns the current mesh
  82603. */
  82604. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82605. /**
  82606. * Calculate relative position change from the point of view of behind the front of the mesh.
  82607. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82608. * Supports definition of mesh facing forward or backward
  82609. * @param amountRight defines the distance on the right axis
  82610. * @param amountUp defines the distance on the up axis
  82611. * @param amountForward defines the distance on the forward axis
  82612. * @returns the new displacement vector
  82613. */
  82614. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82615. /**
  82616. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82617. * Supports definition of mesh facing forward or backward
  82618. * @param flipBack defines the flip
  82619. * @param twirlClockwise defines the twirl
  82620. * @param tiltRight defines the tilt
  82621. * @returns the current mesh
  82622. */
  82623. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82624. /**
  82625. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82626. * Supports definition of mesh facing forward or backward.
  82627. * @param flipBack defines the flip
  82628. * @param twirlClockwise defines the twirl
  82629. * @param tiltRight defines the tilt
  82630. * @returns the new rotation vector
  82631. */
  82632. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82633. /**
  82634. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82635. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82636. * @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
  82637. * @returns the new bounding vectors
  82638. */
  82639. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82640. min: Vector3;
  82641. max: Vector3;
  82642. };
  82643. /**
  82644. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82645. * This means the mesh underlying bounding box and sphere are recomputed.
  82646. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82647. * @returns the current mesh
  82648. */
  82649. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82650. /** @hidden */
  82651. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82652. /** @hidden */
  82653. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82654. /** @hidden */
  82655. _updateBoundingInfo(): AbstractMesh;
  82656. /** @hidden */
  82657. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82658. /** @hidden */
  82659. protected _afterComputeWorldMatrix(): void;
  82660. /**
  82661. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82662. * A mesh is in the frustum if its bounding box intersects the frustum
  82663. * @param frustumPlanes defines the frustum to test
  82664. * @returns true if the mesh is in the frustum planes
  82665. */
  82666. isInFrustum(frustumPlanes: Plane[]): boolean;
  82667. /**
  82668. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82669. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82670. * @param frustumPlanes defines the frustum to test
  82671. * @returns true if the mesh is completely in the frustum planes
  82672. */
  82673. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82674. /**
  82675. * True if the mesh intersects another mesh or a SolidParticle object
  82676. * @param mesh defines a target mesh or SolidParticle to test
  82677. * @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)
  82678. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  82679. * @returns true if there is an intersection
  82680. */
  82681. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  82682. /**
  82683. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  82684. * @param point defines the point to test
  82685. * @returns true if there is an intersection
  82686. */
  82687. intersectsPoint(point: Vector3): boolean;
  82688. /**
  82689. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  82690. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82691. */
  82692. checkCollisions: boolean;
  82693. /**
  82694. * Gets Collider object used to compute collisions (not physics)
  82695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82696. */
  82697. readonly collider: Collider;
  82698. /**
  82699. * Move the mesh using collision engine
  82700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82701. * @param displacement defines the requested displacement vector
  82702. * @returns the current mesh
  82703. */
  82704. moveWithCollisions(displacement: Vector3): AbstractMesh;
  82705. private _onCollisionPositionChange;
  82706. /** @hidden */
  82707. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  82708. /** @hidden */
  82709. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  82710. /** @hidden */
  82711. _checkCollision(collider: Collider): AbstractMesh;
  82712. /** @hidden */
  82713. _generatePointsArray(): boolean;
  82714. /**
  82715. * Checks if the passed Ray intersects with the mesh
  82716. * @param ray defines the ray to use
  82717. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82718. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82719. * @returns the picking info
  82720. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82721. */
  82722. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  82723. /**
  82724. * Clones the current mesh
  82725. * @param name defines the mesh name
  82726. * @param newParent defines the new mesh parent
  82727. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82728. * @returns the new mesh
  82729. */
  82730. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  82731. /**
  82732. * Disposes all the submeshes of the current meshnp
  82733. * @returns the current mesh
  82734. */
  82735. releaseSubMeshes(): AbstractMesh;
  82736. /**
  82737. * Releases resources associated with this abstract mesh.
  82738. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82739. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82740. */
  82741. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82742. /**
  82743. * Adds the passed mesh as a child to the current mesh
  82744. * @param mesh defines the child mesh
  82745. * @returns the current mesh
  82746. */
  82747. addChild(mesh: AbstractMesh): AbstractMesh;
  82748. /**
  82749. * Removes the passed mesh from the current mesh children list
  82750. * @param mesh defines the child mesh
  82751. * @returns the current mesh
  82752. */
  82753. removeChild(mesh: AbstractMesh): AbstractMesh;
  82754. /** @hidden */
  82755. private _initFacetData;
  82756. /**
  82757. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82758. * This method can be called within the render loop.
  82759. * 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
  82760. * @returns the current mesh
  82761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82762. */
  82763. updateFacetData(): AbstractMesh;
  82764. /**
  82765. * Returns the facetLocalNormals array.
  82766. * The normals are expressed in the mesh local spac
  82767. * @returns an array of Vector3
  82768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82769. */
  82770. getFacetLocalNormals(): Vector3[];
  82771. /**
  82772. * Returns the facetLocalPositions array.
  82773. * The facet positions are expressed in the mesh local space
  82774. * @returns an array of Vector3
  82775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82776. */
  82777. getFacetLocalPositions(): Vector3[];
  82778. /**
  82779. * Returns the facetLocalPartioning array
  82780. * @returns an array of array of numbers
  82781. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82782. */
  82783. getFacetLocalPartitioning(): number[][];
  82784. /**
  82785. * Returns the i-th facet position in the world system.
  82786. * This method allocates a new Vector3 per call
  82787. * @param i defines the facet index
  82788. * @returns a new Vector3
  82789. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82790. */
  82791. getFacetPosition(i: number): Vector3;
  82792. /**
  82793. * Sets the reference Vector3 with the i-th facet position in the world system
  82794. * @param i defines the facet index
  82795. * @param ref defines the target vector
  82796. * @returns the current mesh
  82797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82798. */
  82799. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  82800. /**
  82801. * Returns the i-th facet normal in the world system.
  82802. * This method allocates a new Vector3 per call
  82803. * @param i defines the facet index
  82804. * @returns a new Vector3
  82805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82806. */
  82807. getFacetNormal(i: number): Vector3;
  82808. /**
  82809. * Sets the reference Vector3 with the i-th facet normal in the world system
  82810. * @param i defines the facet index
  82811. * @param ref defines the target vector
  82812. * @returns the current mesh
  82813. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82814. */
  82815. getFacetNormalToRef(i: number, ref: Vector3): this;
  82816. /**
  82817. * 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)
  82818. * @param x defines x coordinate
  82819. * @param y defines y coordinate
  82820. * @param z defines z coordinate
  82821. * @returns the array of facet indexes
  82822. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82823. */
  82824. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  82825. /**
  82826. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82827. * @param projected sets as the (x,y,z) world projection on the facet
  82828. * @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
  82829. * @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
  82830. * @param x defines x coordinate
  82831. * @param y defines y coordinate
  82832. * @param z defines z coordinate
  82833. * @returns the face index if found (or null instead)
  82834. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82835. */
  82836. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82837. /**
  82838. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82839. * @param projected sets as the (x,y,z) local projection on the facet
  82840. * @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
  82841. * @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
  82842. * @param x defines x coordinate
  82843. * @param y defines y coordinate
  82844. * @param z defines z coordinate
  82845. * @returns the face index if found (or null instead)
  82846. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82847. */
  82848. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82849. /**
  82850. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82851. * @returns the parameters
  82852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82853. */
  82854. getFacetDataParameters(): any;
  82855. /**
  82856. * Disables the feature FacetData and frees the related memory
  82857. * @returns the current mesh
  82858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82859. */
  82860. disableFacetData(): AbstractMesh;
  82861. /**
  82862. * Updates the AbstractMesh indices array
  82863. * @param indices defines the data source
  82864. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82865. * @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)
  82866. * @returns the current mesh
  82867. */
  82868. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  82869. /**
  82870. * Creates new normals data for the mesh
  82871. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82872. * @returns the current mesh
  82873. */
  82874. createNormals(updatable: boolean): AbstractMesh;
  82875. /**
  82876. * Align the mesh with a normal
  82877. * @param normal defines the normal to use
  82878. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82879. * @returns the current mesh
  82880. */
  82881. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  82882. /** @hidden */
  82883. _checkOcclusionQuery(): boolean;
  82884. }
  82885. }
  82886. declare module BABYLON {
  82887. /**
  82888. * Interface used to define ActionEvent
  82889. */
  82890. export interface IActionEvent {
  82891. /** The mesh or sprite that triggered the action */
  82892. source: any;
  82893. /** The X mouse cursor position at the time of the event */
  82894. pointerX: number;
  82895. /** The Y mouse cursor position at the time of the event */
  82896. pointerY: number;
  82897. /** The mesh that is currently pointed at (can be null) */
  82898. meshUnderPointer: Nullable<AbstractMesh>;
  82899. /** the original (browser) event that triggered the ActionEvent */
  82900. sourceEvent?: any;
  82901. /** additional data for the event */
  82902. additionalData?: any;
  82903. }
  82904. /**
  82905. * ActionEvent is the event being sent when an action is triggered.
  82906. */
  82907. export class ActionEvent implements IActionEvent {
  82908. /** The mesh or sprite that triggered the action */
  82909. source: any;
  82910. /** The X mouse cursor position at the time of the event */
  82911. pointerX: number;
  82912. /** The Y mouse cursor position at the time of the event */
  82913. pointerY: number;
  82914. /** The mesh that is currently pointed at (can be null) */
  82915. meshUnderPointer: Nullable<AbstractMesh>;
  82916. /** the original (browser) event that triggered the ActionEvent */
  82917. sourceEvent?: any;
  82918. /** additional data for the event */
  82919. additionalData?: any;
  82920. /**
  82921. * Creates a new ActionEvent
  82922. * @param source The mesh or sprite that triggered the action
  82923. * @param pointerX The X mouse cursor position at the time of the event
  82924. * @param pointerY The Y mouse cursor position at the time of the event
  82925. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82926. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82927. * @param additionalData additional data for the event
  82928. */
  82929. constructor(
  82930. /** The mesh or sprite that triggered the action */
  82931. source: any,
  82932. /** The X mouse cursor position at the time of the event */
  82933. pointerX: number,
  82934. /** The Y mouse cursor position at the time of the event */
  82935. pointerY: number,
  82936. /** The mesh that is currently pointed at (can be null) */
  82937. meshUnderPointer: Nullable<AbstractMesh>,
  82938. /** the original (browser) event that triggered the ActionEvent */
  82939. sourceEvent?: any,
  82940. /** additional data for the event */
  82941. additionalData?: any);
  82942. /**
  82943. * Helper function to auto-create an ActionEvent from a source mesh.
  82944. * @param source The source mesh that triggered the event
  82945. * @param evt The original (browser) event
  82946. * @param additionalData additional data for the event
  82947. * @returns the new ActionEvent
  82948. */
  82949. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82950. /**
  82951. * Helper function to auto-create an ActionEvent from a source sprite
  82952. * @param source The source sprite that triggered the event
  82953. * @param scene Scene associated with the sprite
  82954. * @param evt The original (browser) event
  82955. * @param additionalData additional data for the event
  82956. * @returns the new ActionEvent
  82957. */
  82958. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82959. /**
  82960. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82961. * @param scene the scene where the event occurred
  82962. * @param evt The original (browser) event
  82963. * @returns the new ActionEvent
  82964. */
  82965. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82966. /**
  82967. * Helper function to auto-create an ActionEvent from a primitive
  82968. * @param prim defines the target primitive
  82969. * @param pointerPos defines the pointer position
  82970. * @param evt The original (browser) event
  82971. * @param additionalData additional data for the event
  82972. * @returns the new ActionEvent
  82973. */
  82974. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82975. }
  82976. }
  82977. declare module BABYLON {
  82978. /**
  82979. * Abstract class used to decouple action Manager from scene and meshes.
  82980. * Do not instantiate.
  82981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82982. */
  82983. export abstract class AbstractActionManager implements IDisposable {
  82984. /** Gets the list of active triggers */
  82985. static Triggers: {
  82986. [key: string]: number;
  82987. };
  82988. /** Gets the cursor to use when hovering items */
  82989. hoverCursor: string;
  82990. /** Gets the list of actions */
  82991. actions: IAction[];
  82992. /**
  82993. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82994. */
  82995. isRecursive: boolean;
  82996. /**
  82997. * Releases all associated resources
  82998. */
  82999. abstract dispose(): void;
  83000. /**
  83001. * Does this action manager has pointer triggers
  83002. */
  83003. abstract readonly hasPointerTriggers: boolean;
  83004. /**
  83005. * Does this action manager has pick triggers
  83006. */
  83007. abstract readonly hasPickTriggers: boolean;
  83008. /**
  83009. * Process a specific trigger
  83010. * @param trigger defines the trigger to process
  83011. * @param evt defines the event details to be processed
  83012. */
  83013. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  83014. /**
  83015. * Does this action manager handles actions of any of the given triggers
  83016. * @param triggers defines the triggers to be tested
  83017. * @return a boolean indicating whether one (or more) of the triggers is handled
  83018. */
  83019. abstract hasSpecificTriggers(triggers: number[]): boolean;
  83020. /**
  83021. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  83022. * speed.
  83023. * @param triggerA defines the trigger to be tested
  83024. * @param triggerB defines the trigger to be tested
  83025. * @return a boolean indicating whether one (or more) of the triggers is handled
  83026. */
  83027. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  83028. /**
  83029. * Does this action manager handles actions of a given trigger
  83030. * @param trigger defines the trigger to be tested
  83031. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  83032. * @return whether the trigger is handled
  83033. */
  83034. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  83035. /**
  83036. * Serialize this manager to a JSON object
  83037. * @param name defines the property name to store this manager
  83038. * @returns a JSON representation of this manager
  83039. */
  83040. abstract serialize(name: string): any;
  83041. /**
  83042. * Registers an action to this action manager
  83043. * @param action defines the action to be registered
  83044. * @return the action amended (prepared) after registration
  83045. */
  83046. abstract registerAction(action: IAction): Nullable<IAction>;
  83047. /**
  83048. * Unregisters an action to this action manager
  83049. * @param action defines the action to be unregistered
  83050. * @return a boolean indicating whether the action has been unregistered
  83051. */
  83052. abstract unregisterAction(action: IAction): Boolean;
  83053. /**
  83054. * Does exist one action manager with at least one trigger
  83055. **/
  83056. static readonly HasTriggers: boolean;
  83057. /**
  83058. * Does exist one action manager with at least one pick trigger
  83059. **/
  83060. static readonly HasPickTriggers: boolean;
  83061. /**
  83062. * Does exist one action manager that handles actions of a given trigger
  83063. * @param trigger defines the trigger to be tested
  83064. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83065. **/
  83066. static HasSpecificTrigger(trigger: number): boolean;
  83067. }
  83068. }
  83069. declare module BABYLON {
  83070. /**
  83071. * Defines how a node can be built from a string name.
  83072. */
  83073. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83074. /**
  83075. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83076. */
  83077. export class Node implements IBehaviorAware<Node> {
  83078. /** @hidden */
  83079. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83080. private static _NodeConstructors;
  83081. /**
  83082. * Add a new node constructor
  83083. * @param type defines the type name of the node to construct
  83084. * @param constructorFunc defines the constructor function
  83085. */
  83086. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83087. /**
  83088. * Returns a node constructor based on type name
  83089. * @param type defines the type name
  83090. * @param name defines the new node name
  83091. * @param scene defines the hosting scene
  83092. * @param options defines optional options to transmit to constructors
  83093. * @returns the new constructor or null
  83094. */
  83095. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83096. /**
  83097. * Gets or sets the name of the node
  83098. */
  83099. name: string;
  83100. /**
  83101. * Gets or sets the id of the node
  83102. */
  83103. id: string;
  83104. /**
  83105. * Gets or sets the unique id of the node
  83106. */
  83107. uniqueId: number;
  83108. /**
  83109. * Gets or sets a string used to store user defined state for the node
  83110. */
  83111. state: string;
  83112. /**
  83113. * Gets or sets an object used to store user defined information for the node
  83114. */
  83115. metadata: any;
  83116. /**
  83117. * For internal use only. Please do not use.
  83118. */
  83119. reservedDataStore: any;
  83120. /**
  83121. * List of inspectable custom properties (used by the Inspector)
  83122. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83123. */
  83124. inspectableCustomProperties: IInspectable[];
  83125. /**
  83126. * Gets or sets a boolean used to define if the node must be serialized
  83127. */
  83128. doNotSerialize: boolean;
  83129. /** @hidden */
  83130. _isDisposed: boolean;
  83131. /**
  83132. * Gets a list of Animations associated with the node
  83133. */
  83134. animations: Animation[];
  83135. protected _ranges: {
  83136. [name: string]: Nullable<AnimationRange>;
  83137. };
  83138. /**
  83139. * Callback raised when the node is ready to be used
  83140. */
  83141. onReady: (node: Node) => void;
  83142. private _isEnabled;
  83143. private _isParentEnabled;
  83144. private _isReady;
  83145. /** @hidden */
  83146. _currentRenderId: number;
  83147. private _parentRenderId;
  83148. protected _childRenderId: number;
  83149. /** @hidden */
  83150. _waitingParentId: Nullable<string>;
  83151. /** @hidden */
  83152. _scene: Scene;
  83153. /** @hidden */
  83154. _cache: any;
  83155. private _parentNode;
  83156. private _children;
  83157. /** @hidden */
  83158. _worldMatrix: Matrix;
  83159. /** @hidden */
  83160. _worldMatrixDeterminant: number;
  83161. /** @hidden */
  83162. private _sceneRootNodesIndex;
  83163. /**
  83164. * Gets a boolean indicating if the node has been disposed
  83165. * @returns true if the node was disposed
  83166. */
  83167. isDisposed(): boolean;
  83168. /**
  83169. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83170. * @see https://doc.babylonjs.com/how_to/parenting
  83171. */
  83172. parent: Nullable<Node>;
  83173. private addToSceneRootNodes;
  83174. private removeFromSceneRootNodes;
  83175. private _animationPropertiesOverride;
  83176. /**
  83177. * Gets or sets the animation properties override
  83178. */
  83179. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83180. /**
  83181. * Gets a string idenfifying the name of the class
  83182. * @returns "Node" string
  83183. */
  83184. getClassName(): string;
  83185. /** @hidden */
  83186. readonly _isNode: boolean;
  83187. /**
  83188. * An event triggered when the mesh is disposed
  83189. */
  83190. onDisposeObservable: Observable<Node>;
  83191. private _onDisposeObserver;
  83192. /**
  83193. * Sets a callback that will be raised when the node will be disposed
  83194. */
  83195. onDispose: () => void;
  83196. /**
  83197. * Creates a new Node
  83198. * @param name the name and id to be given to this node
  83199. * @param scene the scene this node will be added to
  83200. * @param addToRootNodes the node will be added to scene.rootNodes
  83201. */
  83202. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83203. /**
  83204. * Gets the scene of the node
  83205. * @returns a scene
  83206. */
  83207. getScene(): Scene;
  83208. /**
  83209. * Gets the engine of the node
  83210. * @returns a Engine
  83211. */
  83212. getEngine(): Engine;
  83213. private _behaviors;
  83214. /**
  83215. * Attach a behavior to the node
  83216. * @see http://doc.babylonjs.com/features/behaviour
  83217. * @param behavior defines the behavior to attach
  83218. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83219. * @returns the current Node
  83220. */
  83221. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83222. /**
  83223. * Remove an attached behavior
  83224. * @see http://doc.babylonjs.com/features/behaviour
  83225. * @param behavior defines the behavior to attach
  83226. * @returns the current Node
  83227. */
  83228. removeBehavior(behavior: Behavior<Node>): Node;
  83229. /**
  83230. * Gets the list of attached behaviors
  83231. * @see http://doc.babylonjs.com/features/behaviour
  83232. */
  83233. readonly behaviors: Behavior<Node>[];
  83234. /**
  83235. * Gets an attached behavior by name
  83236. * @param name defines the name of the behavior to look for
  83237. * @see http://doc.babylonjs.com/features/behaviour
  83238. * @returns null if behavior was not found else the requested behavior
  83239. */
  83240. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83241. /**
  83242. * Returns the latest update of the World matrix
  83243. * @returns a Matrix
  83244. */
  83245. getWorldMatrix(): Matrix;
  83246. /** @hidden */
  83247. _getWorldMatrixDeterminant(): number;
  83248. /**
  83249. * Returns directly the latest state of the mesh World matrix.
  83250. * A Matrix is returned.
  83251. */
  83252. readonly worldMatrixFromCache: Matrix;
  83253. /** @hidden */
  83254. _initCache(): void;
  83255. /** @hidden */
  83256. updateCache(force?: boolean): void;
  83257. /** @hidden */
  83258. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83259. /** @hidden */
  83260. _updateCache(ignoreParentClass?: boolean): void;
  83261. /** @hidden */
  83262. _isSynchronized(): boolean;
  83263. /** @hidden */
  83264. _markSyncedWithParent(): void;
  83265. /** @hidden */
  83266. isSynchronizedWithParent(): boolean;
  83267. /** @hidden */
  83268. isSynchronized(): boolean;
  83269. /**
  83270. * Is this node ready to be used/rendered
  83271. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83272. * @return true if the node is ready
  83273. */
  83274. isReady(completeCheck?: boolean): boolean;
  83275. /**
  83276. * Is this node enabled?
  83277. * 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
  83278. * @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
  83279. * @return whether this node (and its parent) is enabled
  83280. */
  83281. isEnabled(checkAncestors?: boolean): boolean;
  83282. /** @hidden */
  83283. protected _syncParentEnabledState(): void;
  83284. /**
  83285. * Set the enabled state of this node
  83286. * @param value defines the new enabled state
  83287. */
  83288. setEnabled(value: boolean): void;
  83289. /**
  83290. * Is this node a descendant of the given node?
  83291. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83292. * @param ancestor defines the parent node to inspect
  83293. * @returns a boolean indicating if this node is a descendant of the given node
  83294. */
  83295. isDescendantOf(ancestor: Node): boolean;
  83296. /** @hidden */
  83297. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83298. /**
  83299. * Will return all nodes that have this node as ascendant
  83300. * @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
  83301. * @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
  83302. * @return all children nodes of all types
  83303. */
  83304. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83305. /**
  83306. * Get all child-meshes of this node
  83307. * @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)
  83308. * @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
  83309. * @returns an array of AbstractMesh
  83310. */
  83311. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83312. /**
  83313. * Get all direct children of this node
  83314. * @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
  83315. * @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)
  83316. * @returns an array of Node
  83317. */
  83318. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83319. /** @hidden */
  83320. _setReady(state: boolean): void;
  83321. /**
  83322. * Get an animation by name
  83323. * @param name defines the name of the animation to look for
  83324. * @returns null if not found else the requested animation
  83325. */
  83326. getAnimationByName(name: string): Nullable<Animation>;
  83327. /**
  83328. * Creates an animation range for this node
  83329. * @param name defines the name of the range
  83330. * @param from defines the starting key
  83331. * @param to defines the end key
  83332. */
  83333. createAnimationRange(name: string, from: number, to: number): void;
  83334. /**
  83335. * Delete a specific animation range
  83336. * @param name defines the name of the range to delete
  83337. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83338. */
  83339. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83340. /**
  83341. * Get an animation range by name
  83342. * @param name defines the name of the animation range to look for
  83343. * @returns null if not found else the requested animation range
  83344. */
  83345. getAnimationRange(name: string): Nullable<AnimationRange>;
  83346. /**
  83347. * Gets the list of all animation ranges defined on this node
  83348. * @returns an array
  83349. */
  83350. getAnimationRanges(): Nullable<AnimationRange>[];
  83351. /**
  83352. * Will start the animation sequence
  83353. * @param name defines the range frames for animation sequence
  83354. * @param loop defines if the animation should loop (false by default)
  83355. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83356. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83357. * @returns the object created for this animation. If range does not exist, it will return null
  83358. */
  83359. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83360. /**
  83361. * Serialize animation ranges into a JSON compatible object
  83362. * @returns serialization object
  83363. */
  83364. serializeAnimationRanges(): any;
  83365. /**
  83366. * Computes the world matrix of the node
  83367. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83368. * @returns the world matrix
  83369. */
  83370. computeWorldMatrix(force?: boolean): Matrix;
  83371. /**
  83372. * Releases resources associated with this node.
  83373. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83374. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83375. */
  83376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83377. /**
  83378. * Parse animation range data from a serialization object and store them into a given node
  83379. * @param node defines where to store the animation ranges
  83380. * @param parsedNode defines the serialization object to read data from
  83381. * @param scene defines the hosting scene
  83382. */
  83383. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83384. }
  83385. }
  83386. declare module BABYLON {
  83387. /**
  83388. * Class used to store any kind of animation
  83389. */
  83390. export class Animation {
  83391. /**Name of the animation */
  83392. name: string;
  83393. /**Property to animate */
  83394. targetProperty: string;
  83395. /**The frames per second of the animation */
  83396. framePerSecond: number;
  83397. /**The data type of the animation */
  83398. dataType: number;
  83399. /**The loop mode of the animation */
  83400. loopMode?: number | undefined;
  83401. /**Specifies if blending should be enabled */
  83402. enableBlending?: boolean | undefined;
  83403. /**
  83404. * Use matrix interpolation instead of using direct key value when animating matrices
  83405. */
  83406. static AllowMatricesInterpolation: boolean;
  83407. /**
  83408. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83409. */
  83410. static AllowMatrixDecomposeForInterpolation: boolean;
  83411. /**
  83412. * Stores the key frames of the animation
  83413. */
  83414. private _keys;
  83415. /**
  83416. * Stores the easing function of the animation
  83417. */
  83418. private _easingFunction;
  83419. /**
  83420. * @hidden Internal use only
  83421. */
  83422. _runtimeAnimations: RuntimeAnimation[];
  83423. /**
  83424. * The set of event that will be linked to this animation
  83425. */
  83426. private _events;
  83427. /**
  83428. * Stores an array of target property paths
  83429. */
  83430. targetPropertyPath: string[];
  83431. /**
  83432. * Stores the blending speed of the animation
  83433. */
  83434. blendingSpeed: number;
  83435. /**
  83436. * Stores the animation ranges for the animation
  83437. */
  83438. private _ranges;
  83439. /**
  83440. * @hidden Internal use
  83441. */
  83442. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83443. /**
  83444. * Sets up an animation
  83445. * @param property The property to animate
  83446. * @param animationType The animation type to apply
  83447. * @param framePerSecond The frames per second of the animation
  83448. * @param easingFunction The easing function used in the animation
  83449. * @returns The created animation
  83450. */
  83451. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83452. /**
  83453. * Create and start an animation on a node
  83454. * @param name defines the name of the global animation that will be run on all nodes
  83455. * @param node defines the root node where the animation will take place
  83456. * @param targetProperty defines property to animate
  83457. * @param framePerSecond defines the number of frame per second yo use
  83458. * @param totalFrame defines the number of frames in total
  83459. * @param from defines the initial value
  83460. * @param to defines the final value
  83461. * @param loopMode defines which loop mode you want to use (off by default)
  83462. * @param easingFunction defines the easing function to use (linear by default)
  83463. * @param onAnimationEnd defines the callback to call when animation end
  83464. * @returns the animatable created for this animation
  83465. */
  83466. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83467. /**
  83468. * Create and start an animation on a node and its descendants
  83469. * @param name defines the name of the global animation that will be run on all nodes
  83470. * @param node defines the root node where the animation will take place
  83471. * @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
  83472. * @param targetProperty defines property to animate
  83473. * @param framePerSecond defines the number of frame per second to use
  83474. * @param totalFrame defines the number of frames in total
  83475. * @param from defines the initial value
  83476. * @param to defines the final value
  83477. * @param loopMode defines which loop mode you want to use (off by default)
  83478. * @param easingFunction defines the easing function to use (linear by default)
  83479. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83480. * @returns the list of animatables created for all nodes
  83481. * @example https://www.babylonjs-playground.com/#MH0VLI
  83482. */
  83483. 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[]>;
  83484. /**
  83485. * Creates a new animation, merges it with the existing animations and starts it
  83486. * @param name Name of the animation
  83487. * @param node Node which contains the scene that begins the animations
  83488. * @param targetProperty Specifies which property to animate
  83489. * @param framePerSecond The frames per second of the animation
  83490. * @param totalFrame The total number of frames
  83491. * @param from The frame at the beginning of the animation
  83492. * @param to The frame at the end of the animation
  83493. * @param loopMode Specifies the loop mode of the animation
  83494. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83495. * @param onAnimationEnd Callback to run once the animation is complete
  83496. * @returns Nullable animation
  83497. */
  83498. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83499. /**
  83500. * Transition property of an host to the target Value
  83501. * @param property The property to transition
  83502. * @param targetValue The target Value of the property
  83503. * @param host The object where the property to animate belongs
  83504. * @param scene Scene used to run the animation
  83505. * @param frameRate Framerate (in frame/s) to use
  83506. * @param transition The transition type we want to use
  83507. * @param duration The duration of the animation, in milliseconds
  83508. * @param onAnimationEnd Callback trigger at the end of the animation
  83509. * @returns Nullable animation
  83510. */
  83511. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83512. /**
  83513. * Return the array of runtime animations currently using this animation
  83514. */
  83515. readonly runtimeAnimations: RuntimeAnimation[];
  83516. /**
  83517. * Specifies if any of the runtime animations are currently running
  83518. */
  83519. readonly hasRunningRuntimeAnimations: boolean;
  83520. /**
  83521. * Initializes the animation
  83522. * @param name Name of the animation
  83523. * @param targetProperty Property to animate
  83524. * @param framePerSecond The frames per second of the animation
  83525. * @param dataType The data type of the animation
  83526. * @param loopMode The loop mode of the animation
  83527. * @param enableBlending Specifies if blending should be enabled
  83528. */
  83529. constructor(
  83530. /**Name of the animation */
  83531. name: string,
  83532. /**Property to animate */
  83533. targetProperty: string,
  83534. /**The frames per second of the animation */
  83535. framePerSecond: number,
  83536. /**The data type of the animation */
  83537. dataType: number,
  83538. /**The loop mode of the animation */
  83539. loopMode?: number | undefined,
  83540. /**Specifies if blending should be enabled */
  83541. enableBlending?: boolean | undefined);
  83542. /**
  83543. * Converts the animation to a string
  83544. * @param fullDetails support for multiple levels of logging within scene loading
  83545. * @returns String form of the animation
  83546. */
  83547. toString(fullDetails?: boolean): string;
  83548. /**
  83549. * Add an event to this animation
  83550. * @param event Event to add
  83551. */
  83552. addEvent(event: AnimationEvent): void;
  83553. /**
  83554. * Remove all events found at the given frame
  83555. * @param frame The frame to remove events from
  83556. */
  83557. removeEvents(frame: number): void;
  83558. /**
  83559. * Retrieves all the events from the animation
  83560. * @returns Events from the animation
  83561. */
  83562. getEvents(): AnimationEvent[];
  83563. /**
  83564. * Creates an animation range
  83565. * @param name Name of the animation range
  83566. * @param from Starting frame of the animation range
  83567. * @param to Ending frame of the animation
  83568. */
  83569. createRange(name: string, from: number, to: number): void;
  83570. /**
  83571. * Deletes an animation range by name
  83572. * @param name Name of the animation range to delete
  83573. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83574. */
  83575. deleteRange(name: string, deleteFrames?: boolean): void;
  83576. /**
  83577. * Gets the animation range by name, or null if not defined
  83578. * @param name Name of the animation range
  83579. * @returns Nullable animation range
  83580. */
  83581. getRange(name: string): Nullable<AnimationRange>;
  83582. /**
  83583. * Gets the key frames from the animation
  83584. * @returns The key frames of the animation
  83585. */
  83586. getKeys(): Array<IAnimationKey>;
  83587. /**
  83588. * Gets the highest frame rate of the animation
  83589. * @returns Highest frame rate of the animation
  83590. */
  83591. getHighestFrame(): number;
  83592. /**
  83593. * Gets the easing function of the animation
  83594. * @returns Easing function of the animation
  83595. */
  83596. getEasingFunction(): IEasingFunction;
  83597. /**
  83598. * Sets the easing function of the animation
  83599. * @param easingFunction A custom mathematical formula for animation
  83600. */
  83601. setEasingFunction(easingFunction: EasingFunction): void;
  83602. /**
  83603. * Interpolates a scalar linearly
  83604. * @param startValue Start value of the animation curve
  83605. * @param endValue End value of the animation curve
  83606. * @param gradient Scalar amount to interpolate
  83607. * @returns Interpolated scalar value
  83608. */
  83609. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83610. /**
  83611. * Interpolates a scalar cubically
  83612. * @param startValue Start value of the animation curve
  83613. * @param outTangent End tangent of the animation
  83614. * @param endValue End value of the animation curve
  83615. * @param inTangent Start tangent of the animation curve
  83616. * @param gradient Scalar amount to interpolate
  83617. * @returns Interpolated scalar value
  83618. */
  83619. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83620. /**
  83621. * Interpolates a quaternion using a spherical linear interpolation
  83622. * @param startValue Start value of the animation curve
  83623. * @param endValue End value of the animation curve
  83624. * @param gradient Scalar amount to interpolate
  83625. * @returns Interpolated quaternion value
  83626. */
  83627. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83628. /**
  83629. * Interpolates a quaternion cubically
  83630. * @param startValue Start value of the animation curve
  83631. * @param outTangent End tangent of the animation curve
  83632. * @param endValue End value of the animation curve
  83633. * @param inTangent Start tangent of the animation curve
  83634. * @param gradient Scalar amount to interpolate
  83635. * @returns Interpolated quaternion value
  83636. */
  83637. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83638. /**
  83639. * Interpolates a Vector3 linearl
  83640. * @param startValue Start value of the animation curve
  83641. * @param endValue End value of the animation curve
  83642. * @param gradient Scalar amount to interpolate
  83643. * @returns Interpolated scalar value
  83644. */
  83645. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83646. /**
  83647. * Interpolates a Vector3 cubically
  83648. * @param startValue Start value of the animation curve
  83649. * @param outTangent End tangent of the animation
  83650. * @param endValue End value of the animation curve
  83651. * @param inTangent Start tangent of the animation curve
  83652. * @param gradient Scalar amount to interpolate
  83653. * @returns InterpolatedVector3 value
  83654. */
  83655. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83656. /**
  83657. * Interpolates a Vector2 linearly
  83658. * @param startValue Start value of the animation curve
  83659. * @param endValue End value of the animation curve
  83660. * @param gradient Scalar amount to interpolate
  83661. * @returns Interpolated Vector2 value
  83662. */
  83663. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  83664. /**
  83665. * Interpolates a Vector2 cubically
  83666. * @param startValue Start value of the animation curve
  83667. * @param outTangent End tangent of the animation
  83668. * @param endValue End value of the animation curve
  83669. * @param inTangent Start tangent of the animation curve
  83670. * @param gradient Scalar amount to interpolate
  83671. * @returns Interpolated Vector2 value
  83672. */
  83673. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  83674. /**
  83675. * Interpolates a size linearly
  83676. * @param startValue Start value of the animation curve
  83677. * @param endValue End value of the animation curve
  83678. * @param gradient Scalar amount to interpolate
  83679. * @returns Interpolated Size value
  83680. */
  83681. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  83682. /**
  83683. * Interpolates a Color3 linearly
  83684. * @param startValue Start value of the animation curve
  83685. * @param endValue End value of the animation curve
  83686. * @param gradient Scalar amount to interpolate
  83687. * @returns Interpolated Color3 value
  83688. */
  83689. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  83690. /**
  83691. * @hidden Internal use only
  83692. */
  83693. _getKeyValue(value: any): any;
  83694. /**
  83695. * @hidden Internal use only
  83696. */
  83697. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  83698. /**
  83699. * Defines the function to use to interpolate matrices
  83700. * @param startValue defines the start matrix
  83701. * @param endValue defines the end matrix
  83702. * @param gradient defines the gradient between both matrices
  83703. * @param result defines an optional target matrix where to store the interpolation
  83704. * @returns the interpolated matrix
  83705. */
  83706. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  83707. /**
  83708. * Makes a copy of the animation
  83709. * @returns Cloned animation
  83710. */
  83711. clone(): Animation;
  83712. /**
  83713. * Sets the key frames of the animation
  83714. * @param values The animation key frames to set
  83715. */
  83716. setKeys(values: Array<IAnimationKey>): void;
  83717. /**
  83718. * Serializes the animation to an object
  83719. * @returns Serialized object
  83720. */
  83721. serialize(): any;
  83722. /**
  83723. * Float animation type
  83724. */
  83725. private static _ANIMATIONTYPE_FLOAT;
  83726. /**
  83727. * Vector3 animation type
  83728. */
  83729. private static _ANIMATIONTYPE_VECTOR3;
  83730. /**
  83731. * Quaternion animation type
  83732. */
  83733. private static _ANIMATIONTYPE_QUATERNION;
  83734. /**
  83735. * Matrix animation type
  83736. */
  83737. private static _ANIMATIONTYPE_MATRIX;
  83738. /**
  83739. * Color3 animation type
  83740. */
  83741. private static _ANIMATIONTYPE_COLOR3;
  83742. /**
  83743. * Vector2 animation type
  83744. */
  83745. private static _ANIMATIONTYPE_VECTOR2;
  83746. /**
  83747. * Size animation type
  83748. */
  83749. private static _ANIMATIONTYPE_SIZE;
  83750. /**
  83751. * Relative Loop Mode
  83752. */
  83753. private static _ANIMATIONLOOPMODE_RELATIVE;
  83754. /**
  83755. * Cycle Loop Mode
  83756. */
  83757. private static _ANIMATIONLOOPMODE_CYCLE;
  83758. /**
  83759. * Constant Loop Mode
  83760. */
  83761. private static _ANIMATIONLOOPMODE_CONSTANT;
  83762. /**
  83763. * Get the float animation type
  83764. */
  83765. static readonly ANIMATIONTYPE_FLOAT: number;
  83766. /**
  83767. * Get the Vector3 animation type
  83768. */
  83769. static readonly ANIMATIONTYPE_VECTOR3: number;
  83770. /**
  83771. * Get the Vector2 animation type
  83772. */
  83773. static readonly ANIMATIONTYPE_VECTOR2: number;
  83774. /**
  83775. * Get the Size animation type
  83776. */
  83777. static readonly ANIMATIONTYPE_SIZE: number;
  83778. /**
  83779. * Get the Quaternion animation type
  83780. */
  83781. static readonly ANIMATIONTYPE_QUATERNION: number;
  83782. /**
  83783. * Get the Matrix animation type
  83784. */
  83785. static readonly ANIMATIONTYPE_MATRIX: number;
  83786. /**
  83787. * Get the Color3 animation type
  83788. */
  83789. static readonly ANIMATIONTYPE_COLOR3: number;
  83790. /**
  83791. * Get the Relative Loop Mode
  83792. */
  83793. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  83794. /**
  83795. * Get the Cycle Loop Mode
  83796. */
  83797. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  83798. /**
  83799. * Get the Constant Loop Mode
  83800. */
  83801. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  83802. /** @hidden */
  83803. static _UniversalLerp(left: any, right: any, amount: number): any;
  83804. /**
  83805. * Parses an animation object and creates an animation
  83806. * @param parsedAnimation Parsed animation object
  83807. * @returns Animation object
  83808. */
  83809. static Parse(parsedAnimation: any): Animation;
  83810. /**
  83811. * Appends the serialized animations from the source animations
  83812. * @param source Source containing the animations
  83813. * @param destination Target to store the animations
  83814. */
  83815. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  83816. }
  83817. }
  83818. declare module BABYLON {
  83819. /**
  83820. * Base class of all the textures in babylon.
  83821. * It groups all the common properties the materials, post process, lights... might need
  83822. * in order to make a correct use of the texture.
  83823. */
  83824. export class BaseTexture implements IAnimatable {
  83825. /**
  83826. * Default anisotropic filtering level for the application.
  83827. * It is set to 4 as a good tradeoff between perf and quality.
  83828. */
  83829. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  83830. /**
  83831. * Gets or sets the unique id of the texture
  83832. */
  83833. uniqueId: number;
  83834. /**
  83835. * Define the name of the texture.
  83836. */
  83837. name: string;
  83838. /**
  83839. * Gets or sets an object used to store user defined information.
  83840. */
  83841. metadata: any;
  83842. /**
  83843. * For internal use only. Please do not use.
  83844. */
  83845. reservedDataStore: any;
  83846. private _hasAlpha;
  83847. /**
  83848. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  83849. */
  83850. hasAlpha: boolean;
  83851. /**
  83852. * Defines if the alpha value should be determined via the rgb values.
  83853. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  83854. */
  83855. getAlphaFromRGB: boolean;
  83856. /**
  83857. * Intensity or strength of the texture.
  83858. * It is commonly used by materials to fine tune the intensity of the texture
  83859. */
  83860. level: number;
  83861. /**
  83862. * Define the UV chanel to use starting from 0 and defaulting to 0.
  83863. * This is part of the texture as textures usually maps to one uv set.
  83864. */
  83865. coordinatesIndex: number;
  83866. private _coordinatesMode;
  83867. /**
  83868. * How a texture is mapped.
  83869. *
  83870. * | Value | Type | Description |
  83871. * | ----- | ----------------------------------- | ----------- |
  83872. * | 0 | EXPLICIT_MODE | |
  83873. * | 1 | SPHERICAL_MODE | |
  83874. * | 2 | PLANAR_MODE | |
  83875. * | 3 | CUBIC_MODE | |
  83876. * | 4 | PROJECTION_MODE | |
  83877. * | 5 | SKYBOX_MODE | |
  83878. * | 6 | INVCUBIC_MODE | |
  83879. * | 7 | EQUIRECTANGULAR_MODE | |
  83880. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  83881. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  83882. */
  83883. coordinatesMode: number;
  83884. /**
  83885. * | Value | Type | Description |
  83886. * | ----- | ------------------ | ----------- |
  83887. * | 0 | CLAMP_ADDRESSMODE | |
  83888. * | 1 | WRAP_ADDRESSMODE | |
  83889. * | 2 | MIRROR_ADDRESSMODE | |
  83890. */
  83891. wrapU: number;
  83892. /**
  83893. * | Value | Type | Description |
  83894. * | ----- | ------------------ | ----------- |
  83895. * | 0 | CLAMP_ADDRESSMODE | |
  83896. * | 1 | WRAP_ADDRESSMODE | |
  83897. * | 2 | MIRROR_ADDRESSMODE | |
  83898. */
  83899. wrapV: number;
  83900. /**
  83901. * | Value | Type | Description |
  83902. * | ----- | ------------------ | ----------- |
  83903. * | 0 | CLAMP_ADDRESSMODE | |
  83904. * | 1 | WRAP_ADDRESSMODE | |
  83905. * | 2 | MIRROR_ADDRESSMODE | |
  83906. */
  83907. wrapR: number;
  83908. /**
  83909. * With compliant hardware and browser (supporting anisotropic filtering)
  83910. * this defines the level of anisotropic filtering in the texture.
  83911. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83912. */
  83913. anisotropicFilteringLevel: number;
  83914. /**
  83915. * Define if the texture is a cube texture or if false a 2d texture.
  83916. */
  83917. isCube: boolean;
  83918. /**
  83919. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83920. */
  83921. is3D: boolean;
  83922. /**
  83923. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  83924. * HDR texture are usually stored in linear space.
  83925. * This only impacts the PBR and Background materials
  83926. */
  83927. gammaSpace: boolean;
  83928. /**
  83929. * Gets whether or not the texture contains RGBD data.
  83930. */
  83931. readonly isRGBD: boolean;
  83932. /**
  83933. * Is Z inverted in the texture (useful in a cube texture).
  83934. */
  83935. invertZ: boolean;
  83936. /**
  83937. * Are mip maps generated for this texture or not.
  83938. */
  83939. readonly noMipmap: boolean;
  83940. /**
  83941. * @hidden
  83942. */
  83943. lodLevelInAlpha: boolean;
  83944. /**
  83945. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83946. */
  83947. lodGenerationOffset: number;
  83948. /**
  83949. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83950. */
  83951. lodGenerationScale: number;
  83952. /**
  83953. * Define if the texture is a render target.
  83954. */
  83955. isRenderTarget: boolean;
  83956. /**
  83957. * Define the unique id of the texture in the scene.
  83958. */
  83959. readonly uid: string;
  83960. /**
  83961. * Return a string representation of the texture.
  83962. * @returns the texture as a string
  83963. */
  83964. toString(): string;
  83965. /**
  83966. * Get the class name of the texture.
  83967. * @returns "BaseTexture"
  83968. */
  83969. getClassName(): string;
  83970. /**
  83971. * Define the list of animation attached to the texture.
  83972. */
  83973. animations: Animation[];
  83974. /**
  83975. * An event triggered when the texture is disposed.
  83976. */
  83977. onDisposeObservable: Observable<BaseTexture>;
  83978. private _onDisposeObserver;
  83979. /**
  83980. * Callback triggered when the texture has been disposed.
  83981. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83982. */
  83983. onDispose: () => void;
  83984. /**
  83985. * Define the current state of the loading sequence when in delayed load mode.
  83986. */
  83987. delayLoadState: number;
  83988. private _scene;
  83989. /** @hidden */
  83990. _texture: Nullable<InternalTexture>;
  83991. private _uid;
  83992. /**
  83993. * Define if the texture is preventinga material to render or not.
  83994. * If not and the texture is not ready, the engine will use a default black texture instead.
  83995. */
  83996. readonly isBlocking: boolean;
  83997. /**
  83998. * Instantiates a new BaseTexture.
  83999. * Base class of all the textures in babylon.
  84000. * It groups all the common properties the materials, post process, lights... might need
  84001. * in order to make a correct use of the texture.
  84002. * @param scene Define the scene the texture blongs to
  84003. */
  84004. constructor(scene: Nullable<Scene>);
  84005. /**
  84006. * Get the scene the texture belongs to.
  84007. * @returns the scene or null if undefined
  84008. */
  84009. getScene(): Nullable<Scene>;
  84010. /**
  84011. * Get the texture transform matrix used to offset tile the texture for istance.
  84012. * @returns the transformation matrix
  84013. */
  84014. getTextureMatrix(): Matrix;
  84015. /**
  84016. * Get the texture reflection matrix used to rotate/transform the reflection.
  84017. * @returns the reflection matrix
  84018. */
  84019. getReflectionTextureMatrix(): Matrix;
  84020. /**
  84021. * Get the underlying lower level texture from Babylon.
  84022. * @returns the insternal texture
  84023. */
  84024. getInternalTexture(): Nullable<InternalTexture>;
  84025. /**
  84026. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  84027. * @returns true if ready or not blocking
  84028. */
  84029. isReadyOrNotBlocking(): boolean;
  84030. /**
  84031. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  84032. * @returns true if fully ready
  84033. */
  84034. isReady(): boolean;
  84035. private _cachedSize;
  84036. /**
  84037. * Get the size of the texture.
  84038. * @returns the texture size.
  84039. */
  84040. getSize(): ISize;
  84041. /**
  84042. * Get the base size of the texture.
  84043. * It can be different from the size if the texture has been resized for POT for instance
  84044. * @returns the base size
  84045. */
  84046. getBaseSize(): ISize;
  84047. /**
  84048. * Update the sampling mode of the texture.
  84049. * Default is Trilinear mode.
  84050. *
  84051. * | Value | Type | Description |
  84052. * | ----- | ------------------ | ----------- |
  84053. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  84054. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  84055. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  84056. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  84057. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  84058. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  84059. * | 7 | NEAREST_LINEAR | |
  84060. * | 8 | NEAREST_NEAREST | |
  84061. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  84062. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  84063. * | 11 | LINEAR_LINEAR | |
  84064. * | 12 | LINEAR_NEAREST | |
  84065. *
  84066. * > _mag_: magnification filter (close to the viewer)
  84067. * > _min_: minification filter (far from the viewer)
  84068. * > _mip_: filter used between mip map levels
  84069. *@param samplingMode Define the new sampling mode of the texture
  84070. */
  84071. updateSamplingMode(samplingMode: number): void;
  84072. /**
  84073. * Scales the texture if is `canRescale()`
  84074. * @param ratio the resize factor we want to use to rescale
  84075. */
  84076. scale(ratio: number): void;
  84077. /**
  84078. * Get if the texture can rescale.
  84079. */
  84080. readonly canRescale: boolean;
  84081. /** @hidden */
  84082. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84083. /** @hidden */
  84084. _rebuild(): void;
  84085. /**
  84086. * Triggers the load sequence in delayed load mode.
  84087. */
  84088. delayLoad(): void;
  84089. /**
  84090. * Clones the texture.
  84091. * @returns the cloned texture
  84092. */
  84093. clone(): Nullable<BaseTexture>;
  84094. /**
  84095. * Get the texture underlying type (INT, FLOAT...)
  84096. */
  84097. readonly textureType: number;
  84098. /**
  84099. * Get the texture underlying format (RGB, RGBA...)
  84100. */
  84101. readonly textureFormat: number;
  84102. /**
  84103. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84104. * This will returns an RGBA array buffer containing either in values (0-255) or
  84105. * float values (0-1) depending of the underlying buffer type.
  84106. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84107. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84108. * @param buffer defines a user defined buffer to fill with data (can be null)
  84109. * @returns The Array buffer containing the pixels data.
  84110. */
  84111. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84112. /**
  84113. * Release and destroy the underlying lower level texture aka internalTexture.
  84114. */
  84115. releaseInternalTexture(): void;
  84116. /**
  84117. * Get the polynomial representation of the texture data.
  84118. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84119. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84120. */
  84121. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84122. /** @hidden */
  84123. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84124. /** @hidden */
  84125. readonly _lodTextureMid: Nullable<BaseTexture>;
  84126. /** @hidden */
  84127. readonly _lodTextureLow: Nullable<BaseTexture>;
  84128. /**
  84129. * Dispose the texture and release its associated resources.
  84130. */
  84131. dispose(): void;
  84132. /**
  84133. * Serialize the texture into a JSON representation that can be parsed later on.
  84134. * @returns the JSON representation of the texture
  84135. */
  84136. serialize(): any;
  84137. /**
  84138. * Helper function to be called back once a list of texture contains only ready textures.
  84139. * @param textures Define the list of textures to wait for
  84140. * @param callback Define the callback triggered once the entire list will be ready
  84141. */
  84142. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84143. }
  84144. }
  84145. declare module BABYLON {
  84146. /**
  84147. * Uniform buffer objects.
  84148. *
  84149. * Handles blocks of uniform on the GPU.
  84150. *
  84151. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84152. *
  84153. * For more information, please refer to :
  84154. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84155. */
  84156. export class UniformBuffer {
  84157. private _engine;
  84158. private _buffer;
  84159. private _data;
  84160. private _bufferData;
  84161. private _dynamic?;
  84162. private _uniformLocations;
  84163. private _uniformSizes;
  84164. private _uniformLocationPointer;
  84165. private _needSync;
  84166. private _noUBO;
  84167. private _currentEffect;
  84168. private static _MAX_UNIFORM_SIZE;
  84169. private static _tempBuffer;
  84170. /**
  84171. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84172. * This is dynamic to allow compat with webgl 1 and 2.
  84173. * You will need to pass the name of the uniform as well as the value.
  84174. */
  84175. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84176. /**
  84177. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84178. * This is dynamic to allow compat with webgl 1 and 2.
  84179. * You will need to pass the name of the uniform as well as the value.
  84180. */
  84181. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84182. /**
  84183. * Lambda to Update a single float in a uniform buffer.
  84184. * This is dynamic to allow compat with webgl 1 and 2.
  84185. * You will need to pass the name of the uniform as well as the value.
  84186. */
  84187. updateFloat: (name: string, x: number) => void;
  84188. /**
  84189. * Lambda to Update a vec2 of float in a uniform buffer.
  84190. * This is dynamic to allow compat with webgl 1 and 2.
  84191. * You will need to pass the name of the uniform as well as the value.
  84192. */
  84193. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84194. /**
  84195. * Lambda to Update a vec3 of float in a uniform buffer.
  84196. * This is dynamic to allow compat with webgl 1 and 2.
  84197. * You will need to pass the name of the uniform as well as the value.
  84198. */
  84199. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84200. /**
  84201. * Lambda to Update a vec4 of float in a uniform buffer.
  84202. * This is dynamic to allow compat with webgl 1 and 2.
  84203. * You will need to pass the name of the uniform as well as the value.
  84204. */
  84205. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84206. /**
  84207. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84208. * This is dynamic to allow compat with webgl 1 and 2.
  84209. * You will need to pass the name of the uniform as well as the value.
  84210. */
  84211. updateMatrix: (name: string, mat: Matrix) => void;
  84212. /**
  84213. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84214. * This is dynamic to allow compat with webgl 1 and 2.
  84215. * You will need to pass the name of the uniform as well as the value.
  84216. */
  84217. updateVector3: (name: string, vector: Vector3) => void;
  84218. /**
  84219. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84220. * This is dynamic to allow compat with webgl 1 and 2.
  84221. * You will need to pass the name of the uniform as well as the value.
  84222. */
  84223. updateVector4: (name: string, vector: Vector4) => void;
  84224. /**
  84225. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84226. * This is dynamic to allow compat with webgl 1 and 2.
  84227. * You will need to pass the name of the uniform as well as the value.
  84228. */
  84229. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84230. /**
  84231. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84232. * This is dynamic to allow compat with webgl 1 and 2.
  84233. * You will need to pass the name of the uniform as well as the value.
  84234. */
  84235. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84236. /**
  84237. * Instantiates a new Uniform buffer objects.
  84238. *
  84239. * Handles blocks of uniform on the GPU.
  84240. *
  84241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84242. *
  84243. * For more information, please refer to :
  84244. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84245. * @param engine Define the engine the buffer is associated with
  84246. * @param data Define the data contained in the buffer
  84247. * @param dynamic Define if the buffer is updatable
  84248. */
  84249. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84250. /**
  84251. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84252. * or just falling back on setUniformXXX calls.
  84253. */
  84254. readonly useUbo: boolean;
  84255. /**
  84256. * Indicates if the WebGL underlying uniform buffer is in sync
  84257. * with the javascript cache data.
  84258. */
  84259. readonly isSync: boolean;
  84260. /**
  84261. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84262. * Also, a dynamic UniformBuffer will disable cache verification and always
  84263. * update the underlying WebGL uniform buffer to the GPU.
  84264. * @returns if Dynamic, otherwise false
  84265. */
  84266. isDynamic(): boolean;
  84267. /**
  84268. * The data cache on JS side.
  84269. * @returns the underlying data as a float array
  84270. */
  84271. getData(): Float32Array;
  84272. /**
  84273. * The underlying WebGL Uniform buffer.
  84274. * @returns the webgl buffer
  84275. */
  84276. getBuffer(): Nullable<WebGLBuffer>;
  84277. /**
  84278. * std140 layout specifies how to align data within an UBO structure.
  84279. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84280. * for specs.
  84281. */
  84282. private _fillAlignment;
  84283. /**
  84284. * Adds an uniform in the buffer.
  84285. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84286. * for the layout to be correct !
  84287. * @param name Name of the uniform, as used in the uniform block in the shader.
  84288. * @param size Data size, or data directly.
  84289. */
  84290. addUniform(name: string, size: number | number[]): void;
  84291. /**
  84292. * Adds a Matrix 4x4 to the uniform buffer.
  84293. * @param name Name of the uniform, as used in the uniform block in the shader.
  84294. * @param mat A 4x4 matrix.
  84295. */
  84296. addMatrix(name: string, mat: Matrix): void;
  84297. /**
  84298. * Adds a vec2 to the uniform buffer.
  84299. * @param name Name of the uniform, as used in the uniform block in the shader.
  84300. * @param x Define the x component value of the vec2
  84301. * @param y Define the y component value of the vec2
  84302. */
  84303. addFloat2(name: string, x: number, y: number): void;
  84304. /**
  84305. * Adds a vec3 to the uniform buffer.
  84306. * @param name Name of the uniform, as used in the uniform block in the shader.
  84307. * @param x Define the x component value of the vec3
  84308. * @param y Define the y component value of the vec3
  84309. * @param z Define the z component value of the vec3
  84310. */
  84311. addFloat3(name: string, x: number, y: number, z: number): void;
  84312. /**
  84313. * Adds a vec3 to the uniform buffer.
  84314. * @param name Name of the uniform, as used in the uniform block in the shader.
  84315. * @param color Define the vec3 from a Color
  84316. */
  84317. addColor3(name: string, color: Color3): void;
  84318. /**
  84319. * Adds a vec4 to the uniform buffer.
  84320. * @param name Name of the uniform, as used in the uniform block in the shader.
  84321. * @param color Define the rgb components from a Color
  84322. * @param alpha Define the a component of the vec4
  84323. */
  84324. addColor4(name: string, color: Color3, alpha: number): void;
  84325. /**
  84326. * Adds a vec3 to the uniform buffer.
  84327. * @param name Name of the uniform, as used in the uniform block in the shader.
  84328. * @param vector Define the vec3 components from a Vector
  84329. */
  84330. addVector3(name: string, vector: Vector3): void;
  84331. /**
  84332. * Adds a Matrix 3x3 to the uniform buffer.
  84333. * @param name Name of the uniform, as used in the uniform block in the shader.
  84334. */
  84335. addMatrix3x3(name: string): void;
  84336. /**
  84337. * Adds a Matrix 2x2 to the uniform buffer.
  84338. * @param name Name of the uniform, as used in the uniform block in the shader.
  84339. */
  84340. addMatrix2x2(name: string): void;
  84341. /**
  84342. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84343. */
  84344. create(): void;
  84345. /** @hidden */
  84346. _rebuild(): void;
  84347. /**
  84348. * Updates the WebGL Uniform Buffer on the GPU.
  84349. * If the `dynamic` flag is set to true, no cache comparison is done.
  84350. * Otherwise, the buffer will be updated only if the cache differs.
  84351. */
  84352. update(): void;
  84353. /**
  84354. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84355. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84356. * @param data Define the flattened data
  84357. * @param size Define the size of the data.
  84358. */
  84359. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84360. private _updateMatrix3x3ForUniform;
  84361. private _updateMatrix3x3ForEffect;
  84362. private _updateMatrix2x2ForEffect;
  84363. private _updateMatrix2x2ForUniform;
  84364. private _updateFloatForEffect;
  84365. private _updateFloatForUniform;
  84366. private _updateFloat2ForEffect;
  84367. private _updateFloat2ForUniform;
  84368. private _updateFloat3ForEffect;
  84369. private _updateFloat3ForUniform;
  84370. private _updateFloat4ForEffect;
  84371. private _updateFloat4ForUniform;
  84372. private _updateMatrixForEffect;
  84373. private _updateMatrixForUniform;
  84374. private _updateVector3ForEffect;
  84375. private _updateVector3ForUniform;
  84376. private _updateVector4ForEffect;
  84377. private _updateVector4ForUniform;
  84378. private _updateColor3ForEffect;
  84379. private _updateColor3ForUniform;
  84380. private _updateColor4ForEffect;
  84381. private _updateColor4ForUniform;
  84382. /**
  84383. * Sets a sampler uniform on the effect.
  84384. * @param name Define the name of the sampler.
  84385. * @param texture Define the texture to set in the sampler
  84386. */
  84387. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84388. /**
  84389. * Directly updates the value of the uniform in the cache AND on the GPU.
  84390. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84391. * @param data Define the flattened data
  84392. */
  84393. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84394. /**
  84395. * Binds this uniform buffer to an effect.
  84396. * @param effect Define the effect to bind the buffer to
  84397. * @param name Name of the uniform block in the shader.
  84398. */
  84399. bindToEffect(effect: Effect, name: string): void;
  84400. /**
  84401. * Disposes the uniform buffer.
  84402. */
  84403. dispose(): void;
  84404. }
  84405. }
  84406. declare module BABYLON {
  84407. /**
  84408. * This represents the required contract to create a new type of texture loader.
  84409. */
  84410. export interface IInternalTextureLoader {
  84411. /**
  84412. * Defines wether the loader supports cascade loading the different faces.
  84413. */
  84414. supportCascades: boolean;
  84415. /**
  84416. * This returns if the loader support the current file information.
  84417. * @param extension defines the file extension of the file being loaded
  84418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84419. * @param fallback defines the fallback internal texture if any
  84420. * @param isBase64 defines whether the texture is encoded as a base64
  84421. * @param isBuffer defines whether the texture data are stored as a buffer
  84422. * @returns true if the loader can load the specified file
  84423. */
  84424. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84425. /**
  84426. * Transform the url before loading if required.
  84427. * @param rootUrl the url of the texture
  84428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84429. * @returns the transformed texture
  84430. */
  84431. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84432. /**
  84433. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84434. * @param rootUrl the url of the texture
  84435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84436. * @returns the fallback texture
  84437. */
  84438. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84439. /**
  84440. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84441. * @param data contains the texture data
  84442. * @param texture defines the BabylonJS internal texture
  84443. * @param createPolynomials will be true if polynomials have been requested
  84444. * @param onLoad defines the callback to trigger once the texture is ready
  84445. * @param onError defines the callback to trigger in case of error
  84446. */
  84447. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84448. /**
  84449. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84450. * @param data contains the texture data
  84451. * @param texture defines the BabylonJS internal texture
  84452. * @param callback defines the method to call once ready to upload
  84453. */
  84454. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84455. }
  84456. }
  84457. declare module BABYLON {
  84458. /**
  84459. * Creation options of the multi render target texture.
  84460. */
  84461. export interface IMultiRenderTargetOptions {
  84462. /**
  84463. * Define if the texture needs to create mip maps after render.
  84464. */
  84465. generateMipMaps?: boolean;
  84466. /**
  84467. * Define the types of all the draw buffers we want to create
  84468. */
  84469. types?: number[];
  84470. /**
  84471. * Define the sampling modes of all the draw buffers we want to create
  84472. */
  84473. samplingModes?: number[];
  84474. /**
  84475. * Define if a depth buffer is required
  84476. */
  84477. generateDepthBuffer?: boolean;
  84478. /**
  84479. * Define if a stencil buffer is required
  84480. */
  84481. generateStencilBuffer?: boolean;
  84482. /**
  84483. * Define if a depth texture is required instead of a depth buffer
  84484. */
  84485. generateDepthTexture?: boolean;
  84486. /**
  84487. * Define the number of desired draw buffers
  84488. */
  84489. textureCount?: number;
  84490. /**
  84491. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84492. */
  84493. doNotChangeAspectRatio?: boolean;
  84494. /**
  84495. * Define the default type of the buffers we are creating
  84496. */
  84497. defaultType?: number;
  84498. }
  84499. /**
  84500. * A multi render target, like a render target provides the ability to render to a texture.
  84501. * Unlike the render target, it can render to several draw buffers in one draw.
  84502. * This is specially interesting in deferred rendering or for any effects requiring more than
  84503. * just one color from a single pass.
  84504. */
  84505. export class MultiRenderTarget extends RenderTargetTexture {
  84506. private _internalTextures;
  84507. private _textures;
  84508. private _multiRenderTargetOptions;
  84509. /**
  84510. * Get if draw buffers are currently supported by the used hardware and browser.
  84511. */
  84512. readonly isSupported: boolean;
  84513. /**
  84514. * Get the list of textures generated by the multi render target.
  84515. */
  84516. readonly textures: Texture[];
  84517. /**
  84518. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84519. */
  84520. readonly depthTexture: Texture;
  84521. /**
  84522. * Set the wrapping mode on U of all the textures we are rendering to.
  84523. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84524. */
  84525. wrapU: number;
  84526. /**
  84527. * Set the wrapping mode on V of all the textures we are rendering to.
  84528. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84529. */
  84530. wrapV: number;
  84531. /**
  84532. * Instantiate a new multi render target texture.
  84533. * A multi render target, like a render target provides the ability to render to a texture.
  84534. * Unlike the render target, it can render to several draw buffers in one draw.
  84535. * This is specially interesting in deferred rendering or for any effects requiring more than
  84536. * just one color from a single pass.
  84537. * @param name Define the name of the texture
  84538. * @param size Define the size of the buffers to render to
  84539. * @param count Define the number of target we are rendering into
  84540. * @param scene Define the scene the texture belongs to
  84541. * @param options Define the options used to create the multi render target
  84542. */
  84543. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84544. /** @hidden */
  84545. _rebuild(): void;
  84546. private _createInternalTextures;
  84547. private _createTextures;
  84548. /**
  84549. * Define the number of samples used if MSAA is enabled.
  84550. */
  84551. samples: number;
  84552. /**
  84553. * Resize all the textures in the multi render target.
  84554. * Be carrefull as it will recreate all the data in the new texture.
  84555. * @param size Define the new size
  84556. */
  84557. resize(size: any): void;
  84558. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84559. /**
  84560. * Dispose the render targets and their associated resources
  84561. */
  84562. dispose(): void;
  84563. /**
  84564. * Release all the underlying texture used as draw buffers.
  84565. */
  84566. releaseInternalTextures(): void;
  84567. }
  84568. }
  84569. declare module BABYLON {
  84570. /**
  84571. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84573. */
  84574. export class Analyser {
  84575. /**
  84576. * Gets or sets the smoothing
  84577. * @ignorenaming
  84578. */
  84579. SMOOTHING: number;
  84580. /**
  84581. * Gets or sets the FFT table size
  84582. * @ignorenaming
  84583. */
  84584. FFT_SIZE: number;
  84585. /**
  84586. * Gets or sets the bar graph amplitude
  84587. * @ignorenaming
  84588. */
  84589. BARGRAPHAMPLITUDE: number;
  84590. /**
  84591. * Gets or sets the position of the debug canvas
  84592. * @ignorenaming
  84593. */
  84594. DEBUGCANVASPOS: {
  84595. x: number;
  84596. y: number;
  84597. };
  84598. /**
  84599. * Gets or sets the debug canvas size
  84600. * @ignorenaming
  84601. */
  84602. DEBUGCANVASSIZE: {
  84603. width: number;
  84604. height: number;
  84605. };
  84606. private _byteFreqs;
  84607. private _byteTime;
  84608. private _floatFreqs;
  84609. private _webAudioAnalyser;
  84610. private _debugCanvas;
  84611. private _debugCanvasContext;
  84612. private _scene;
  84613. private _registerFunc;
  84614. private _audioEngine;
  84615. /**
  84616. * Creates a new analyser
  84617. * @param scene defines hosting scene
  84618. */
  84619. constructor(scene: Scene);
  84620. /**
  84621. * Get the number of data values you will have to play with for the visualization
  84622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84623. * @returns a number
  84624. */
  84625. getFrequencyBinCount(): number;
  84626. /**
  84627. * Gets the current frequency data as a byte array
  84628. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84629. * @returns a Uint8Array
  84630. */
  84631. getByteFrequencyData(): Uint8Array;
  84632. /**
  84633. * Gets the current waveform as a byte array
  84634. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84635. * @returns a Uint8Array
  84636. */
  84637. getByteTimeDomainData(): Uint8Array;
  84638. /**
  84639. * Gets the current frequency data as a float array
  84640. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84641. * @returns a Float32Array
  84642. */
  84643. getFloatFrequencyData(): Float32Array;
  84644. /**
  84645. * Renders the debug canvas
  84646. */
  84647. drawDebugCanvas(): void;
  84648. /**
  84649. * Stops rendering the debug canvas and removes it
  84650. */
  84651. stopDebugCanvas(): void;
  84652. /**
  84653. * Connects two audio nodes
  84654. * @param inputAudioNode defines first node to connect
  84655. * @param outputAudioNode defines second node to connect
  84656. */
  84657. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84658. /**
  84659. * Releases all associated resources
  84660. */
  84661. dispose(): void;
  84662. }
  84663. }
  84664. declare module BABYLON {
  84665. /**
  84666. * This represents an audio engine and it is responsible
  84667. * to play, synchronize and analyse sounds throughout the application.
  84668. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84669. */
  84670. export interface IAudioEngine extends IDisposable {
  84671. /**
  84672. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84673. */
  84674. readonly canUseWebAudio: boolean;
  84675. /**
  84676. * Gets the current AudioContext if available.
  84677. */
  84678. readonly audioContext: Nullable<AudioContext>;
  84679. /**
  84680. * The master gain node defines the global audio volume of your audio engine.
  84681. */
  84682. readonly masterGain: GainNode;
  84683. /**
  84684. * Gets whether or not mp3 are supported by your browser.
  84685. */
  84686. readonly isMP3supported: boolean;
  84687. /**
  84688. * Gets whether or not ogg are supported by your browser.
  84689. */
  84690. readonly isOGGsupported: boolean;
  84691. /**
  84692. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84693. * @ignoreNaming
  84694. */
  84695. WarnedWebAudioUnsupported: boolean;
  84696. /**
  84697. * Defines if the audio engine relies on a custom unlocked button.
  84698. * In this case, the embedded button will not be displayed.
  84699. */
  84700. useCustomUnlockedButton: boolean;
  84701. /**
  84702. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  84703. */
  84704. readonly unlocked: boolean;
  84705. /**
  84706. * Event raised when audio has been unlocked on the browser.
  84707. */
  84708. onAudioUnlockedObservable: Observable<AudioEngine>;
  84709. /**
  84710. * Event raised when audio has been locked on the browser.
  84711. */
  84712. onAudioLockedObservable: Observable<AudioEngine>;
  84713. /**
  84714. * Flags the audio engine in Locked state.
  84715. * This happens due to new browser policies preventing audio to autoplay.
  84716. */
  84717. lock(): void;
  84718. /**
  84719. * Unlocks the audio engine once a user action has been done on the dom.
  84720. * This is helpful to resume play once browser policies have been satisfied.
  84721. */
  84722. unlock(): void;
  84723. }
  84724. /**
  84725. * This represents the default audio engine used in babylon.
  84726. * It is responsible to play, synchronize and analyse sounds throughout the application.
  84727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84728. */
  84729. export class AudioEngine implements IAudioEngine {
  84730. private _audioContext;
  84731. private _audioContextInitialized;
  84732. private _muteButton;
  84733. private _hostElement;
  84734. /**
  84735. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84736. */
  84737. canUseWebAudio: boolean;
  84738. /**
  84739. * The master gain node defines the global audio volume of your audio engine.
  84740. */
  84741. masterGain: GainNode;
  84742. /**
  84743. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84744. * @ignoreNaming
  84745. */
  84746. WarnedWebAudioUnsupported: boolean;
  84747. /**
  84748. * Gets whether or not mp3 are supported by your browser.
  84749. */
  84750. isMP3supported: boolean;
  84751. /**
  84752. * Gets whether or not ogg are supported by your browser.
  84753. */
  84754. isOGGsupported: boolean;
  84755. /**
  84756. * Gets whether audio has been unlocked on the device.
  84757. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  84758. * a user interaction has happened.
  84759. */
  84760. unlocked: boolean;
  84761. /**
  84762. * Defines if the audio engine relies on a custom unlocked button.
  84763. * In this case, the embedded button will not be displayed.
  84764. */
  84765. useCustomUnlockedButton: boolean;
  84766. /**
  84767. * Event raised when audio has been unlocked on the browser.
  84768. */
  84769. onAudioUnlockedObservable: Observable<AudioEngine>;
  84770. /**
  84771. * Event raised when audio has been locked on the browser.
  84772. */
  84773. onAudioLockedObservable: Observable<AudioEngine>;
  84774. /**
  84775. * Gets the current AudioContext if available.
  84776. */
  84777. readonly audioContext: Nullable<AudioContext>;
  84778. private _connectedAnalyser;
  84779. /**
  84780. * Instantiates a new audio engine.
  84781. *
  84782. * There should be only one per page as some browsers restrict the number
  84783. * of audio contexts you can create.
  84784. * @param hostElement defines the host element where to display the mute icon if necessary
  84785. */
  84786. constructor(hostElement?: Nullable<HTMLElement>);
  84787. /**
  84788. * Flags the audio engine in Locked state.
  84789. * This happens due to new browser policies preventing audio to autoplay.
  84790. */
  84791. lock(): void;
  84792. /**
  84793. * Unlocks the audio engine once a user action has been done on the dom.
  84794. * This is helpful to resume play once browser policies have been satisfied.
  84795. */
  84796. unlock(): void;
  84797. private _resumeAudioContext;
  84798. private _initializeAudioContext;
  84799. private _tryToRun;
  84800. private _triggerRunningState;
  84801. private _triggerSuspendedState;
  84802. private _displayMuteButton;
  84803. private _moveButtonToTopLeft;
  84804. private _onResize;
  84805. private _hideMuteButton;
  84806. /**
  84807. * Destroy and release the resources associated with the audio ccontext.
  84808. */
  84809. dispose(): void;
  84810. /**
  84811. * Gets the global volume sets on the master gain.
  84812. * @returns the global volume if set or -1 otherwise
  84813. */
  84814. getGlobalVolume(): number;
  84815. /**
  84816. * Sets the global volume of your experience (sets on the master gain).
  84817. * @param newVolume Defines the new global volume of the application
  84818. */
  84819. setGlobalVolume(newVolume: number): void;
  84820. /**
  84821. * Connect the audio engine to an audio analyser allowing some amazing
  84822. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  84823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  84824. * @param analyser The analyser to connect to the engine
  84825. */
  84826. connectToAnalyser(analyser: Analyser): void;
  84827. }
  84828. }
  84829. declare module BABYLON {
  84830. /**
  84831. * Interface used to present a loading screen while loading a scene
  84832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84833. */
  84834. export interface ILoadingScreen {
  84835. /**
  84836. * Function called to display the loading screen
  84837. */
  84838. displayLoadingUI: () => void;
  84839. /**
  84840. * Function called to hide the loading screen
  84841. */
  84842. hideLoadingUI: () => void;
  84843. /**
  84844. * Gets or sets the color to use for the background
  84845. */
  84846. loadingUIBackgroundColor: string;
  84847. /**
  84848. * Gets or sets the text to display while loading
  84849. */
  84850. loadingUIText: string;
  84851. }
  84852. /**
  84853. * Class used for the default loading screen
  84854. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84855. */
  84856. export class DefaultLoadingScreen implements ILoadingScreen {
  84857. private _renderingCanvas;
  84858. private _loadingText;
  84859. private _loadingDivBackgroundColor;
  84860. private _loadingDiv;
  84861. private _loadingTextDiv;
  84862. /**
  84863. * Creates a new default loading screen
  84864. * @param _renderingCanvas defines the canvas used to render the scene
  84865. * @param _loadingText defines the default text to display
  84866. * @param _loadingDivBackgroundColor defines the default background color
  84867. */
  84868. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  84869. /**
  84870. * Function called to display the loading screen
  84871. */
  84872. displayLoadingUI(): void;
  84873. /**
  84874. * Function called to hide the loading screen
  84875. */
  84876. hideLoadingUI(): void;
  84877. /**
  84878. * Gets or sets the text to display while loading
  84879. */
  84880. loadingUIText: string;
  84881. /**
  84882. * Gets or sets the color to use for the background
  84883. */
  84884. loadingUIBackgroundColor: string;
  84885. private _resizeLoadingUI;
  84886. }
  84887. }
  84888. declare module BABYLON {
  84889. /**
  84890. * Settings for finer control over video usage
  84891. */
  84892. export interface VideoTextureSettings {
  84893. /**
  84894. * Applies `autoplay` to video, if specified
  84895. */
  84896. autoPlay?: boolean;
  84897. /**
  84898. * Applies `loop` to video, if specified
  84899. */
  84900. loop?: boolean;
  84901. /**
  84902. * Automatically updates internal texture from video at every frame in the render loop
  84903. */
  84904. autoUpdateTexture: boolean;
  84905. /**
  84906. * Image src displayed during the video loading or until the user interacts with the video.
  84907. */
  84908. poster?: string;
  84909. }
  84910. /**
  84911. * If you want to display a video in your scene, this is the special texture for that.
  84912. * This special texture works similar to other textures, with the exception of a few parameters.
  84913. * @see https://doc.babylonjs.com/how_to/video_texture
  84914. */
  84915. export class VideoTexture extends Texture {
  84916. /**
  84917. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  84918. */
  84919. readonly autoUpdateTexture: boolean;
  84920. /**
  84921. * The video instance used by the texture internally
  84922. */
  84923. readonly video: HTMLVideoElement;
  84924. private _onUserActionRequestedObservable;
  84925. /**
  84926. * Event triggerd when a dom action is required by the user to play the video.
  84927. * This happens due to recent changes in browser policies preventing video to auto start.
  84928. */
  84929. readonly onUserActionRequestedObservable: Observable<Texture>;
  84930. private _generateMipMaps;
  84931. private _engine;
  84932. private _stillImageCaptured;
  84933. private _displayingPosterTexture;
  84934. private _settings;
  84935. private _createInternalTextureOnEvent;
  84936. /**
  84937. * Creates a video texture.
  84938. * If you want to display a video in your scene, this is the special texture for that.
  84939. * This special texture works similar to other textures, with the exception of a few parameters.
  84940. * @see https://doc.babylonjs.com/how_to/video_texture
  84941. * @param name optional name, will detect from video source, if not defined
  84942. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84943. * @param scene is obviously the current scene.
  84944. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84945. * @param invertY is false by default but can be used to invert video on Y axis
  84946. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84947. * @param settings allows finer control over video usage
  84948. */
  84949. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84950. private _getName;
  84951. private _getVideo;
  84952. private _createInternalTexture;
  84953. private reset;
  84954. /**
  84955. * @hidden Internal method to initiate `update`.
  84956. */
  84957. _rebuild(): void;
  84958. /**
  84959. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84960. */
  84961. update(): void;
  84962. /**
  84963. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84964. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84965. */
  84966. updateTexture(isVisible: boolean): void;
  84967. protected _updateInternalTexture: () => void;
  84968. /**
  84969. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84970. * @param url New url.
  84971. */
  84972. updateURL(url: string): void;
  84973. /**
  84974. * Dispose the texture and release its associated resources.
  84975. */
  84976. dispose(): void;
  84977. /**
  84978. * Creates a video texture straight from a stream.
  84979. * @param scene Define the scene the texture should be created in
  84980. * @param stream Define the stream the texture should be created from
  84981. * @returns The created video texture as a promise
  84982. */
  84983. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84984. /**
  84985. * Creates a video texture straight from your WebCam video feed.
  84986. * @param scene Define the scene the texture should be created in
  84987. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84988. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84989. * @returns The created video texture as a promise
  84990. */
  84991. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84992. minWidth: number;
  84993. maxWidth: number;
  84994. minHeight: number;
  84995. maxHeight: number;
  84996. deviceId: string;
  84997. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84998. /**
  84999. * Creates a video texture straight from your WebCam video feed.
  85000. * @param scene Define the scene the texture should be created in
  85001. * @param onReady Define a callback to triggered once the texture will be ready
  85002. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  85003. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  85004. */
  85005. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  85006. minWidth: number;
  85007. maxWidth: number;
  85008. minHeight: number;
  85009. maxHeight: number;
  85010. deviceId: string;
  85011. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  85012. }
  85013. }
  85014. declare module BABYLON {
  85015. /**
  85016. * Interface for attribute information associated with buffer instanciation
  85017. */
  85018. export class InstancingAttributeInfo {
  85019. /**
  85020. * Index/offset of the attribute in the vertex shader
  85021. */
  85022. index: number;
  85023. /**
  85024. * size of the attribute, 1, 2, 3 or 4
  85025. */
  85026. attributeSize: number;
  85027. /**
  85028. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  85029. * default is FLOAT
  85030. */
  85031. attribyteType: number;
  85032. /**
  85033. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  85034. */
  85035. normalized: boolean;
  85036. /**
  85037. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  85038. */
  85039. offset: number;
  85040. /**
  85041. * Name of the GLSL attribute, for debugging purpose only
  85042. */
  85043. attributeName: string;
  85044. }
  85045. /**
  85046. * Define options used to create a depth texture
  85047. */
  85048. export class DepthTextureCreationOptions {
  85049. /** Specifies whether or not a stencil should be allocated in the texture */
  85050. generateStencil?: boolean;
  85051. /** Specifies whether or not bilinear filtering is enable on the texture */
  85052. bilinearFiltering?: boolean;
  85053. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85054. comparisonFunction?: number;
  85055. /** Specifies if the created texture is a cube texture */
  85056. isCube?: boolean;
  85057. }
  85058. /**
  85059. * Class used to describe the capabilities of the engine relatively to the current browser
  85060. */
  85061. export class EngineCapabilities {
  85062. /** Maximum textures units per fragment shader */
  85063. maxTexturesImageUnits: number;
  85064. /** Maximum texture units per vertex shader */
  85065. maxVertexTextureImageUnits: number;
  85066. /** Maximum textures units in the entire pipeline */
  85067. maxCombinedTexturesImageUnits: number;
  85068. /** Maximum texture size */
  85069. maxTextureSize: number;
  85070. /** Maximum cube texture size */
  85071. maxCubemapTextureSize: number;
  85072. /** Maximum render texture size */
  85073. maxRenderTextureSize: number;
  85074. /** Maximum number of vertex attributes */
  85075. maxVertexAttribs: number;
  85076. /** Maximum number of varyings */
  85077. maxVaryingVectors: number;
  85078. /** Maximum number of uniforms per vertex shader */
  85079. maxVertexUniformVectors: number;
  85080. /** Maximum number of uniforms per fragment shader */
  85081. maxFragmentUniformVectors: number;
  85082. /** Defines if standard derivates (dx/dy) are supported */
  85083. standardDerivatives: boolean;
  85084. /** Defines if s3tc texture compression is supported */
  85085. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85086. /** Defines if pvrtc texture compression is supported */
  85087. pvrtc: any;
  85088. /** Defines if etc1 texture compression is supported */
  85089. etc1: any;
  85090. /** Defines if etc2 texture compression is supported */
  85091. etc2: any;
  85092. /** Defines if astc texture compression is supported */
  85093. astc: any;
  85094. /** Defines if float textures are supported */
  85095. textureFloat: boolean;
  85096. /** Defines if vertex array objects are supported */
  85097. vertexArrayObject: boolean;
  85098. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85099. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85100. /** Gets the maximum level of anisotropy supported */
  85101. maxAnisotropy: number;
  85102. /** Defines if instancing is supported */
  85103. instancedArrays: boolean;
  85104. /** Defines if 32 bits indices are supported */
  85105. uintIndices: boolean;
  85106. /** Defines if high precision shaders are supported */
  85107. highPrecisionShaderSupported: boolean;
  85108. /** Defines if depth reading in the fragment shader is supported */
  85109. fragmentDepthSupported: boolean;
  85110. /** Defines if float texture linear filtering is supported*/
  85111. textureFloatLinearFiltering: boolean;
  85112. /** Defines if rendering to float textures is supported */
  85113. textureFloatRender: boolean;
  85114. /** Defines if half float textures are supported*/
  85115. textureHalfFloat: boolean;
  85116. /** Defines if half float texture linear filtering is supported*/
  85117. textureHalfFloatLinearFiltering: boolean;
  85118. /** Defines if rendering to half float textures is supported */
  85119. textureHalfFloatRender: boolean;
  85120. /** Defines if textureLOD shader command is supported */
  85121. textureLOD: boolean;
  85122. /** Defines if draw buffers extension is supported */
  85123. drawBuffersExtension: boolean;
  85124. /** Defines if depth textures are supported */
  85125. depthTextureExtension: boolean;
  85126. /** Defines if float color buffer are supported */
  85127. colorBufferFloat: boolean;
  85128. /** Gets disjoint timer query extension (null if not supported) */
  85129. timerQuery: EXT_disjoint_timer_query;
  85130. /** Defines if timestamp can be used with timer query */
  85131. canUseTimestampForTimerQuery: boolean;
  85132. /** Function used to let the system compiles shaders in background */
  85133. parallelShaderCompile: {
  85134. COMPLETION_STATUS_KHR: number;
  85135. };
  85136. }
  85137. /** Interface defining initialization parameters for Engine class */
  85138. export interface EngineOptions extends WebGLContextAttributes {
  85139. /**
  85140. * Defines if the engine should no exceed a specified device ratio
  85141. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85142. */
  85143. limitDeviceRatio?: number;
  85144. /**
  85145. * Defines if webvr should be enabled automatically
  85146. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85147. */
  85148. autoEnableWebVR?: boolean;
  85149. /**
  85150. * Defines if webgl2 should be turned off even if supported
  85151. * @see http://doc.babylonjs.com/features/webgl2
  85152. */
  85153. disableWebGL2Support?: boolean;
  85154. /**
  85155. * Defines if webaudio should be initialized as well
  85156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85157. */
  85158. audioEngine?: boolean;
  85159. /**
  85160. * Defines if animations should run using a deterministic lock step
  85161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85162. */
  85163. deterministicLockstep?: boolean;
  85164. /** Defines the maximum steps to use with deterministic lock step mode */
  85165. lockstepMaxSteps?: number;
  85166. /**
  85167. * Defines that engine should ignore context lost events
  85168. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85169. */
  85170. doNotHandleContextLost?: boolean;
  85171. /**
  85172. * Defines that engine should ignore modifying touch action attribute and style
  85173. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85174. */
  85175. doNotHandleTouchAction?: boolean;
  85176. /**
  85177. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85178. */
  85179. useHighPrecisionFloats?: boolean;
  85180. }
  85181. /**
  85182. * Defines the interface used by display changed events
  85183. */
  85184. export interface IDisplayChangedEventArgs {
  85185. /** Gets the vrDisplay object (if any) */
  85186. vrDisplay: Nullable<any>;
  85187. /** Gets a boolean indicating if webVR is supported */
  85188. vrSupported: boolean;
  85189. }
  85190. /**
  85191. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85192. */
  85193. export class Engine {
  85194. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85195. static ExceptionList: ({
  85196. key: string;
  85197. capture: string;
  85198. captureConstraint: number;
  85199. targets: string[];
  85200. } | {
  85201. key: string;
  85202. capture: null;
  85203. captureConstraint: null;
  85204. targets: string[];
  85205. })[];
  85206. /** Gets the list of created engines */
  85207. static readonly Instances: Engine[];
  85208. /**
  85209. * Gets the latest created engine
  85210. */
  85211. static readonly LastCreatedEngine: Nullable<Engine>;
  85212. /**
  85213. * Gets the latest created scene
  85214. */
  85215. static readonly LastCreatedScene: Nullable<Scene>;
  85216. /**
  85217. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85218. * @param flag defines which part of the materials must be marked as dirty
  85219. * @param predicate defines a predicate used to filter which materials should be affected
  85220. */
  85221. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85222. /**
  85223. * Hidden
  85224. */
  85225. static _TextureLoaders: IInternalTextureLoader[];
  85226. /** Defines that alpha blending is disabled */
  85227. static readonly ALPHA_DISABLE: number;
  85228. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85229. static readonly ALPHA_ADD: number;
  85230. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85231. static readonly ALPHA_COMBINE: number;
  85232. /** Defines that alpha blending to DEST - SRC * DEST */
  85233. static readonly ALPHA_SUBTRACT: number;
  85234. /** Defines that alpha blending to SRC * DEST */
  85235. static readonly ALPHA_MULTIPLY: number;
  85236. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85237. static readonly ALPHA_MAXIMIZED: number;
  85238. /** Defines that alpha blending to SRC + DEST */
  85239. static readonly ALPHA_ONEONE: number;
  85240. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85241. static readonly ALPHA_PREMULTIPLIED: number;
  85242. /**
  85243. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  85244. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85245. */
  85246. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85247. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  85248. static readonly ALPHA_INTERPOLATE: number;
  85249. /**
  85250. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  85251. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85252. */
  85253. static readonly ALPHA_SCREENMODE: number;
  85254. /** Defines that the ressource is not delayed*/
  85255. static readonly DELAYLOADSTATE_NONE: number;
  85256. /** Defines that the ressource was successfully delay loaded */
  85257. static readonly DELAYLOADSTATE_LOADED: number;
  85258. /** Defines that the ressource is currently delay loading */
  85259. static readonly DELAYLOADSTATE_LOADING: number;
  85260. /** Defines that the ressource is delayed and has not started loading */
  85261. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85262. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85263. static readonly NEVER: number;
  85264. /** 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 */
  85265. static readonly ALWAYS: number;
  85266. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85267. static readonly LESS: number;
  85268. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85269. static readonly EQUAL: number;
  85270. /** 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 */
  85271. static readonly LEQUAL: number;
  85272. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85273. static readonly GREATER: number;
  85274. /** 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 */
  85275. static readonly GEQUAL: number;
  85276. /** 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 */
  85277. static readonly NOTEQUAL: number;
  85278. /** Passed to stencilOperation to specify that stencil value must be kept */
  85279. static readonly KEEP: number;
  85280. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85281. static readonly REPLACE: number;
  85282. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85283. static readonly INCR: number;
  85284. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85285. static readonly DECR: number;
  85286. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85287. static readonly INVERT: number;
  85288. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85289. static readonly INCR_WRAP: number;
  85290. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85291. static readonly DECR_WRAP: number;
  85292. /** Texture is not repeating outside of 0..1 UVs */
  85293. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85294. /** Texture is repeating outside of 0..1 UVs */
  85295. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85296. /** Texture is repeating and mirrored */
  85297. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85298. /** ALPHA */
  85299. static readonly TEXTUREFORMAT_ALPHA: number;
  85300. /** LUMINANCE */
  85301. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85302. /** LUMINANCE_ALPHA */
  85303. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85304. /** RGB */
  85305. static readonly TEXTUREFORMAT_RGB: number;
  85306. /** RGBA */
  85307. static readonly TEXTUREFORMAT_RGBA: number;
  85308. /** RED */
  85309. static readonly TEXTUREFORMAT_RED: number;
  85310. /** RED (2nd reference) */
  85311. static readonly TEXTUREFORMAT_R: number;
  85312. /** RG */
  85313. static readonly TEXTUREFORMAT_RG: number;
  85314. /** RED_INTEGER */
  85315. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85316. /** RED_INTEGER (2nd reference) */
  85317. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85318. /** RG_INTEGER */
  85319. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85320. /** RGB_INTEGER */
  85321. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85322. /** RGBA_INTEGER */
  85323. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85324. /** UNSIGNED_BYTE */
  85325. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85326. /** UNSIGNED_BYTE (2nd reference) */
  85327. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85328. /** FLOAT */
  85329. static readonly TEXTURETYPE_FLOAT: number;
  85330. /** HALF_FLOAT */
  85331. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85332. /** BYTE */
  85333. static readonly TEXTURETYPE_BYTE: number;
  85334. /** SHORT */
  85335. static readonly TEXTURETYPE_SHORT: number;
  85336. /** UNSIGNED_SHORT */
  85337. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85338. /** INT */
  85339. static readonly TEXTURETYPE_INT: number;
  85340. /** UNSIGNED_INT */
  85341. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85342. /** UNSIGNED_SHORT_4_4_4_4 */
  85343. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85344. /** UNSIGNED_SHORT_5_5_5_1 */
  85345. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85346. /** UNSIGNED_SHORT_5_6_5 */
  85347. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85348. /** UNSIGNED_INT_2_10_10_10_REV */
  85349. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85350. /** UNSIGNED_INT_24_8 */
  85351. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85352. /** UNSIGNED_INT_10F_11F_11F_REV */
  85353. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85354. /** UNSIGNED_INT_5_9_9_9_REV */
  85355. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85356. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85357. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85358. /** nearest is mag = nearest and min = nearest and mip = linear */
  85359. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85360. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85361. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85362. /** Trilinear is mag = linear and min = linear and mip = linear */
  85363. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85364. /** nearest is mag = nearest and min = nearest and mip = linear */
  85365. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85366. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85367. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85368. /** Trilinear is mag = linear and min = linear and mip = linear */
  85369. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85370. /** mag = nearest and min = nearest and mip = nearest */
  85371. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85372. /** mag = nearest and min = linear and mip = nearest */
  85373. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85374. /** mag = nearest and min = linear and mip = linear */
  85375. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85376. /** mag = nearest and min = linear and mip = none */
  85377. static readonly TEXTURE_NEAREST_LINEAR: number;
  85378. /** mag = nearest and min = nearest and mip = none */
  85379. static readonly TEXTURE_NEAREST_NEAREST: number;
  85380. /** mag = linear and min = nearest and mip = nearest */
  85381. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85382. /** mag = linear and min = nearest and mip = linear */
  85383. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85384. /** mag = linear and min = linear and mip = none */
  85385. static readonly TEXTURE_LINEAR_LINEAR: number;
  85386. /** mag = linear and min = nearest and mip = none */
  85387. static readonly TEXTURE_LINEAR_NEAREST: number;
  85388. /** Explicit coordinates mode */
  85389. static readonly TEXTURE_EXPLICIT_MODE: number;
  85390. /** Spherical coordinates mode */
  85391. static readonly TEXTURE_SPHERICAL_MODE: number;
  85392. /** Planar coordinates mode */
  85393. static readonly TEXTURE_PLANAR_MODE: number;
  85394. /** Cubic coordinates mode */
  85395. static readonly TEXTURE_CUBIC_MODE: number;
  85396. /** Projection coordinates mode */
  85397. static readonly TEXTURE_PROJECTION_MODE: number;
  85398. /** Skybox coordinates mode */
  85399. static readonly TEXTURE_SKYBOX_MODE: number;
  85400. /** Inverse Cubic coordinates mode */
  85401. static readonly TEXTURE_INVCUBIC_MODE: number;
  85402. /** Equirectangular coordinates mode */
  85403. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85404. /** Equirectangular Fixed coordinates mode */
  85405. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85406. /** Equirectangular Fixed Mirrored coordinates mode */
  85407. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85408. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85409. static readonly SCALEMODE_FLOOR: number;
  85410. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85411. static readonly SCALEMODE_NEAREST: number;
  85412. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85413. static readonly SCALEMODE_CEILING: number;
  85414. /**
  85415. * Returns the current npm package of the sdk
  85416. */
  85417. static readonly NpmPackage: string;
  85418. /**
  85419. * Returns the current version of the framework
  85420. */
  85421. static readonly Version: string;
  85422. /**
  85423. * Returns a string describing the current engine
  85424. */
  85425. readonly description: string;
  85426. /**
  85427. * Gets or sets the epsilon value used by collision engine
  85428. */
  85429. static CollisionsEpsilon: number;
  85430. /**
  85431. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85432. */
  85433. static ShadersRepository: string;
  85434. /**
  85435. * Method called to create the default loading screen.
  85436. * This can be overriden in your own app.
  85437. * @param canvas The rendering canvas element
  85438. * @returns The loading screen
  85439. */
  85440. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85441. /**
  85442. * Method called to create the default rescale post process on each engine.
  85443. */
  85444. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85445. /**
  85446. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85447. */
  85448. forcePOTTextures: boolean;
  85449. /**
  85450. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85451. */
  85452. isFullscreen: boolean;
  85453. /**
  85454. * Gets a boolean indicating if the pointer is currently locked
  85455. */
  85456. isPointerLock: boolean;
  85457. /**
  85458. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85459. */
  85460. cullBackFaces: boolean;
  85461. /**
  85462. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85463. */
  85464. renderEvenInBackground: boolean;
  85465. /**
  85466. * Gets or sets a boolean indicating that cache can be kept between frames
  85467. */
  85468. preventCacheWipeBetweenFrames: boolean;
  85469. /**
  85470. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85471. **/
  85472. enableOfflineSupport: boolean;
  85473. /**
  85474. * 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)
  85475. **/
  85476. disableManifestCheck: boolean;
  85477. /**
  85478. * Gets the list of created scenes
  85479. */
  85480. scenes: Scene[];
  85481. /**
  85482. * Event raised when a new scene is created
  85483. */
  85484. onNewSceneAddedObservable: Observable<Scene>;
  85485. /**
  85486. * Gets the list of created postprocesses
  85487. */
  85488. postProcesses: PostProcess[];
  85489. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85490. validateShaderPrograms: boolean;
  85491. /**
  85492. * Observable event triggered each time the rendering canvas is resized
  85493. */
  85494. onResizeObservable: Observable<Engine>;
  85495. /**
  85496. * Observable event triggered each time the canvas loses focus
  85497. */
  85498. onCanvasBlurObservable: Observable<Engine>;
  85499. /**
  85500. * Observable event triggered each time the canvas gains focus
  85501. */
  85502. onCanvasFocusObservable: Observable<Engine>;
  85503. /**
  85504. * Observable event triggered each time the canvas receives pointerout event
  85505. */
  85506. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85507. /**
  85508. * Observable event triggered before each texture is initialized
  85509. */
  85510. onBeforeTextureInitObservable: Observable<Texture>;
  85511. private _vrDisplay;
  85512. private _vrSupported;
  85513. private _oldSize;
  85514. private _oldHardwareScaleFactor;
  85515. private _vrExclusivePointerMode;
  85516. private _webVRInitPromise;
  85517. /**
  85518. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85519. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85520. */
  85521. readonly isInVRExclusivePointerMode: boolean;
  85522. /**
  85523. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85524. */
  85525. disableUniformBuffers: boolean;
  85526. /** @hidden */
  85527. _uniformBuffers: UniformBuffer[];
  85528. /**
  85529. * Gets a boolean indicating that the engine supports uniform buffers
  85530. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85531. */
  85532. readonly supportsUniformBuffers: boolean;
  85533. /**
  85534. * Observable raised when the engine begins a new frame
  85535. */
  85536. onBeginFrameObservable: Observable<Engine>;
  85537. /**
  85538. * If set, will be used to request the next animation frame for the render loop
  85539. */
  85540. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85541. /**
  85542. * Observable raised when the engine ends the current frame
  85543. */
  85544. onEndFrameObservable: Observable<Engine>;
  85545. /**
  85546. * Observable raised when the engine is about to compile a shader
  85547. */
  85548. onBeforeShaderCompilationObservable: Observable<Engine>;
  85549. /**
  85550. * Observable raised when the engine has jsut compiled a shader
  85551. */
  85552. onAfterShaderCompilationObservable: Observable<Engine>;
  85553. /** @hidden */
  85554. _gl: WebGLRenderingContext;
  85555. private _renderingCanvas;
  85556. private _windowIsBackground;
  85557. private _webGLVersion;
  85558. protected _highPrecisionShadersAllowed: boolean;
  85559. /** @hidden */
  85560. readonly _shouldUseHighPrecisionShader: boolean;
  85561. /**
  85562. * Gets a boolean indicating that only power of 2 textures are supported
  85563. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85564. */
  85565. readonly needPOTTextures: boolean;
  85566. /** @hidden */
  85567. _badOS: boolean;
  85568. /** @hidden */
  85569. _badDesktopOS: boolean;
  85570. /**
  85571. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85572. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85573. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85574. */
  85575. disableTextureBindingOptimization: boolean;
  85576. /**
  85577. * Gets the audio engine
  85578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85579. * @ignorenaming
  85580. */
  85581. static audioEngine: IAudioEngine;
  85582. /**
  85583. * Default AudioEngine factory responsible of creating the Audio Engine.
  85584. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85585. */
  85586. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85587. /**
  85588. * Default offline support factory responsible of creating a tool used to store data locally.
  85589. * By default, this will create a Database object if the workload has been embedded.
  85590. */
  85591. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85592. private _onFocus;
  85593. private _onBlur;
  85594. private _onCanvasPointerOut;
  85595. private _onCanvasBlur;
  85596. private _onCanvasFocus;
  85597. private _onFullscreenChange;
  85598. private _onPointerLockChange;
  85599. private _onVRDisplayPointerRestricted;
  85600. private _onVRDisplayPointerUnrestricted;
  85601. private _onVrDisplayConnect;
  85602. private _onVrDisplayDisconnect;
  85603. private _onVrDisplayPresentChange;
  85604. /**
  85605. * Observable signaled when VR display mode changes
  85606. */
  85607. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85608. /**
  85609. * Observable signaled when VR request present is complete
  85610. */
  85611. onVRRequestPresentComplete: Observable<boolean>;
  85612. /**
  85613. * Observable signaled when VR request present starts
  85614. */
  85615. onVRRequestPresentStart: Observable<Engine>;
  85616. private _hardwareScalingLevel;
  85617. /** @hidden */
  85618. protected _caps: EngineCapabilities;
  85619. private _pointerLockRequested;
  85620. private _isStencilEnable;
  85621. private _colorWrite;
  85622. private _loadingScreen;
  85623. /** @hidden */
  85624. _drawCalls: PerfCounter;
  85625. /** @hidden */
  85626. _textureCollisions: PerfCounter;
  85627. private _glVersion;
  85628. private _glRenderer;
  85629. private _glVendor;
  85630. private _videoTextureSupported;
  85631. private _renderingQueueLaunched;
  85632. private _activeRenderLoops;
  85633. private _deterministicLockstep;
  85634. private _lockstepMaxSteps;
  85635. /**
  85636. * Observable signaled when a context lost event is raised
  85637. */
  85638. onContextLostObservable: Observable<Engine>;
  85639. /**
  85640. * Observable signaled when a context restored event is raised
  85641. */
  85642. onContextRestoredObservable: Observable<Engine>;
  85643. private _onContextLost;
  85644. private _onContextRestored;
  85645. private _contextWasLost;
  85646. private _doNotHandleContextLost;
  85647. /**
  85648. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85649. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85650. */
  85651. doNotHandleContextLost: boolean;
  85652. private _performanceMonitor;
  85653. private _fps;
  85654. private _deltaTime;
  85655. /**
  85656. * Turn this value on if you want to pause FPS computation when in background
  85657. */
  85658. disablePerformanceMonitorInBackground: boolean;
  85659. /**
  85660. * Gets the performance monitor attached to this engine
  85661. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  85662. */
  85663. readonly performanceMonitor: PerformanceMonitor;
  85664. /** @hidden */
  85665. protected _depthCullingState: _DepthCullingState;
  85666. /** @hidden */
  85667. protected _stencilState: _StencilState;
  85668. /** @hidden */
  85669. protected _alphaState: _AlphaState;
  85670. /** @hidden */
  85671. protected _alphaMode: number;
  85672. protected _internalTexturesCache: InternalTexture[];
  85673. /** @hidden */
  85674. protected _activeChannel: number;
  85675. private _currentTextureChannel;
  85676. /** @hidden */
  85677. protected _boundTexturesCache: {
  85678. [key: string]: Nullable<InternalTexture>;
  85679. };
  85680. /** @hidden */
  85681. protected _currentEffect: Nullable<Effect>;
  85682. /** @hidden */
  85683. protected _currentProgram: Nullable<WebGLProgram>;
  85684. private _compiledEffects;
  85685. private _vertexAttribArraysEnabled;
  85686. /** @hidden */
  85687. protected _cachedViewport: Nullable<Viewport>;
  85688. private _cachedVertexArrayObject;
  85689. /** @hidden */
  85690. protected _cachedVertexBuffers: any;
  85691. /** @hidden */
  85692. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  85693. /** @hidden */
  85694. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  85695. /** @hidden */
  85696. protected _currentRenderTarget: Nullable<InternalTexture>;
  85697. private _uintIndicesCurrentlySet;
  85698. private _currentBoundBuffer;
  85699. /** @hidden */
  85700. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  85701. private _currentBufferPointers;
  85702. private _currentInstanceLocations;
  85703. private _currentInstanceBuffers;
  85704. private _textureUnits;
  85705. private _firstBoundInternalTextureTracker;
  85706. private _lastBoundInternalTextureTracker;
  85707. private _workingCanvas;
  85708. private _workingContext;
  85709. private _rescalePostProcess;
  85710. private _dummyFramebuffer;
  85711. private _externalData;
  85712. private _bindedRenderFunction;
  85713. private _vaoRecordInProgress;
  85714. private _mustWipeVertexAttributes;
  85715. private _emptyTexture;
  85716. private _emptyCubeTexture;
  85717. private _emptyTexture3D;
  85718. /** @hidden */
  85719. _frameHandler: number;
  85720. private _nextFreeTextureSlots;
  85721. private _maxSimultaneousTextures;
  85722. private _activeRequests;
  85723. private _texturesSupported;
  85724. private _textureFormatInUse;
  85725. /**
  85726. * Gets the list of texture formats supported
  85727. */
  85728. readonly texturesSupported: Array<string>;
  85729. /**
  85730. * Gets the list of texture formats in use
  85731. */
  85732. readonly textureFormatInUse: Nullable<string>;
  85733. /**
  85734. * Gets the current viewport
  85735. */
  85736. readonly currentViewport: Nullable<Viewport>;
  85737. /**
  85738. * Gets the default empty texture
  85739. */
  85740. readonly emptyTexture: InternalTexture;
  85741. /**
  85742. * Gets the default empty 3D texture
  85743. */
  85744. readonly emptyTexture3D: InternalTexture;
  85745. /**
  85746. * Gets the default empty cube texture
  85747. */
  85748. readonly emptyCubeTexture: InternalTexture;
  85749. /**
  85750. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  85751. */
  85752. readonly premultipliedAlpha: boolean;
  85753. /**
  85754. * Creates a new engine
  85755. * @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
  85756. * @param antialias defines enable antialiasing (default: false)
  85757. * @param options defines further options to be sent to the getContext() function
  85758. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  85759. */
  85760. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  85761. private _disableTouchAction;
  85762. private _rebuildInternalTextures;
  85763. private _rebuildEffects;
  85764. /**
  85765. * Gets a boolean indicating if all created effects are ready
  85766. * @returns true if all effects are ready
  85767. */
  85768. areAllEffectsReady(): boolean;
  85769. private _rebuildBuffers;
  85770. private _initGLContext;
  85771. /**
  85772. * Gets version of the current webGL context
  85773. */
  85774. readonly webGLVersion: number;
  85775. /**
  85776. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  85777. */
  85778. readonly isStencilEnable: boolean;
  85779. private _prepareWorkingCanvas;
  85780. /**
  85781. * Reset the texture cache to empty state
  85782. */
  85783. resetTextureCache(): void;
  85784. /**
  85785. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  85786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85787. * @returns true if engine is in deterministic lock step mode
  85788. */
  85789. isDeterministicLockStep(): boolean;
  85790. /**
  85791. * Gets the max steps when engine is running in deterministic lock step
  85792. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85793. * @returns the max steps
  85794. */
  85795. getLockstepMaxSteps(): number;
  85796. /**
  85797. * Gets an object containing information about the current webGL context
  85798. * @returns an object containing the vender, the renderer and the version of the current webGL context
  85799. */
  85800. getGlInfo(): {
  85801. vendor: string;
  85802. renderer: string;
  85803. version: string;
  85804. };
  85805. /**
  85806. * Gets current aspect ratio
  85807. * @param camera defines the camera to use to get the aspect ratio
  85808. * @param useScreen defines if screen size must be used (or the current render target if any)
  85809. * @returns a number defining the aspect ratio
  85810. */
  85811. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  85812. /**
  85813. * Gets current screen aspect ratio
  85814. * @returns a number defining the aspect ratio
  85815. */
  85816. getScreenAspectRatio(): number;
  85817. /**
  85818. * Gets the current render width
  85819. * @param useScreen defines if screen size must be used (or the current render target if any)
  85820. * @returns a number defining the current render width
  85821. */
  85822. getRenderWidth(useScreen?: boolean): number;
  85823. /**
  85824. * Gets the current render height
  85825. * @param useScreen defines if screen size must be used (or the current render target if any)
  85826. * @returns a number defining the current render height
  85827. */
  85828. getRenderHeight(useScreen?: boolean): number;
  85829. /**
  85830. * Gets the HTML canvas attached with the current webGL context
  85831. * @returns a HTML canvas
  85832. */
  85833. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  85834. /**
  85835. * Gets the client rect of the HTML canvas attached with the current webGL context
  85836. * @returns a client rectanglee
  85837. */
  85838. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  85839. /**
  85840. * Defines the hardware scaling level.
  85841. * By default the hardware scaling level is computed from the window device ratio.
  85842. * 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.
  85843. * @param level defines the level to use
  85844. */
  85845. setHardwareScalingLevel(level: number): void;
  85846. /**
  85847. * Gets the current hardware scaling level.
  85848. * By default the hardware scaling level is computed from the window device ratio.
  85849. * 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.
  85850. * @returns a number indicating the current hardware scaling level
  85851. */
  85852. getHardwareScalingLevel(): number;
  85853. /**
  85854. * Gets the list of loaded textures
  85855. * @returns an array containing all loaded textures
  85856. */
  85857. getLoadedTexturesCache(): InternalTexture[];
  85858. /**
  85859. * Gets the object containing all engine capabilities
  85860. * @returns the EngineCapabilities object
  85861. */
  85862. getCaps(): EngineCapabilities;
  85863. /**
  85864. * Gets the current depth function
  85865. * @returns a number defining the depth function
  85866. */
  85867. getDepthFunction(): Nullable<number>;
  85868. /**
  85869. * Sets the current depth function
  85870. * @param depthFunc defines the function to use
  85871. */
  85872. setDepthFunction(depthFunc: number): void;
  85873. /**
  85874. * Sets the current depth function to GREATER
  85875. */
  85876. setDepthFunctionToGreater(): void;
  85877. /**
  85878. * Sets the current depth function to GEQUAL
  85879. */
  85880. setDepthFunctionToGreaterOrEqual(): void;
  85881. /**
  85882. * Sets the current depth function to LESS
  85883. */
  85884. setDepthFunctionToLess(): void;
  85885. private _cachedStencilBuffer;
  85886. private _cachedStencilFunction;
  85887. private _cachedStencilMask;
  85888. private _cachedStencilOperationPass;
  85889. private _cachedStencilOperationFail;
  85890. private _cachedStencilOperationDepthFail;
  85891. private _cachedStencilReference;
  85892. /**
  85893. * Caches the the state of the stencil buffer
  85894. */
  85895. cacheStencilState(): void;
  85896. /**
  85897. * Restores the state of the stencil buffer
  85898. */
  85899. restoreStencilState(): void;
  85900. /**
  85901. * Sets the current depth function to LEQUAL
  85902. */
  85903. setDepthFunctionToLessOrEqual(): void;
  85904. /**
  85905. * Gets a boolean indicating if stencil buffer is enabled
  85906. * @returns the current stencil buffer state
  85907. */
  85908. getStencilBuffer(): boolean;
  85909. /**
  85910. * Enable or disable the stencil buffer
  85911. * @param enable defines if the stencil buffer must be enabled or disabled
  85912. */
  85913. setStencilBuffer(enable: boolean): void;
  85914. /**
  85915. * Gets the current stencil mask
  85916. * @returns a number defining the new stencil mask to use
  85917. */
  85918. getStencilMask(): number;
  85919. /**
  85920. * Sets the current stencil mask
  85921. * @param mask defines the new stencil mask to use
  85922. */
  85923. setStencilMask(mask: number): void;
  85924. /**
  85925. * Gets the current stencil function
  85926. * @returns a number defining the stencil function to use
  85927. */
  85928. getStencilFunction(): number;
  85929. /**
  85930. * Gets the current stencil reference value
  85931. * @returns a number defining the stencil reference value to use
  85932. */
  85933. getStencilFunctionReference(): number;
  85934. /**
  85935. * Gets the current stencil mask
  85936. * @returns a number defining the stencil mask to use
  85937. */
  85938. getStencilFunctionMask(): number;
  85939. /**
  85940. * Sets the current stencil function
  85941. * @param stencilFunc defines the new stencil function to use
  85942. */
  85943. setStencilFunction(stencilFunc: number): void;
  85944. /**
  85945. * Sets the current stencil reference
  85946. * @param reference defines the new stencil reference to use
  85947. */
  85948. setStencilFunctionReference(reference: number): void;
  85949. /**
  85950. * Sets the current stencil mask
  85951. * @param mask defines the new stencil mask to use
  85952. */
  85953. setStencilFunctionMask(mask: number): void;
  85954. /**
  85955. * Gets the current stencil operation when stencil fails
  85956. * @returns a number defining stencil operation to use when stencil fails
  85957. */
  85958. getStencilOperationFail(): number;
  85959. /**
  85960. * Gets the current stencil operation when depth fails
  85961. * @returns a number defining stencil operation to use when depth fails
  85962. */
  85963. getStencilOperationDepthFail(): number;
  85964. /**
  85965. * Gets the current stencil operation when stencil passes
  85966. * @returns a number defining stencil operation to use when stencil passes
  85967. */
  85968. getStencilOperationPass(): number;
  85969. /**
  85970. * Sets the stencil operation to use when stencil fails
  85971. * @param operation defines the stencil operation to use when stencil fails
  85972. */
  85973. setStencilOperationFail(operation: number): void;
  85974. /**
  85975. * Sets the stencil operation to use when depth fails
  85976. * @param operation defines the stencil operation to use when depth fails
  85977. */
  85978. setStencilOperationDepthFail(operation: number): void;
  85979. /**
  85980. * Sets the stencil operation to use when stencil passes
  85981. * @param operation defines the stencil operation to use when stencil passes
  85982. */
  85983. setStencilOperationPass(operation: number): void;
  85984. /**
  85985. * Sets a boolean indicating if the dithering state is enabled or disabled
  85986. * @param value defines the dithering state
  85987. */
  85988. setDitheringState(value: boolean): void;
  85989. /**
  85990. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85991. * @param value defines the rasterizer state
  85992. */
  85993. setRasterizerState(value: boolean): void;
  85994. /**
  85995. * stop executing a render loop function and remove it from the execution array
  85996. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85997. */
  85998. stopRenderLoop(renderFunction?: () => void): void;
  85999. /** @hidden */
  86000. _renderLoop(): void;
  86001. /**
  86002. * Register and execute a render loop. The engine can have more than one render function
  86003. * @param renderFunction defines the function to continuously execute
  86004. */
  86005. runRenderLoop(renderFunction: () => void): void;
  86006. /**
  86007. * Toggle full screen mode
  86008. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86009. */
  86010. switchFullscreen(requestPointerLock: boolean): void;
  86011. /**
  86012. * Enters full screen mode
  86013. * @param requestPointerLock defines if a pointer lock should be requested from the user
  86014. */
  86015. enterFullscreen(requestPointerLock: boolean): void;
  86016. /**
  86017. * Exits full screen mode
  86018. */
  86019. exitFullscreen(): void;
  86020. /**
  86021. * Clear the current render buffer or the current render target (if any is set up)
  86022. * @param color defines the color to use
  86023. * @param backBuffer defines if the back buffer must be cleared
  86024. * @param depth defines if the depth buffer must be cleared
  86025. * @param stencil defines if the stencil buffer must be cleared
  86026. */
  86027. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  86028. /**
  86029. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  86030. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86031. * @param y defines the y-coordinate of the corner of the clear rectangle
  86032. * @param width defines the width of the clear rectangle
  86033. * @param height defines the height of the clear rectangle
  86034. * @param clearColor defines the clear color
  86035. */
  86036. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  86037. /**
  86038. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  86039. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  86040. * @param y defines the y-coordinate of the corner of the clear rectangle
  86041. * @param width defines the width of the clear rectangle
  86042. * @param height defines the height of the clear rectangle
  86043. */
  86044. enableScissor(x: number, y: number, width: number, height: number): void;
  86045. /**
  86046. * Disable previously set scissor test rectangle
  86047. */
  86048. disableScissor(): void;
  86049. private _viewportCached;
  86050. /** @hidden */
  86051. _viewport(x: number, y: number, width: number, height: number): void;
  86052. /**
  86053. * Set the WebGL's viewport
  86054. * @param viewport defines the viewport element to be used
  86055. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  86056. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  86057. */
  86058. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  86059. /**
  86060. * Directly set the WebGL Viewport
  86061. * @param x defines the x coordinate of the viewport (in screen space)
  86062. * @param y defines the y coordinate of the viewport (in screen space)
  86063. * @param width defines the width of the viewport (in screen space)
  86064. * @param height defines the height of the viewport (in screen space)
  86065. * @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
  86066. */
  86067. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86068. /**
  86069. * Begin a new frame
  86070. */
  86071. beginFrame(): void;
  86072. /**
  86073. * Enf the current frame
  86074. */
  86075. endFrame(): void;
  86076. /**
  86077. * Resize the view according to the canvas' size
  86078. */
  86079. resize(): void;
  86080. /**
  86081. * Force a specific size of the canvas
  86082. * @param width defines the new canvas' width
  86083. * @param height defines the new canvas' height
  86084. */
  86085. setSize(width: number, height: number): void;
  86086. /**
  86087. * Gets a boolean indicating if a webVR device was detected
  86088. * @returns true if a webVR device was detected
  86089. */
  86090. isVRDevicePresent(): boolean;
  86091. /**
  86092. * Gets the current webVR device
  86093. * @returns the current webVR device (or null)
  86094. */
  86095. getVRDevice(): any;
  86096. /**
  86097. * Initializes a webVR display and starts listening to display change events
  86098. * The onVRDisplayChangedObservable will be notified upon these changes
  86099. * @returns The onVRDisplayChangedObservable
  86100. */
  86101. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86102. /**
  86103. * Initializes a webVR display and starts listening to display change events
  86104. * The onVRDisplayChangedObservable will be notified upon these changes
  86105. * @returns A promise containing a VRDisplay and if vr is supported
  86106. */
  86107. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86108. /**
  86109. * Call this function to switch to webVR mode
  86110. * Will do nothing if webVR is not supported or if there is no webVR device
  86111. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86112. */
  86113. enableVR(): void;
  86114. /**
  86115. * Call this function to leave webVR mode
  86116. * Will do nothing if webVR is not supported or if there is no webVR device
  86117. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86118. */
  86119. disableVR(): void;
  86120. private _onVRFullScreenTriggered;
  86121. private _getVRDisplaysAsync;
  86122. /**
  86123. * Binds the frame buffer to the specified texture.
  86124. * @param texture The texture to render to or null for the default canvas
  86125. * @param faceIndex The face of the texture to render to in case of cube texture
  86126. * @param requiredWidth The width of the target to render to
  86127. * @param requiredHeight The height of the target to render to
  86128. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86129. * @param depthStencilTexture The depth stencil texture to use to render
  86130. * @param lodLevel defines le lod level to bind to the frame buffer
  86131. */
  86132. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86133. private bindUnboundFramebuffer;
  86134. /**
  86135. * Unbind the current render target texture from the webGL context
  86136. * @param texture defines the render target texture to unbind
  86137. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86138. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86139. */
  86140. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86141. /**
  86142. * Unbind a list of render target textures from the webGL context
  86143. * This is used only when drawBuffer extension or webGL2 are active
  86144. * @param textures defines the render target textures to unbind
  86145. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86146. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86147. */
  86148. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86149. /**
  86150. * Force the mipmap generation for the given render target texture
  86151. * @param texture defines the render target texture to use
  86152. */
  86153. generateMipMapsForCubemap(texture: InternalTexture): void;
  86154. /**
  86155. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86156. */
  86157. flushFramebuffer(): void;
  86158. /**
  86159. * Unbind the current render target and bind the default framebuffer
  86160. */
  86161. restoreDefaultFramebuffer(): void;
  86162. /**
  86163. * Create an uniform buffer
  86164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86165. * @param elements defines the content of the uniform buffer
  86166. * @returns the webGL uniform buffer
  86167. */
  86168. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86169. /**
  86170. * Create a dynamic uniform buffer
  86171. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86172. * @param elements defines the content of the uniform buffer
  86173. * @returns the webGL uniform buffer
  86174. */
  86175. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86176. /**
  86177. * Update an existing uniform buffer
  86178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86179. * @param uniformBuffer defines the target uniform buffer
  86180. * @param elements defines the content to update
  86181. * @param offset defines the offset in the uniform buffer where update should start
  86182. * @param count defines the size of the data to update
  86183. */
  86184. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86185. private _resetVertexBufferBinding;
  86186. /**
  86187. * Creates a vertex buffer
  86188. * @param data the data for the vertex buffer
  86189. * @returns the new WebGL static buffer
  86190. */
  86191. createVertexBuffer(data: DataArray): WebGLBuffer;
  86192. /**
  86193. * Creates a dynamic vertex buffer
  86194. * @param data the data for the dynamic vertex buffer
  86195. * @returns the new WebGL dynamic buffer
  86196. */
  86197. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86198. /**
  86199. * Update a dynamic index buffer
  86200. * @param indexBuffer defines the target index buffer
  86201. * @param indices defines the data to update
  86202. * @param offset defines the offset in the target index buffer where update should start
  86203. */
  86204. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86205. /**
  86206. * Updates a dynamic vertex buffer.
  86207. * @param vertexBuffer the vertex buffer to update
  86208. * @param data the data used to update the vertex buffer
  86209. * @param byteOffset the byte offset of the data
  86210. * @param byteLength the byte length of the data
  86211. */
  86212. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86213. private _resetIndexBufferBinding;
  86214. /**
  86215. * Creates a new index buffer
  86216. * @param indices defines the content of the index buffer
  86217. * @param updatable defines if the index buffer must be updatable
  86218. * @returns a new webGL buffer
  86219. */
  86220. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86221. /**
  86222. * Bind a webGL buffer to the webGL context
  86223. * @param buffer defines the buffer to bind
  86224. */
  86225. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86226. /**
  86227. * Bind an uniform buffer to the current webGL context
  86228. * @param buffer defines the buffer to bind
  86229. */
  86230. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86231. /**
  86232. * Bind a buffer to the current webGL context at a given location
  86233. * @param buffer defines the buffer to bind
  86234. * @param location defines the index where to bind the buffer
  86235. */
  86236. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86237. /**
  86238. * Bind a specific block at a given index in a specific shader program
  86239. * @param shaderProgram defines the shader program
  86240. * @param blockName defines the block name
  86241. * @param index defines the index where to bind the block
  86242. */
  86243. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86244. private bindIndexBuffer;
  86245. private bindBuffer;
  86246. /**
  86247. * update the bound buffer with the given data
  86248. * @param data defines the data to update
  86249. */
  86250. updateArrayBuffer(data: Float32Array): void;
  86251. private _vertexAttribPointer;
  86252. private _bindIndexBufferWithCache;
  86253. private _bindVertexBuffersAttributes;
  86254. /**
  86255. * Records a vertex array object
  86256. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86257. * @param vertexBuffers defines the list of vertex buffers to store
  86258. * @param indexBuffer defines the index buffer to store
  86259. * @param effect defines the effect to store
  86260. * @returns the new vertex array object
  86261. */
  86262. recordVertexArrayObject(vertexBuffers: {
  86263. [key: string]: VertexBuffer;
  86264. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86265. /**
  86266. * Bind a specific vertex array object
  86267. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86268. * @param vertexArrayObject defines the vertex array object to bind
  86269. * @param indexBuffer defines the index buffer to bind
  86270. */
  86271. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86272. /**
  86273. * Bind webGl buffers directly to the webGL context
  86274. * @param vertexBuffer defines the vertex buffer to bind
  86275. * @param indexBuffer defines the index buffer to bind
  86276. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86277. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86278. * @param effect defines the effect associated with the vertex buffer
  86279. */
  86280. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86281. private _unbindVertexArrayObject;
  86282. /**
  86283. * Bind a list of vertex buffers to the webGL context
  86284. * @param vertexBuffers defines the list of vertex buffers to bind
  86285. * @param indexBuffer defines the index buffer to bind
  86286. * @param effect defines the effect associated with the vertex buffers
  86287. */
  86288. bindBuffers(vertexBuffers: {
  86289. [key: string]: Nullable<VertexBuffer>;
  86290. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86291. /**
  86292. * Unbind all instance attributes
  86293. */
  86294. unbindInstanceAttributes(): void;
  86295. /**
  86296. * Release and free the memory of a vertex array object
  86297. * @param vao defines the vertex array object to delete
  86298. */
  86299. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86300. /** @hidden */
  86301. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86302. /**
  86303. * Creates a webGL buffer to use with instanciation
  86304. * @param capacity defines the size of the buffer
  86305. * @returns the webGL buffer
  86306. */
  86307. createInstancesBuffer(capacity: number): WebGLBuffer;
  86308. /**
  86309. * Delete a webGL buffer used with instanciation
  86310. * @param buffer defines the webGL buffer to delete
  86311. */
  86312. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86313. /**
  86314. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86315. * @param instancesBuffer defines the webGL buffer to update and bind
  86316. * @param data defines the data to store in the buffer
  86317. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86318. */
  86319. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86320. /**
  86321. * Apply all cached states (depth, culling, stencil and alpha)
  86322. */
  86323. applyStates(): void;
  86324. /**
  86325. * Send a draw order
  86326. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86327. * @param indexStart defines the starting index
  86328. * @param indexCount defines the number of index to draw
  86329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86330. */
  86331. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86332. /**
  86333. * Draw a list of points
  86334. * @param verticesStart defines the index of first vertex to draw
  86335. * @param verticesCount defines the count of vertices to draw
  86336. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86337. */
  86338. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86339. /**
  86340. * Draw a list of unindexed primitives
  86341. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86342. * @param verticesStart defines the index of first vertex to draw
  86343. * @param verticesCount defines the count of vertices to draw
  86344. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86345. */
  86346. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86347. /**
  86348. * Draw a list of indexed primitives
  86349. * @param fillMode defines the primitive to use
  86350. * @param indexStart defines the starting index
  86351. * @param indexCount defines the number of index to draw
  86352. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86353. */
  86354. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86355. /**
  86356. * Draw a list of unindexed primitives
  86357. * @param fillMode defines the primitive to use
  86358. * @param verticesStart defines the index of first vertex to draw
  86359. * @param verticesCount defines the count of vertices to draw
  86360. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86361. */
  86362. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86363. private _drawMode;
  86364. /** @hidden */
  86365. _releaseEffect(effect: Effect): void;
  86366. /** @hidden */
  86367. _deleteProgram(program: WebGLProgram): void;
  86368. /**
  86369. * Create a new effect (used to store vertex/fragment shaders)
  86370. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86371. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86372. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86373. * @param samplers defines an array of string used to represent textures
  86374. * @param defines defines the string containing the defines to use to compile the shaders
  86375. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86376. * @param onCompiled defines a function to call when the effect creation is successful
  86377. * @param onError defines a function to call when the effect creation has failed
  86378. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86379. * @returns the new Effect
  86380. */
  86381. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  86382. private _compileShader;
  86383. private _compileRawShader;
  86384. /**
  86385. * Directly creates a webGL program
  86386. * @param vertexCode defines the vertex shader code to use
  86387. * @param fragmentCode defines the fragment shader code to use
  86388. * @param context defines the webGL context to use (if not set, the current one will be used)
  86389. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86390. * @returns the new webGL program
  86391. */
  86392. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86393. /**
  86394. * Creates a webGL program
  86395. * @param vertexCode defines the vertex shader code to use
  86396. * @param fragmentCode defines the fragment shader code to use
  86397. * @param defines defines the string containing the defines to use to compile the shaders
  86398. * @param context defines the webGL context to use (if not set, the current one will be used)
  86399. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86400. * @returns the new webGL program
  86401. */
  86402. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86403. private _createShaderProgram;
  86404. private _finalizeProgram;
  86405. /** @hidden */
  86406. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86407. /** @hidden */
  86408. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86409. /**
  86410. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86411. * @param shaderProgram defines the webGL program to use
  86412. * @param uniformsNames defines the list of uniform names
  86413. * @returns an array of webGL uniform locations
  86414. */
  86415. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86416. /**
  86417. * Gets the lsit of active attributes for a given webGL program
  86418. * @param shaderProgram defines the webGL program to use
  86419. * @param attributesNames defines the list of attribute names to get
  86420. * @returns an array of indices indicating the offset of each attribute
  86421. */
  86422. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86423. /**
  86424. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86425. * @param effect defines the effect to activate
  86426. */
  86427. enableEffect(effect: Nullable<Effect>): void;
  86428. /**
  86429. * Set the value of an uniform to an array of int32
  86430. * @param uniform defines the webGL uniform location where to store the value
  86431. * @param array defines the array of int32 to store
  86432. */
  86433. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86434. /**
  86435. * Set the value of an uniform to an array of int32 (stored as vec2)
  86436. * @param uniform defines the webGL uniform location where to store the value
  86437. * @param array defines the array of int32 to store
  86438. */
  86439. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86440. /**
  86441. * Set the value of an uniform to an array of int32 (stored as vec3)
  86442. * @param uniform defines the webGL uniform location where to store the value
  86443. * @param array defines the array of int32 to store
  86444. */
  86445. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86446. /**
  86447. * Set the value of an uniform to an array of int32 (stored as vec4)
  86448. * @param uniform defines the webGL uniform location where to store the value
  86449. * @param array defines the array of int32 to store
  86450. */
  86451. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86452. /**
  86453. * Set the value of an uniform to an array of float32
  86454. * @param uniform defines the webGL uniform location where to store the value
  86455. * @param array defines the array of float32 to store
  86456. */
  86457. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86458. /**
  86459. * Set the value of an uniform to an array of float32 (stored as vec2)
  86460. * @param uniform defines the webGL uniform location where to store the value
  86461. * @param array defines the array of float32 to store
  86462. */
  86463. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86464. /**
  86465. * Set the value of an uniform to an array of float32 (stored as vec3)
  86466. * @param uniform defines the webGL uniform location where to store the value
  86467. * @param array defines the array of float32 to store
  86468. */
  86469. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86470. /**
  86471. * Set the value of an uniform to an array of float32 (stored as vec4)
  86472. * @param uniform defines the webGL uniform location where to store the value
  86473. * @param array defines the array of float32 to store
  86474. */
  86475. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86476. /**
  86477. * Set the value of an uniform to an array of number
  86478. * @param uniform defines the webGL uniform location where to store the value
  86479. * @param array defines the array of number to store
  86480. */
  86481. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86482. /**
  86483. * Set the value of an uniform to an array of number (stored as vec2)
  86484. * @param uniform defines the webGL uniform location where to store the value
  86485. * @param array defines the array of number to store
  86486. */
  86487. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86488. /**
  86489. * Set the value of an uniform to an array of number (stored as vec3)
  86490. * @param uniform defines the webGL uniform location where to store the value
  86491. * @param array defines the array of number to store
  86492. */
  86493. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86494. /**
  86495. * Set the value of an uniform to an array of number (stored as vec4)
  86496. * @param uniform defines the webGL uniform location where to store the value
  86497. * @param array defines the array of number to store
  86498. */
  86499. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86500. /**
  86501. * Set the value of an uniform to an array of float32 (stored as matrices)
  86502. * @param uniform defines the webGL uniform location where to store the value
  86503. * @param matrices defines the array of float32 to store
  86504. */
  86505. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86506. /**
  86507. * Set the value of an uniform to a matrix
  86508. * @param uniform defines the webGL uniform location where to store the value
  86509. * @param matrix defines the matrix to store
  86510. */
  86511. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86512. /**
  86513. * Set the value of an uniform to a matrix (3x3)
  86514. * @param uniform defines the webGL uniform location where to store the value
  86515. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86516. */
  86517. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86518. /**
  86519. * Set the value of an uniform to a matrix (2x2)
  86520. * @param uniform defines the webGL uniform location where to store the value
  86521. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86522. */
  86523. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86524. /**
  86525. * Set the value of an uniform to a number (int)
  86526. * @param uniform defines the webGL uniform location where to store the value
  86527. * @param value defines the int number to store
  86528. */
  86529. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86530. /**
  86531. * Set the value of an uniform to a number (float)
  86532. * @param uniform defines the webGL uniform location where to store the value
  86533. * @param value defines the float number to store
  86534. */
  86535. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86536. /**
  86537. * Set the value of an uniform to a vec2
  86538. * @param uniform defines the webGL uniform location where to store the value
  86539. * @param x defines the 1st component of the value
  86540. * @param y defines the 2nd component of the value
  86541. */
  86542. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86543. /**
  86544. * Set the value of an uniform to a vec3
  86545. * @param uniform defines the webGL uniform location where to store the value
  86546. * @param x defines the 1st component of the value
  86547. * @param y defines the 2nd component of the value
  86548. * @param z defines the 3rd component of the value
  86549. */
  86550. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86551. /**
  86552. * Set the value of an uniform to a boolean
  86553. * @param uniform defines the webGL uniform location where to store the value
  86554. * @param bool defines the boolean to store
  86555. */
  86556. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86557. /**
  86558. * Set the value of an uniform to a vec4
  86559. * @param uniform defines the webGL uniform location where to store the value
  86560. * @param x defines the 1st component of the value
  86561. * @param y defines the 2nd component of the value
  86562. * @param z defines the 3rd component of the value
  86563. * @param w defines the 4th component of the value
  86564. */
  86565. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86566. /**
  86567. * Set the value of an uniform to a Color3
  86568. * @param uniform defines the webGL uniform location where to store the value
  86569. * @param color3 defines the color to store
  86570. */
  86571. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86572. /**
  86573. * Set the value of an uniform to a Color3 and an alpha value
  86574. * @param uniform defines the webGL uniform location where to store the value
  86575. * @param color3 defines the color to store
  86576. * @param alpha defines the alpha component to store
  86577. */
  86578. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86579. /**
  86580. * Sets a Color4 on a uniform variable
  86581. * @param uniform defines the uniform location
  86582. * @param color4 defines the value to be set
  86583. */
  86584. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86585. /**
  86586. * Set various states to the webGL context
  86587. * @param culling defines backface culling state
  86588. * @param zOffset defines the value to apply to zOffset (0 by default)
  86589. * @param force defines if states must be applied even if cache is up to date
  86590. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86591. */
  86592. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86593. /**
  86594. * Set the z offset to apply to current rendering
  86595. * @param value defines the offset to apply
  86596. */
  86597. setZOffset(value: number): void;
  86598. /**
  86599. * Gets the current value of the zOffset
  86600. * @returns the current zOffset state
  86601. */
  86602. getZOffset(): number;
  86603. /**
  86604. * Enable or disable depth buffering
  86605. * @param enable defines the state to set
  86606. */
  86607. setDepthBuffer(enable: boolean): void;
  86608. /**
  86609. * Gets a boolean indicating if depth writing is enabled
  86610. * @returns the current depth writing state
  86611. */
  86612. getDepthWrite(): boolean;
  86613. /**
  86614. * Enable or disable depth writing
  86615. * @param enable defines the state to set
  86616. */
  86617. setDepthWrite(enable: boolean): void;
  86618. /**
  86619. * Enable or disable color writing
  86620. * @param enable defines the state to set
  86621. */
  86622. setColorWrite(enable: boolean): void;
  86623. /**
  86624. * Gets a boolean indicating if color writing is enabled
  86625. * @returns the current color writing state
  86626. */
  86627. getColorWrite(): boolean;
  86628. /**
  86629. * Sets alpha constants used by some alpha blending modes
  86630. * @param r defines the red component
  86631. * @param g defines the green component
  86632. * @param b defines the blue component
  86633. * @param a defines the alpha component
  86634. */
  86635. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86636. /**
  86637. * Sets the current alpha mode
  86638. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86639. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86641. */
  86642. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86643. /**
  86644. * Gets the current alpha mode
  86645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86646. * @returns the current alpha mode
  86647. */
  86648. getAlphaMode(): number;
  86649. /**
  86650. * Clears the list of texture accessible through engine.
  86651. * This can help preventing texture load conflict due to name collision.
  86652. */
  86653. clearInternalTexturesCache(): void;
  86654. /**
  86655. * Force the entire cache to be cleared
  86656. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86657. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86658. */
  86659. wipeCaches(bruteForce?: boolean): void;
  86660. /**
  86661. * Set the compressed texture format to use, based on the formats you have, and the formats
  86662. * supported by the hardware / browser.
  86663. *
  86664. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  86665. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  86666. * to API arguments needed to compressed textures. This puts the burden on the container
  86667. * generator to house the arcane code for determining these for current & future formats.
  86668. *
  86669. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  86670. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  86671. *
  86672. * Note: The result of this call is not taken into account when a texture is base64.
  86673. *
  86674. * @param formatsAvailable defines the list of those format families you have created
  86675. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  86676. *
  86677. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  86678. * @returns The extension selected.
  86679. */
  86680. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  86681. private _getSamplingParameters;
  86682. private _partialLoadImg;
  86683. private _cascadeLoadImgs;
  86684. /** @hidden */
  86685. _createTexture(): WebGLTexture;
  86686. /**
  86687. * Usually called from Texture.ts.
  86688. * Passed information to create a WebGLTexture
  86689. * @param urlArg defines a value which contains one of the following:
  86690. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  86691. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  86692. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  86693. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  86694. * @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)
  86695. * @param scene needed for loading to the correct scene
  86696. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  86697. * @param onLoad optional callback to be called upon successful completion
  86698. * @param onError optional callback to be called upon failure
  86699. * @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
  86700. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  86701. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  86702. * @param forcedExtension defines the extension to use to pick the right loader
  86703. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  86704. * @returns a InternalTexture for assignment back into BABYLON.Texture
  86705. */
  86706. 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 | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  86707. private _rescaleTexture;
  86708. /**
  86709. * Update a raw texture
  86710. * @param texture defines the texture to update
  86711. * @param data defines the data to store in the texture
  86712. * @param format defines the format of the data
  86713. * @param invertY defines if data must be stored with Y axis inverted
  86714. * @param compression defines the compression used (null by default)
  86715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86716. */
  86717. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  86718. /**
  86719. * Creates a raw texture
  86720. * @param data defines the data to store in the texture
  86721. * @param width defines the width of the texture
  86722. * @param height defines the height of the texture
  86723. * @param format defines the format of the data
  86724. * @param generateMipMaps defines if the engine should generate the mip levels
  86725. * @param invertY defines if data must be stored with Y axis inverted
  86726. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86727. * @param compression defines the compression used (null by default)
  86728. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86729. * @returns the raw texture inside an InternalTexture
  86730. */
  86731. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  86732. private _unpackFlipYCached;
  86733. /**
  86734. * In case you are sharing the context with other applications, it might
  86735. * be interested to not cache the unpack flip y state to ensure a consistent
  86736. * value would be set.
  86737. */
  86738. enableUnpackFlipYCached: boolean;
  86739. /** @hidden */
  86740. _unpackFlipY(value: boolean): void;
  86741. /** @hidden */
  86742. _getUnpackAlignement(): number;
  86743. /**
  86744. * Creates a dynamic texture
  86745. * @param width defines the width of the texture
  86746. * @param height defines the height of the texture
  86747. * @param generateMipMaps defines if the engine should generate the mip levels
  86748. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86749. * @returns the dynamic texture inside an InternalTexture
  86750. */
  86751. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86752. /**
  86753. * Update the sampling mode of a given texture
  86754. * @param samplingMode defines the required sampling mode
  86755. * @param texture defines the texture to update
  86756. */
  86757. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  86758. /**
  86759. * Update the content of a dynamic texture
  86760. * @param texture defines the texture to update
  86761. * @param canvas defines the canvas containing the source
  86762. * @param invertY defines if data must be stored with Y axis inverted
  86763. * @param premulAlpha defines if alpha is stored as premultiplied
  86764. * @param format defines the format of the data
  86765. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86766. */
  86767. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86768. /**
  86769. * Update a video texture
  86770. * @param texture defines the texture to update
  86771. * @param video defines the video element to use
  86772. * @param invertY defines if data must be stored with Y axis inverted
  86773. */
  86774. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  86775. /**
  86776. * Updates a depth texture Comparison Mode and Function.
  86777. * If the comparison Function is equal to 0, the mode will be set to none.
  86778. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  86779. * @param texture The texture to set the comparison function for
  86780. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  86781. */
  86782. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  86783. private _setupDepthStencilTexture;
  86784. /**
  86785. * Creates a depth stencil texture.
  86786. * This is only available in WebGL 2 or with the depth texture extension available.
  86787. * @param size The size of face edge in the texture.
  86788. * @param options The options defining the texture.
  86789. * @returns The texture
  86790. */
  86791. createDepthStencilTexture(size: number | {
  86792. width: number;
  86793. height: number;
  86794. }, options: DepthTextureCreationOptions): InternalTexture;
  86795. /**
  86796. * Creates a depth stencil texture.
  86797. * This is only available in WebGL 2 or with the depth texture extension available.
  86798. * @param size The size of face edge in the texture.
  86799. * @param options The options defining the texture.
  86800. * @returns The texture
  86801. */
  86802. private _createDepthStencilTexture;
  86803. /**
  86804. * Creates a depth stencil cube texture.
  86805. * This is only available in WebGL 2.
  86806. * @param size The size of face edge in the cube texture.
  86807. * @param options The options defining the cube texture.
  86808. * @returns The cube texture
  86809. */
  86810. private _createDepthStencilCubeTexture;
  86811. /**
  86812. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  86813. * @param renderTarget The render target to set the frame buffer for
  86814. */
  86815. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  86816. /**
  86817. * Creates a new render target texture
  86818. * @param size defines the size of the texture
  86819. * @param options defines the options used to create the texture
  86820. * @returns a new render target texture stored in an InternalTexture
  86821. */
  86822. createRenderTargetTexture(size: number | {
  86823. width: number;
  86824. height: number;
  86825. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86826. /**
  86827. * Create a multi render target texture
  86828. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  86829. * @param size defines the size of the texture
  86830. * @param options defines the creation options
  86831. * @returns the cube texture as an InternalTexture
  86832. */
  86833. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  86834. private _setupFramebufferDepthAttachments;
  86835. /**
  86836. * Updates the sample count of a render target texture
  86837. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86838. * @param texture defines the texture to update
  86839. * @param samples defines the sample count to set
  86840. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86841. */
  86842. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  86843. /**
  86844. * Update the sample count for a given multiple render target texture
  86845. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86846. * @param textures defines the textures to update
  86847. * @param samples defines the sample count to set
  86848. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86849. */
  86850. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  86851. /** @hidden */
  86852. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86853. /** @hidden */
  86854. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86855. /** @hidden */
  86856. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86857. /** @hidden */
  86858. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  86859. /**
  86860. * Creates a new render target cube texture
  86861. * @param size defines the size of the texture
  86862. * @param options defines the options used to create the texture
  86863. * @returns a new render target cube texture stored in an InternalTexture
  86864. */
  86865. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86866. /**
  86867. * Creates a cube texture
  86868. * @param rootUrl defines the url where the files to load is located
  86869. * @param scene defines the current scene
  86870. * @param files defines the list of files to load (1 per face)
  86871. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86872. * @param onLoad defines an optional callback raised when the texture is loaded
  86873. * @param onError defines an optional callback raised if there is an issue to load the texture
  86874. * @param format defines the format of the data
  86875. * @param forcedExtension defines the extension to use to pick the right loader
  86876. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86877. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86878. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86879. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86880. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  86881. * @returns the cube texture as an InternalTexture
  86882. */
  86883. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  86884. /**
  86885. * @hidden
  86886. */
  86887. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86888. /**
  86889. * Update a raw cube texture
  86890. * @param texture defines the texture to udpdate
  86891. * @param data defines the data to store
  86892. * @param format defines the data format
  86893. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86894. * @param invertY defines if data must be stored with Y axis inverted
  86895. * @param compression defines the compression used (null by default)
  86896. * @param level defines which level of the texture to update
  86897. */
  86898. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  86899. /**
  86900. * Creates a new raw cube texture
  86901. * @param data defines the array of data to use to create each face
  86902. * @param size defines the size of the textures
  86903. * @param format defines the format of the data
  86904. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86905. * @param generateMipMaps defines if the engine should generate the mip levels
  86906. * @param invertY defines if data must be stored with Y axis inverted
  86907. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86908. * @param compression defines the compression used (null by default)
  86909. * @returns the cube texture as an InternalTexture
  86910. */
  86911. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  86912. /**
  86913. * Creates a new raw cube texture from a specified url
  86914. * @param url defines the url where the data is located
  86915. * @param scene defines the current scene
  86916. * @param size defines the size of the textures
  86917. * @param format defines the format of the data
  86918. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86919. * @param noMipmap defines if the engine should avoid generating the mip levels
  86920. * @param callback defines a callback used to extract texture data from loaded data
  86921. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86922. * @param onLoad defines a callback called when texture is loaded
  86923. * @param onError defines a callback called if there is an error
  86924. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86925. * @param invertY defines if data must be stored with Y axis inverted
  86926. * @returns the cube texture as an InternalTexture
  86927. */
  86928. 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;
  86929. /**
  86930. * Update a raw 3D texture
  86931. * @param texture defines the texture to update
  86932. * @param data defines the data to store
  86933. * @param format defines the data format
  86934. * @param invertY defines if data must be stored with Y axis inverted
  86935. * @param compression defines the used compression (can be null)
  86936. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86937. */
  86938. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  86939. /**
  86940. * Creates a new raw 3D texture
  86941. * @param data defines the data used to create the texture
  86942. * @param width defines the width of the texture
  86943. * @param height defines the height of the texture
  86944. * @param depth defines the depth of the texture
  86945. * @param format defines the format of the texture
  86946. * @param generateMipMaps defines if the engine must generate mip levels
  86947. * @param invertY defines if data must be stored with Y axis inverted
  86948. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86949. * @param compression defines the compressed used (can be null)
  86950. * @param textureType defines the compressed used (can be null)
  86951. * @returns a new raw 3D texture (stored in an InternalTexture)
  86952. */
  86953. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86954. private _prepareWebGLTextureContinuation;
  86955. private _prepareWebGLTexture;
  86956. private _convertRGBtoRGBATextureData;
  86957. /** @hidden */
  86958. _releaseFramebufferObjects(texture: InternalTexture): void;
  86959. /** @hidden */
  86960. _releaseTexture(texture: InternalTexture): void;
  86961. private setProgram;
  86962. private _boundUniforms;
  86963. /**
  86964. * Binds an effect to the webGL context
  86965. * @param effect defines the effect to bind
  86966. */
  86967. bindSamplers(effect: Effect): void;
  86968. private _moveBoundTextureOnTop;
  86969. private _getCorrectTextureChannel;
  86970. private _linkTrackers;
  86971. private _removeDesignatedSlot;
  86972. private _activateCurrentTexture;
  86973. /** @hidden */
  86974. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86975. /** @hidden */
  86976. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86977. /**
  86978. * Sets a texture to the webGL context from a postprocess
  86979. * @param channel defines the channel to use
  86980. * @param postProcess defines the source postprocess
  86981. */
  86982. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86983. /**
  86984. * Binds the output of the passed in post process to the texture channel specified
  86985. * @param channel The channel the texture should be bound to
  86986. * @param postProcess The post process which's output should be bound
  86987. */
  86988. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86989. /**
  86990. * Unbind all textures from the webGL context
  86991. */
  86992. unbindAllTextures(): void;
  86993. /**
  86994. * Sets a texture to the according uniform.
  86995. * @param channel The texture channel
  86996. * @param uniform The uniform to set
  86997. * @param texture The texture to apply
  86998. */
  86999. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  87000. /**
  87001. * Sets a depth stencil texture from a render target to the according uniform.
  87002. * @param channel The texture channel
  87003. * @param uniform The uniform to set
  87004. * @param texture The render target texture containing the depth stencil texture to apply
  87005. */
  87006. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  87007. private _bindSamplerUniformToChannel;
  87008. private _getTextureWrapMode;
  87009. private _setTexture;
  87010. /**
  87011. * Sets an array of texture to the webGL context
  87012. * @param channel defines the channel where the texture array must be set
  87013. * @param uniform defines the associated uniform location
  87014. * @param textures defines the array of textures to bind
  87015. */
  87016. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  87017. /** @hidden */
  87018. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  87019. private _setTextureParameterFloat;
  87020. private _setTextureParameterInteger;
  87021. /**
  87022. * Reads pixels from the current frame buffer. Please note that this function can be slow
  87023. * @param x defines the x coordinate of the rectangle where pixels must be read
  87024. * @param y defines the y coordinate of the rectangle where pixels must be read
  87025. * @param width defines the width of the rectangle where pixels must be read
  87026. * @param height defines the height of the rectangle where pixels must be read
  87027. * @returns a Uint8Array containing RGBA colors
  87028. */
  87029. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  87030. /**
  87031. * Add an externaly attached data from its key.
  87032. * This method call will fail and return false, if such key already exists.
  87033. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  87034. * @param key the unique key that identifies the data
  87035. * @param data the data object to associate to the key for this Engine instance
  87036. * @return true if no such key were already present and the data was added successfully, false otherwise
  87037. */
  87038. addExternalData<T>(key: string, data: T): boolean;
  87039. /**
  87040. * Get an externaly attached data from its key
  87041. * @param key the unique key that identifies the data
  87042. * @return the associated data, if present (can be null), or undefined if not present
  87043. */
  87044. getExternalData<T>(key: string): T;
  87045. /**
  87046. * Get an externaly attached data from its key, create it using a factory if it's not already present
  87047. * @param key the unique key that identifies the data
  87048. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  87049. * @return the associated data, can be null if the factory returned null.
  87050. */
  87051. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  87052. /**
  87053. * Remove an externaly attached data from the Engine instance
  87054. * @param key the unique key that identifies the data
  87055. * @return true if the data was successfully removed, false if it doesn't exist
  87056. */
  87057. removeExternalData(key: string): boolean;
  87058. /**
  87059. * Unbind all vertex attributes from the webGL context
  87060. */
  87061. unbindAllAttributes(): void;
  87062. /**
  87063. * 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
  87064. */
  87065. releaseEffects(): void;
  87066. /**
  87067. * Dispose and release all associated resources
  87068. */
  87069. dispose(): void;
  87070. /**
  87071. * Display the loading screen
  87072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87073. */
  87074. displayLoadingUI(): void;
  87075. /**
  87076. * Hide the loading screen
  87077. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87078. */
  87079. hideLoadingUI(): void;
  87080. /**
  87081. * Gets the current loading screen object
  87082. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87083. */
  87084. /**
  87085. * Sets the current loading screen object
  87086. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87087. */
  87088. loadingScreen: ILoadingScreen;
  87089. /**
  87090. * Sets the current loading screen text
  87091. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87092. */
  87093. loadingUIText: string;
  87094. /**
  87095. * Sets the current loading screen background color
  87096. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87097. */
  87098. loadingUIBackgroundColor: string;
  87099. /**
  87100. * Attach a new callback raised when context lost event is fired
  87101. * @param callback defines the callback to call
  87102. */
  87103. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87104. /**
  87105. * Attach a new callback raised when context restored event is fired
  87106. * @param callback defines the callback to call
  87107. */
  87108. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87109. /**
  87110. * Gets the source code of the vertex shader associated with a specific webGL program
  87111. * @param program defines the program to use
  87112. * @returns a string containing the source code of the vertex shader associated with the program
  87113. */
  87114. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87115. /**
  87116. * Gets the source code of the fragment shader associated with a specific webGL program
  87117. * @param program defines the program to use
  87118. * @returns a string containing the source code of the fragment shader associated with the program
  87119. */
  87120. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87121. /**
  87122. * Get the current error code of the webGL context
  87123. * @returns the error code
  87124. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87125. */
  87126. getError(): number;
  87127. /**
  87128. * Gets the current framerate
  87129. * @returns a number representing the framerate
  87130. */
  87131. getFps(): number;
  87132. /**
  87133. * Gets the time spent between current and previous frame
  87134. * @returns a number representing the delta time in ms
  87135. */
  87136. getDeltaTime(): number;
  87137. private _measureFps;
  87138. /** @hidden */
  87139. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87140. private _canRenderToFloatFramebuffer;
  87141. private _canRenderToHalfFloatFramebuffer;
  87142. private _canRenderToFramebuffer;
  87143. /** @hidden */
  87144. _getWebGLTextureType(type: number): number;
  87145. private _getInternalFormat;
  87146. /** @hidden */
  87147. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87148. /** @hidden */
  87149. _getRGBAMultiSampleBufferFormat(type: number): number;
  87150. /** @hidden */
  87151. _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;
  87152. /** @hidden */
  87153. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87154. private _partialLoadFile;
  87155. private _cascadeLoadFiles;
  87156. /**
  87157. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87158. * @returns true if the engine can be created
  87159. * @ignorenaming
  87160. */
  87161. static isSupported(): boolean;
  87162. }
  87163. }
  87164. declare module BABYLON {
  87165. /**
  87166. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87167. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87168. */
  87169. export class EffectFallbacks {
  87170. private _defines;
  87171. private _currentRank;
  87172. private _maxRank;
  87173. private _mesh;
  87174. /**
  87175. * Removes the fallback from the bound mesh.
  87176. */
  87177. unBindMesh(): void;
  87178. /**
  87179. * Adds a fallback on the specified property.
  87180. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87181. * @param define The name of the define in the shader
  87182. */
  87183. addFallback(rank: number, define: string): void;
  87184. /**
  87185. * Sets the mesh to use CPU skinning when needing to fallback.
  87186. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87187. * @param mesh The mesh to use the fallbacks.
  87188. */
  87189. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87190. /**
  87191. * Checks to see if more fallbacks are still availible.
  87192. */
  87193. readonly isMoreFallbacks: boolean;
  87194. /**
  87195. * Removes the defines that shoould be removed when falling back.
  87196. * @param currentDefines defines the current define statements for the shader.
  87197. * @param effect defines the current effect we try to compile
  87198. * @returns The resulting defines with defines of the current rank removed.
  87199. */
  87200. reduce(currentDefines: string, effect: Effect): string;
  87201. }
  87202. /**
  87203. * Options to be used when creating an effect.
  87204. */
  87205. export class EffectCreationOptions {
  87206. /**
  87207. * Atrributes that will be used in the shader.
  87208. */
  87209. attributes: string[];
  87210. /**
  87211. * Uniform varible names that will be set in the shader.
  87212. */
  87213. uniformsNames: string[];
  87214. /**
  87215. * Uniform buffer varible names that will be set in the shader.
  87216. */
  87217. uniformBuffersNames: string[];
  87218. /**
  87219. * Sampler texture variable names that will be set in the shader.
  87220. */
  87221. samplers: string[];
  87222. /**
  87223. * Define statements that will be set in the shader.
  87224. */
  87225. defines: any;
  87226. /**
  87227. * Possible fallbacks for this effect to improve performance when needed.
  87228. */
  87229. fallbacks: Nullable<EffectFallbacks>;
  87230. /**
  87231. * Callback that will be called when the shader is compiled.
  87232. */
  87233. onCompiled: Nullable<(effect: Effect) => void>;
  87234. /**
  87235. * Callback that will be called if an error occurs during shader compilation.
  87236. */
  87237. onError: Nullable<(effect: Effect, errors: string) => void>;
  87238. /**
  87239. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87240. */
  87241. indexParameters: any;
  87242. /**
  87243. * Max number of lights that can be used in the shader.
  87244. */
  87245. maxSimultaneousLights: number;
  87246. /**
  87247. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87248. */
  87249. transformFeedbackVaryings: Nullable<string[]>;
  87250. }
  87251. /**
  87252. * Effect containing vertex and fragment shader that can be executed on an object.
  87253. */
  87254. export class Effect {
  87255. /**
  87256. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87257. */
  87258. static ShadersRepository: string;
  87259. /**
  87260. * Name of the effect.
  87261. */
  87262. name: any;
  87263. /**
  87264. * String container all the define statements that should be set on the shader.
  87265. */
  87266. defines: string;
  87267. /**
  87268. * Callback that will be called when the shader is compiled.
  87269. */
  87270. onCompiled: Nullable<(effect: Effect) => void>;
  87271. /**
  87272. * Callback that will be called if an error occurs during shader compilation.
  87273. */
  87274. onError: Nullable<(effect: Effect, errors: string) => void>;
  87275. /**
  87276. * Callback that will be called when effect is bound.
  87277. */
  87278. onBind: Nullable<(effect: Effect) => void>;
  87279. /**
  87280. * Unique ID of the effect.
  87281. */
  87282. uniqueId: number;
  87283. /**
  87284. * Observable that will be called when the shader is compiled.
  87285. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87286. */
  87287. onCompileObservable: Observable<Effect>;
  87288. /**
  87289. * Observable that will be called if an error occurs during shader compilation.
  87290. */
  87291. onErrorObservable: Observable<Effect>;
  87292. /** @hidden */
  87293. _onBindObservable: Nullable<Observable<Effect>>;
  87294. /**
  87295. * Observable that will be called when effect is bound.
  87296. */
  87297. readonly onBindObservable: Observable<Effect>;
  87298. /** @hidden */
  87299. _bonesComputationForcedToCPU: boolean;
  87300. private static _uniqueIdSeed;
  87301. private _engine;
  87302. private _uniformBuffersNames;
  87303. private _uniformsNames;
  87304. private _samplers;
  87305. private _isReady;
  87306. private _compilationError;
  87307. private _attributesNames;
  87308. private _attributes;
  87309. private _uniforms;
  87310. /**
  87311. * Key for the effect.
  87312. * @hidden
  87313. */
  87314. _key: string;
  87315. private _indexParameters;
  87316. private _fallbacks;
  87317. private _vertexSourceCode;
  87318. private _fragmentSourceCode;
  87319. private _vertexSourceCodeOverride;
  87320. private _fragmentSourceCodeOverride;
  87321. private _transformFeedbackVaryings;
  87322. /**
  87323. * Compiled shader to webGL program.
  87324. * @hidden
  87325. */
  87326. _program: WebGLProgram;
  87327. private _valueCache;
  87328. private static _baseCache;
  87329. /**
  87330. * Instantiates an effect.
  87331. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87332. * @param baseName Name of the effect.
  87333. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87334. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87335. * @param samplers List of sampler variables that will be passed to the shader.
  87336. * @param engine Engine to be used to render the effect
  87337. * @param defines Define statements to be added to the shader.
  87338. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87339. * @param onCompiled Callback that will be called when the shader is compiled.
  87340. * @param onError Callback that will be called if an error occurs during shader compilation.
  87341. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87342. */
  87343. 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);
  87344. /**
  87345. * Unique key for this effect
  87346. */
  87347. readonly key: string;
  87348. /**
  87349. * If the effect has been compiled and prepared.
  87350. * @returns if the effect is compiled and prepared.
  87351. */
  87352. isReady(): boolean;
  87353. /**
  87354. * The engine the effect was initialized with.
  87355. * @returns the engine.
  87356. */
  87357. getEngine(): Engine;
  87358. /**
  87359. * The compiled webGL program for the effect
  87360. * @returns the webGL program.
  87361. */
  87362. getProgram(): WebGLProgram;
  87363. /**
  87364. * The set of names of attribute variables for the shader.
  87365. * @returns An array of attribute names.
  87366. */
  87367. getAttributesNames(): string[];
  87368. /**
  87369. * Returns the attribute at the given index.
  87370. * @param index The index of the attribute.
  87371. * @returns The location of the attribute.
  87372. */
  87373. getAttributeLocation(index: number): number;
  87374. /**
  87375. * Returns the attribute based on the name of the variable.
  87376. * @param name of the attribute to look up.
  87377. * @returns the attribute location.
  87378. */
  87379. getAttributeLocationByName(name: string): number;
  87380. /**
  87381. * The number of attributes.
  87382. * @returns the numnber of attributes.
  87383. */
  87384. getAttributesCount(): number;
  87385. /**
  87386. * Gets the index of a uniform variable.
  87387. * @param uniformName of the uniform to look up.
  87388. * @returns the index.
  87389. */
  87390. getUniformIndex(uniformName: string): number;
  87391. /**
  87392. * Returns the attribute based on the name of the variable.
  87393. * @param uniformName of the uniform to look up.
  87394. * @returns the location of the uniform.
  87395. */
  87396. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87397. /**
  87398. * Returns an array of sampler variable names
  87399. * @returns The array of sampler variable neames.
  87400. */
  87401. getSamplers(): string[];
  87402. /**
  87403. * The error from the last compilation.
  87404. * @returns the error string.
  87405. */
  87406. getCompilationError(): string;
  87407. /**
  87408. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87409. * @param func The callback to be used.
  87410. */
  87411. executeWhenCompiled(func: (effect: Effect) => void): void;
  87412. private _checkIsReady;
  87413. /** @hidden */
  87414. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87415. /** @hidden */
  87416. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87417. /** @hidden */
  87418. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87419. private _processShaderConversion;
  87420. private _processIncludes;
  87421. private _processPrecision;
  87422. /**
  87423. * Recompiles the webGL program
  87424. * @param vertexSourceCode The source code for the vertex shader.
  87425. * @param fragmentSourceCode The source code for the fragment shader.
  87426. * @param onCompiled Callback called when completed.
  87427. * @param onError Callback called on error.
  87428. * @hidden
  87429. */
  87430. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87431. /**
  87432. * Gets the uniform locations of the the specified variable names
  87433. * @param names THe names of the variables to lookup.
  87434. * @returns Array of locations in the same order as variable names.
  87435. */
  87436. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87437. /**
  87438. * Prepares the effect
  87439. * @hidden
  87440. */
  87441. _prepareEffect(): void;
  87442. /**
  87443. * Checks if the effect is supported. (Must be called after compilation)
  87444. */
  87445. readonly isSupported: boolean;
  87446. /**
  87447. * Binds a texture to the engine to be used as output of the shader.
  87448. * @param channel Name of the output variable.
  87449. * @param texture Texture to bind.
  87450. * @hidden
  87451. */
  87452. _bindTexture(channel: string, texture: InternalTexture): void;
  87453. /**
  87454. * Sets a texture on the engine to be used in the shader.
  87455. * @param channel Name of the sampler variable.
  87456. * @param texture Texture to set.
  87457. */
  87458. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87459. /**
  87460. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87461. * @param channel Name of the sampler variable.
  87462. * @param texture Texture to set.
  87463. */
  87464. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87465. /**
  87466. * Sets an array of textures on the engine to be used in the shader.
  87467. * @param channel Name of the variable.
  87468. * @param textures Textures to set.
  87469. */
  87470. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87471. /**
  87472. * 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)
  87473. * @param channel Name of the sampler variable.
  87474. * @param postProcess Post process to get the input texture from.
  87475. */
  87476. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87477. /**
  87478. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87479. * 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)
  87480. * @param channel Name of the sampler variable.
  87481. * @param postProcess Post process to get the output texture from.
  87482. */
  87483. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87484. /** @hidden */
  87485. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87486. /** @hidden */
  87487. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87488. /** @hidden */
  87489. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87490. /** @hidden */
  87491. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87492. /**
  87493. * Binds a buffer to a uniform.
  87494. * @param buffer Buffer to bind.
  87495. * @param name Name of the uniform variable to bind to.
  87496. */
  87497. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87498. /**
  87499. * Binds block to a uniform.
  87500. * @param blockName Name of the block to bind.
  87501. * @param index Index to bind.
  87502. */
  87503. bindUniformBlock(blockName: string, index: number): void;
  87504. /**
  87505. * Sets an interger value on a uniform variable.
  87506. * @param uniformName Name of the variable.
  87507. * @param value Value to be set.
  87508. * @returns this effect.
  87509. */
  87510. setInt(uniformName: string, value: number): Effect;
  87511. /**
  87512. * Sets an int array on a uniform variable.
  87513. * @param uniformName Name of the variable.
  87514. * @param array array to be set.
  87515. * @returns this effect.
  87516. */
  87517. setIntArray(uniformName: string, array: Int32Array): Effect;
  87518. /**
  87519. * 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)
  87520. * @param uniformName Name of the variable.
  87521. * @param array array to be set.
  87522. * @returns this effect.
  87523. */
  87524. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87525. /**
  87526. * 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)
  87527. * @param uniformName Name of the variable.
  87528. * @param array array to be set.
  87529. * @returns this effect.
  87530. */
  87531. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87532. /**
  87533. * 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)
  87534. * @param uniformName Name of the variable.
  87535. * @param array array to be set.
  87536. * @returns this effect.
  87537. */
  87538. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87539. /**
  87540. * Sets an float array on a uniform variable.
  87541. * @param uniformName Name of the variable.
  87542. * @param array array to be set.
  87543. * @returns this effect.
  87544. */
  87545. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87546. /**
  87547. * 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)
  87548. * @param uniformName Name of the variable.
  87549. * @param array array to be set.
  87550. * @returns this effect.
  87551. */
  87552. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87553. /**
  87554. * 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)
  87555. * @param uniformName Name of the variable.
  87556. * @param array array to be set.
  87557. * @returns this effect.
  87558. */
  87559. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87560. /**
  87561. * 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)
  87562. * @param uniformName Name of the variable.
  87563. * @param array array to be set.
  87564. * @returns this effect.
  87565. */
  87566. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87567. /**
  87568. * Sets an array on a uniform variable.
  87569. * @param uniformName Name of the variable.
  87570. * @param array array to be set.
  87571. * @returns this effect.
  87572. */
  87573. setArray(uniformName: string, array: number[]): Effect;
  87574. /**
  87575. * 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)
  87576. * @param uniformName Name of the variable.
  87577. * @param array array to be set.
  87578. * @returns this effect.
  87579. */
  87580. setArray2(uniformName: string, array: number[]): Effect;
  87581. /**
  87582. * 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)
  87583. * @param uniformName Name of the variable.
  87584. * @param array array to be set.
  87585. * @returns this effect.
  87586. */
  87587. setArray3(uniformName: string, array: number[]): Effect;
  87588. /**
  87589. * 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)
  87590. * @param uniformName Name of the variable.
  87591. * @param array array to be set.
  87592. * @returns this effect.
  87593. */
  87594. setArray4(uniformName: string, array: number[]): Effect;
  87595. /**
  87596. * Sets matrices on a uniform variable.
  87597. * @param uniformName Name of the variable.
  87598. * @param matrices matrices to be set.
  87599. * @returns this effect.
  87600. */
  87601. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87602. /**
  87603. * Sets matrix on a uniform variable.
  87604. * @param uniformName Name of the variable.
  87605. * @param matrix matrix to be set.
  87606. * @returns this effect.
  87607. */
  87608. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87609. /**
  87610. * 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)
  87611. * @param uniformName Name of the variable.
  87612. * @param matrix matrix to be set.
  87613. * @returns this effect.
  87614. */
  87615. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87616. /**
  87617. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87618. * @param uniformName Name of the variable.
  87619. * @param matrix matrix to be set.
  87620. * @returns this effect.
  87621. */
  87622. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87623. /**
  87624. * Sets a float on a uniform variable.
  87625. * @param uniformName Name of the variable.
  87626. * @param value value to be set.
  87627. * @returns this effect.
  87628. */
  87629. setFloat(uniformName: string, value: number): Effect;
  87630. /**
  87631. * Sets a boolean on a uniform variable.
  87632. * @param uniformName Name of the variable.
  87633. * @param bool value to be set.
  87634. * @returns this effect.
  87635. */
  87636. setBool(uniformName: string, bool: boolean): Effect;
  87637. /**
  87638. * Sets a Vector2 on a uniform variable.
  87639. * @param uniformName Name of the variable.
  87640. * @param vector2 vector2 to be set.
  87641. * @returns this effect.
  87642. */
  87643. setVector2(uniformName: string, vector2: Vector2): Effect;
  87644. /**
  87645. * Sets a float2 on a uniform variable.
  87646. * @param uniformName Name of the variable.
  87647. * @param x First float in float2.
  87648. * @param y Second float in float2.
  87649. * @returns this effect.
  87650. */
  87651. setFloat2(uniformName: string, x: number, y: number): Effect;
  87652. /**
  87653. * Sets a Vector3 on a uniform variable.
  87654. * @param uniformName Name of the variable.
  87655. * @param vector3 Value to be set.
  87656. * @returns this effect.
  87657. */
  87658. setVector3(uniformName: string, vector3: Vector3): Effect;
  87659. /**
  87660. * Sets a float3 on a uniform variable.
  87661. * @param uniformName Name of the variable.
  87662. * @param x First float in float3.
  87663. * @param y Second float in float3.
  87664. * @param z Third float in float3.
  87665. * @returns this effect.
  87666. */
  87667. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  87668. /**
  87669. * Sets a Vector4 on a uniform variable.
  87670. * @param uniformName Name of the variable.
  87671. * @param vector4 Value to be set.
  87672. * @returns this effect.
  87673. */
  87674. setVector4(uniformName: string, vector4: Vector4): Effect;
  87675. /**
  87676. * Sets a float4 on a uniform variable.
  87677. * @param uniformName Name of the variable.
  87678. * @param x First float in float4.
  87679. * @param y Second float in float4.
  87680. * @param z Third float in float4.
  87681. * @param w Fourth float in float4.
  87682. * @returns this effect.
  87683. */
  87684. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  87685. /**
  87686. * Sets a Color3 on a uniform variable.
  87687. * @param uniformName Name of the variable.
  87688. * @param color3 Value to be set.
  87689. * @returns this effect.
  87690. */
  87691. setColor3(uniformName: string, color3: Color3): Effect;
  87692. /**
  87693. * Sets a Color4 on a uniform variable.
  87694. * @param uniformName Name of the variable.
  87695. * @param color3 Value to be set.
  87696. * @param alpha Alpha value to be set.
  87697. * @returns this effect.
  87698. */
  87699. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  87700. /**
  87701. * Sets a Color4 on a uniform variable
  87702. * @param uniformName defines the name of the variable
  87703. * @param color4 defines the value to be set
  87704. * @returns this effect.
  87705. */
  87706. setDirectColor4(uniformName: string, color4: Color4): Effect;
  87707. /**
  87708. * This function will add a new shader to the shader store
  87709. * @param name the name of the shader
  87710. * @param pixelShader optional pixel shader content
  87711. * @param vertexShader optional vertex shader content
  87712. */
  87713. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  87714. /**
  87715. * Store of each shader (The can be looked up using effect.key)
  87716. */
  87717. static ShadersStore: {
  87718. [key: string]: string;
  87719. };
  87720. /**
  87721. * Store of each included file for a shader (The can be looked up using effect.key)
  87722. */
  87723. static IncludesShadersStore: {
  87724. [key: string]: string;
  87725. };
  87726. /**
  87727. * Resets the cache of effects.
  87728. */
  87729. static ResetCache(): void;
  87730. }
  87731. }
  87732. declare module BABYLON {
  87733. /**
  87734. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87735. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87736. * 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;
  87737. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87738. */
  87739. export class ColorCurves {
  87740. private _dirty;
  87741. private _tempColor;
  87742. private _globalCurve;
  87743. private _highlightsCurve;
  87744. private _midtonesCurve;
  87745. private _shadowsCurve;
  87746. private _positiveCurve;
  87747. private _negativeCurve;
  87748. private _globalHue;
  87749. private _globalDensity;
  87750. private _globalSaturation;
  87751. private _globalExposure;
  87752. /**
  87753. * Gets the global Hue value.
  87754. * 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).
  87755. */
  87756. /**
  87757. * Sets the global Hue value.
  87758. * 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).
  87759. */
  87760. globalHue: number;
  87761. /**
  87762. * Gets the global Density value.
  87763. * 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.
  87764. * Values less than zero provide a filter of opposite hue.
  87765. */
  87766. /**
  87767. * Sets the global Density value.
  87768. * 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.
  87769. * Values less than zero provide a filter of opposite hue.
  87770. */
  87771. globalDensity: number;
  87772. /**
  87773. * Gets the global Saturation value.
  87774. * 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.
  87775. */
  87776. /**
  87777. * Sets the global Saturation value.
  87778. * 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.
  87779. */
  87780. globalSaturation: number;
  87781. /**
  87782. * Gets the global Exposure value.
  87783. * 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.
  87784. */
  87785. /**
  87786. * Sets the global Exposure value.
  87787. * 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.
  87788. */
  87789. globalExposure: number;
  87790. private _highlightsHue;
  87791. private _highlightsDensity;
  87792. private _highlightsSaturation;
  87793. private _highlightsExposure;
  87794. /**
  87795. * Gets the highlights Hue value.
  87796. * 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).
  87797. */
  87798. /**
  87799. * Sets the highlights Hue value.
  87800. * 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).
  87801. */
  87802. highlightsHue: number;
  87803. /**
  87804. * Gets the highlights Density value.
  87805. * 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.
  87806. * Values less than zero provide a filter of opposite hue.
  87807. */
  87808. /**
  87809. * Sets the highlights Density value.
  87810. * 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.
  87811. * Values less than zero provide a filter of opposite hue.
  87812. */
  87813. highlightsDensity: number;
  87814. /**
  87815. * Gets the highlights Saturation value.
  87816. * 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.
  87817. */
  87818. /**
  87819. * Sets the highlights Saturation value.
  87820. * 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.
  87821. */
  87822. highlightsSaturation: number;
  87823. /**
  87824. * Gets the highlights Exposure value.
  87825. * 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.
  87826. */
  87827. /**
  87828. * Sets the highlights Exposure value.
  87829. * 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.
  87830. */
  87831. highlightsExposure: number;
  87832. private _midtonesHue;
  87833. private _midtonesDensity;
  87834. private _midtonesSaturation;
  87835. private _midtonesExposure;
  87836. /**
  87837. * Gets the midtones Hue value.
  87838. * 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).
  87839. */
  87840. /**
  87841. * Sets the midtones Hue value.
  87842. * 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).
  87843. */
  87844. midtonesHue: number;
  87845. /**
  87846. * Gets the midtones Density value.
  87847. * 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.
  87848. * Values less than zero provide a filter of opposite hue.
  87849. */
  87850. /**
  87851. * Sets the midtones Density value.
  87852. * 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.
  87853. * Values less than zero provide a filter of opposite hue.
  87854. */
  87855. midtonesDensity: number;
  87856. /**
  87857. * Gets the midtones Saturation value.
  87858. * 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.
  87859. */
  87860. /**
  87861. * Sets the midtones Saturation value.
  87862. * 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.
  87863. */
  87864. midtonesSaturation: number;
  87865. /**
  87866. * Gets the midtones Exposure value.
  87867. * 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.
  87868. */
  87869. /**
  87870. * Sets the midtones Exposure value.
  87871. * 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.
  87872. */
  87873. midtonesExposure: number;
  87874. private _shadowsHue;
  87875. private _shadowsDensity;
  87876. private _shadowsSaturation;
  87877. private _shadowsExposure;
  87878. /**
  87879. * Gets the shadows Hue value.
  87880. * 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).
  87881. */
  87882. /**
  87883. * Sets the shadows Hue value.
  87884. * 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).
  87885. */
  87886. shadowsHue: number;
  87887. /**
  87888. * Gets the shadows Density value.
  87889. * 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.
  87890. * Values less than zero provide a filter of opposite hue.
  87891. */
  87892. /**
  87893. * Sets the shadows Density value.
  87894. * 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.
  87895. * Values less than zero provide a filter of opposite hue.
  87896. */
  87897. shadowsDensity: number;
  87898. /**
  87899. * Gets the shadows Saturation value.
  87900. * 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.
  87901. */
  87902. /**
  87903. * Sets the shadows Saturation value.
  87904. * 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.
  87905. */
  87906. shadowsSaturation: number;
  87907. /**
  87908. * Gets the shadows Exposure value.
  87909. * 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.
  87910. */
  87911. /**
  87912. * Sets the shadows Exposure value.
  87913. * 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.
  87914. */
  87915. shadowsExposure: number;
  87916. /**
  87917. * Returns the class name
  87918. * @returns The class name
  87919. */
  87920. getClassName(): string;
  87921. /**
  87922. * Binds the color curves to the shader.
  87923. * @param colorCurves The color curve to bind
  87924. * @param effect The effect to bind to
  87925. * @param positiveUniform The positive uniform shader parameter
  87926. * @param neutralUniform The neutral uniform shader parameter
  87927. * @param negativeUniform The negative uniform shader parameter
  87928. */
  87929. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87930. /**
  87931. * Prepare the list of uniforms associated with the ColorCurves effects.
  87932. * @param uniformsList The list of uniforms used in the effect
  87933. */
  87934. static PrepareUniforms(uniformsList: string[]): void;
  87935. /**
  87936. * Returns color grading data based on a hue, density, saturation and exposure value.
  87937. * @param filterHue The hue of the color filter.
  87938. * @param filterDensity The density of the color filter.
  87939. * @param saturation The saturation.
  87940. * @param exposure The exposure.
  87941. * @param result The result data container.
  87942. */
  87943. private getColorGradingDataToRef;
  87944. /**
  87945. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87946. * @param value The input slider value in range [-100,100].
  87947. * @returns Adjusted value.
  87948. */
  87949. private static applyColorGradingSliderNonlinear;
  87950. /**
  87951. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87952. * @param hue The hue (H) input.
  87953. * @param saturation The saturation (S) input.
  87954. * @param brightness The brightness (B) input.
  87955. * @result An RGBA color represented as Vector4.
  87956. */
  87957. private static fromHSBToRef;
  87958. /**
  87959. * Returns a value clamped between min and max
  87960. * @param value The value to clamp
  87961. * @param min The minimum of value
  87962. * @param max The maximum of value
  87963. * @returns The clamped value.
  87964. */
  87965. private static clamp;
  87966. /**
  87967. * Clones the current color curve instance.
  87968. * @return The cloned curves
  87969. */
  87970. clone(): ColorCurves;
  87971. /**
  87972. * Serializes the current color curve instance to a json representation.
  87973. * @return a JSON representation
  87974. */
  87975. serialize(): any;
  87976. /**
  87977. * Parses the color curve from a json representation.
  87978. * @param source the JSON source to parse
  87979. * @return The parsed curves
  87980. */
  87981. static Parse(source: any): ColorCurves;
  87982. }
  87983. }
  87984. declare module BABYLON {
  87985. /**
  87986. * Interface to follow in your material defines to integrate easily the
  87987. * Image proccessing functions.
  87988. * @hidden
  87989. */
  87990. export interface IImageProcessingConfigurationDefines {
  87991. IMAGEPROCESSING: boolean;
  87992. VIGNETTE: boolean;
  87993. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87994. VIGNETTEBLENDMODEOPAQUE: boolean;
  87995. TONEMAPPING: boolean;
  87996. TONEMAPPING_ACES: boolean;
  87997. CONTRAST: boolean;
  87998. EXPOSURE: boolean;
  87999. COLORCURVES: boolean;
  88000. COLORGRADING: boolean;
  88001. COLORGRADING3D: boolean;
  88002. SAMPLER3DGREENDEPTH: boolean;
  88003. SAMPLER3DBGRMAP: boolean;
  88004. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88005. }
  88006. /**
  88007. * @hidden
  88008. */
  88009. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88010. IMAGEPROCESSING: boolean;
  88011. VIGNETTE: boolean;
  88012. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88013. VIGNETTEBLENDMODEOPAQUE: boolean;
  88014. TONEMAPPING: boolean;
  88015. TONEMAPPING_ACES: boolean;
  88016. CONTRAST: boolean;
  88017. COLORCURVES: boolean;
  88018. COLORGRADING: boolean;
  88019. COLORGRADING3D: boolean;
  88020. SAMPLER3DGREENDEPTH: boolean;
  88021. SAMPLER3DBGRMAP: boolean;
  88022. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88023. EXPOSURE: boolean;
  88024. constructor();
  88025. }
  88026. /**
  88027. * This groups together the common properties used for image processing either in direct forward pass
  88028. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88029. * or not.
  88030. */
  88031. export class ImageProcessingConfiguration {
  88032. /**
  88033. * Default tone mapping applied in BabylonJS.
  88034. */
  88035. static readonly TONEMAPPING_STANDARD: number;
  88036. /**
  88037. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88038. * to other engines rendering to increase portability.
  88039. */
  88040. static readonly TONEMAPPING_ACES: number;
  88041. /**
  88042. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88043. */
  88044. colorCurves: Nullable<ColorCurves>;
  88045. private _colorCurvesEnabled;
  88046. /**
  88047. * Gets wether the color curves effect is enabled.
  88048. */
  88049. /**
  88050. * Sets wether the color curves effect is enabled.
  88051. */
  88052. colorCurvesEnabled: boolean;
  88053. private _colorGradingTexture;
  88054. /**
  88055. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88056. */
  88057. /**
  88058. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88059. */
  88060. colorGradingTexture: Nullable<BaseTexture>;
  88061. private _colorGradingEnabled;
  88062. /**
  88063. * Gets wether the color grading effect is enabled.
  88064. */
  88065. /**
  88066. * Sets wether the color grading effect is enabled.
  88067. */
  88068. colorGradingEnabled: boolean;
  88069. private _colorGradingWithGreenDepth;
  88070. /**
  88071. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88072. */
  88073. /**
  88074. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88075. */
  88076. colorGradingWithGreenDepth: boolean;
  88077. private _colorGradingBGR;
  88078. /**
  88079. * Gets wether the color grading texture contains BGR values.
  88080. */
  88081. /**
  88082. * Sets wether the color grading texture contains BGR values.
  88083. */
  88084. colorGradingBGR: boolean;
  88085. /** @hidden */
  88086. _exposure: number;
  88087. /**
  88088. * Gets the Exposure used in the effect.
  88089. */
  88090. /**
  88091. * Sets the Exposure used in the effect.
  88092. */
  88093. exposure: number;
  88094. private _toneMappingEnabled;
  88095. /**
  88096. * Gets wether the tone mapping effect is enabled.
  88097. */
  88098. /**
  88099. * Sets wether the tone mapping effect is enabled.
  88100. */
  88101. toneMappingEnabled: boolean;
  88102. private _toneMappingType;
  88103. /**
  88104. * Gets the type of tone mapping effect.
  88105. */
  88106. /**
  88107. * Sets the type of tone mapping effect used in BabylonJS.
  88108. */
  88109. toneMappingType: number;
  88110. protected _contrast: number;
  88111. /**
  88112. * Gets the contrast used in the effect.
  88113. */
  88114. /**
  88115. * Sets the contrast used in the effect.
  88116. */
  88117. contrast: number;
  88118. /**
  88119. * Vignette stretch size.
  88120. */
  88121. vignetteStretch: number;
  88122. /**
  88123. * Vignette centre X Offset.
  88124. */
  88125. vignetteCentreX: number;
  88126. /**
  88127. * Vignette centre Y Offset.
  88128. */
  88129. vignetteCentreY: number;
  88130. /**
  88131. * Vignette weight or intensity of the vignette effect.
  88132. */
  88133. vignetteWeight: number;
  88134. /**
  88135. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88136. * if vignetteEnabled is set to true.
  88137. */
  88138. vignetteColor: Color4;
  88139. /**
  88140. * Camera field of view used by the Vignette effect.
  88141. */
  88142. vignetteCameraFov: number;
  88143. private _vignetteBlendMode;
  88144. /**
  88145. * Gets the vignette blend mode allowing different kind of effect.
  88146. */
  88147. /**
  88148. * Sets the vignette blend mode allowing different kind of effect.
  88149. */
  88150. vignetteBlendMode: number;
  88151. private _vignetteEnabled;
  88152. /**
  88153. * Gets wether the vignette effect is enabled.
  88154. */
  88155. /**
  88156. * Sets wether the vignette effect is enabled.
  88157. */
  88158. vignetteEnabled: boolean;
  88159. private _applyByPostProcess;
  88160. /**
  88161. * Gets wether the image processing is applied through a post process or not.
  88162. */
  88163. /**
  88164. * Sets wether the image processing is applied through a post process or not.
  88165. */
  88166. applyByPostProcess: boolean;
  88167. private _isEnabled;
  88168. /**
  88169. * Gets wether the image processing is enabled or not.
  88170. */
  88171. /**
  88172. * Sets wether the image processing is enabled or not.
  88173. */
  88174. isEnabled: boolean;
  88175. /**
  88176. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88177. */
  88178. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88179. /**
  88180. * Method called each time the image processing information changes requires to recompile the effect.
  88181. */
  88182. protected _updateParameters(): void;
  88183. /**
  88184. * Gets the current class name.
  88185. * @return "ImageProcessingConfiguration"
  88186. */
  88187. getClassName(): string;
  88188. /**
  88189. * Prepare the list of uniforms associated with the Image Processing effects.
  88190. * @param uniforms The list of uniforms used in the effect
  88191. * @param defines the list of defines currently in use
  88192. */
  88193. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88194. /**
  88195. * Prepare the list of samplers associated with the Image Processing effects.
  88196. * @param samplersList The list of uniforms used in the effect
  88197. * @param defines the list of defines currently in use
  88198. */
  88199. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88200. /**
  88201. * Prepare the list of defines associated to the shader.
  88202. * @param defines the list of defines to complete
  88203. * @param forPostProcess Define if we are currently in post process mode or not
  88204. */
  88205. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88206. /**
  88207. * Returns true if all the image processing information are ready.
  88208. * @returns True if ready, otherwise, false
  88209. */
  88210. isReady(): boolean;
  88211. /**
  88212. * Binds the image processing to the shader.
  88213. * @param effect The effect to bind to
  88214. * @param aspectRatio Define the current aspect ratio of the effect
  88215. */
  88216. bind(effect: Effect, aspectRatio?: number): void;
  88217. /**
  88218. * Clones the current image processing instance.
  88219. * @return The cloned image processing
  88220. */
  88221. clone(): ImageProcessingConfiguration;
  88222. /**
  88223. * Serializes the current image processing instance to a json representation.
  88224. * @return a JSON representation
  88225. */
  88226. serialize(): any;
  88227. /**
  88228. * Parses the image processing from a json representation.
  88229. * @param source the JSON source to parse
  88230. * @return The parsed image processing
  88231. */
  88232. static Parse(source: any): ImageProcessingConfiguration;
  88233. private static _VIGNETTEMODE_MULTIPLY;
  88234. private static _VIGNETTEMODE_OPAQUE;
  88235. /**
  88236. * Used to apply the vignette as a mix with the pixel color.
  88237. */
  88238. static readonly VIGNETTEMODE_MULTIPLY: number;
  88239. /**
  88240. * Used to apply the vignette as a replacement of the pixel color.
  88241. */
  88242. static readonly VIGNETTEMODE_OPAQUE: number;
  88243. }
  88244. }
  88245. declare module BABYLON {
  88246. /**
  88247. * This represents all the required information to add a fresnel effect on a material:
  88248. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88249. */
  88250. export class FresnelParameters {
  88251. private _isEnabled;
  88252. /**
  88253. * Define if the fresnel effect is enable or not.
  88254. */
  88255. isEnabled: boolean;
  88256. /**
  88257. * Define the color used on edges (grazing angle)
  88258. */
  88259. leftColor: Color3;
  88260. /**
  88261. * Define the color used on center
  88262. */
  88263. rightColor: Color3;
  88264. /**
  88265. * Define bias applied to computed fresnel term
  88266. */
  88267. bias: number;
  88268. /**
  88269. * Defined the power exponent applied to fresnel term
  88270. */
  88271. power: number;
  88272. /**
  88273. * Clones the current fresnel and its valuues
  88274. * @returns a clone fresnel configuration
  88275. */
  88276. clone(): FresnelParameters;
  88277. /**
  88278. * Serializes the current fresnel parameters to a JSON representation.
  88279. * @return the JSON serialization
  88280. */
  88281. serialize(): any;
  88282. /**
  88283. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88284. * @param parsedFresnelParameters Define the JSON representation
  88285. * @returns the parsed parameters
  88286. */
  88287. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88288. }
  88289. }
  88290. declare module BABYLON {
  88291. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88292. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88293. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88294. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88295. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88296. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88297. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88298. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88299. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88300. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88301. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88302. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88303. /**
  88304. * Decorator used to define property that can be serialized as reference to a camera
  88305. * @param sourceName defines the name of the property to decorate
  88306. */
  88307. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88308. /**
  88309. * Class used to help serialization objects
  88310. */
  88311. export class SerializationHelper {
  88312. /** hidden */
  88313. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88314. /** hidden */
  88315. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88316. /** hidden */
  88317. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88318. /** hidden */
  88319. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88320. /**
  88321. * Appends the serialized animations from the source animations
  88322. * @param source Source containing the animations
  88323. * @param destination Target to store the animations
  88324. */
  88325. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88326. /**
  88327. * Static function used to serialized a specific entity
  88328. * @param entity defines the entity to serialize
  88329. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88330. * @returns a JSON compatible object representing the serialization of the entity
  88331. */
  88332. static Serialize<T>(entity: T, serializationObject?: any): any;
  88333. /**
  88334. * Creates a new entity from a serialization data object
  88335. * @param creationFunction defines a function used to instanciated the new entity
  88336. * @param source defines the source serialization data
  88337. * @param scene defines the hosting scene
  88338. * @param rootUrl defines the root url for resources
  88339. * @returns a new entity
  88340. */
  88341. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88342. /**
  88343. * Clones an object
  88344. * @param creationFunction defines the function used to instanciate the new object
  88345. * @param source defines the source object
  88346. * @returns the cloned object
  88347. */
  88348. static Clone<T>(creationFunction: () => T, source: T): T;
  88349. /**
  88350. * Instanciates a new object based on a source one (some data will be shared between both object)
  88351. * @param creationFunction defines the function used to instanciate the new object
  88352. * @param source defines the source object
  88353. * @returns the new object
  88354. */
  88355. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88356. }
  88357. }
  88358. declare module BABYLON {
  88359. /**
  88360. * This is the base class of all the camera used in the application.
  88361. * @see http://doc.babylonjs.com/features/cameras
  88362. */
  88363. export class Camera extends Node {
  88364. /** @hidden */
  88365. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88366. /**
  88367. * This is the default projection mode used by the cameras.
  88368. * It helps recreating a feeling of perspective and better appreciate depth.
  88369. * This is the best way to simulate real life cameras.
  88370. */
  88371. static readonly PERSPECTIVE_CAMERA: number;
  88372. /**
  88373. * This helps creating camera with an orthographic mode.
  88374. * 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.
  88375. */
  88376. static readonly ORTHOGRAPHIC_CAMERA: number;
  88377. /**
  88378. * This is the default FOV mode for perspective cameras.
  88379. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88380. */
  88381. static readonly FOVMODE_VERTICAL_FIXED: number;
  88382. /**
  88383. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88384. */
  88385. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88386. /**
  88387. * This specifies ther is no need for a camera rig.
  88388. * Basically only one eye is rendered corresponding to the camera.
  88389. */
  88390. static readonly RIG_MODE_NONE: number;
  88391. /**
  88392. * Simulates a camera Rig with one blue eye and one red eye.
  88393. * This can be use with 3d blue and red glasses.
  88394. */
  88395. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88396. /**
  88397. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88398. */
  88399. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88400. /**
  88401. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88402. */
  88403. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88404. /**
  88405. * Defines that both eyes of the camera will be rendered over under each other.
  88406. */
  88407. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88408. /**
  88409. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88410. */
  88411. static readonly RIG_MODE_VR: number;
  88412. /**
  88413. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88414. */
  88415. static readonly RIG_MODE_WEBVR: number;
  88416. /**
  88417. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88418. */
  88419. static readonly RIG_MODE_CUSTOM: number;
  88420. /**
  88421. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88422. */
  88423. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88424. /**
  88425. * @hidden
  88426. * Might be removed once multiview will be a thing
  88427. */
  88428. static UseAlternateWebVRRendering: boolean;
  88429. /**
  88430. * Define the input manager associated with the camera.
  88431. */
  88432. inputs: CameraInputsManager<Camera>;
  88433. /** @hidden */
  88434. _position: Vector3;
  88435. /**
  88436. * Define the current local position of the camera in the scene
  88437. */
  88438. position: Vector3;
  88439. /**
  88440. * The vector the camera should consider as up.
  88441. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88442. */
  88443. upVector: Vector3;
  88444. /**
  88445. * Define the current limit on the left side for an orthographic camera
  88446. * In scene unit
  88447. */
  88448. orthoLeft: Nullable<number>;
  88449. /**
  88450. * Define the current limit on the right side for an orthographic camera
  88451. * In scene unit
  88452. */
  88453. orthoRight: Nullable<number>;
  88454. /**
  88455. * Define the current limit on the bottom side for an orthographic camera
  88456. * In scene unit
  88457. */
  88458. orthoBottom: Nullable<number>;
  88459. /**
  88460. * Define the current limit on the top side for an orthographic camera
  88461. * In scene unit
  88462. */
  88463. orthoTop: Nullable<number>;
  88464. /**
  88465. * Field Of View is set in Radians. (default is 0.8)
  88466. */
  88467. fov: number;
  88468. /**
  88469. * Define the minimum distance the camera can see from.
  88470. * This is important to note that the depth buffer are not infinite and the closer it starts
  88471. * the more your scene might encounter depth fighting issue.
  88472. */
  88473. minZ: number;
  88474. /**
  88475. * Define the maximum distance the camera can see to.
  88476. * This is important to note that the depth buffer are not infinite and the further it end
  88477. * the more your scene might encounter depth fighting issue.
  88478. */
  88479. maxZ: number;
  88480. /**
  88481. * Define the default inertia of the camera.
  88482. * This helps giving a smooth feeling to the camera movement.
  88483. */
  88484. inertia: number;
  88485. /**
  88486. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88487. */
  88488. mode: number;
  88489. /**
  88490. * Define wether the camera is intermediate.
  88491. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88492. */
  88493. isIntermediate: boolean;
  88494. /**
  88495. * Define the viewport of the camera.
  88496. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88497. */
  88498. viewport: Viewport;
  88499. /**
  88500. * Restricts the camera to viewing objects with the same layerMask.
  88501. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88502. */
  88503. layerMask: number;
  88504. /**
  88505. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88506. */
  88507. fovMode: number;
  88508. /**
  88509. * Rig mode of the camera.
  88510. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88511. * This is normally controlled byt the camera themselves as internal use.
  88512. */
  88513. cameraRigMode: number;
  88514. /**
  88515. * Defines the distance between both "eyes" in case of a RIG
  88516. */
  88517. interaxialDistance: number;
  88518. /**
  88519. * Defines if stereoscopic rendering is done side by side or over under.
  88520. */
  88521. isStereoscopicSideBySide: boolean;
  88522. /**
  88523. * 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
  88524. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88525. * else in the scene.
  88526. */
  88527. customRenderTargets: RenderTargetTexture[];
  88528. /**
  88529. * When set, the camera will render to this render target instead of the default canvas
  88530. */
  88531. outputRenderTarget: Nullable<RenderTargetTexture>;
  88532. /**
  88533. * Observable triggered when the camera view matrix has changed.
  88534. */
  88535. onViewMatrixChangedObservable: Observable<Camera>;
  88536. /**
  88537. * Observable triggered when the camera Projection matrix has changed.
  88538. */
  88539. onProjectionMatrixChangedObservable: Observable<Camera>;
  88540. /**
  88541. * Observable triggered when the inputs have been processed.
  88542. */
  88543. onAfterCheckInputsObservable: Observable<Camera>;
  88544. /**
  88545. * Observable triggered when reset has been called and applied to the camera.
  88546. */
  88547. onRestoreStateObservable: Observable<Camera>;
  88548. /** @hidden */
  88549. _cameraRigParams: any;
  88550. /** @hidden */
  88551. _rigCameras: Camera[];
  88552. /** @hidden */
  88553. _rigPostProcess: Nullable<PostProcess>;
  88554. protected _webvrViewMatrix: Matrix;
  88555. /** @hidden */
  88556. _skipRendering: boolean;
  88557. /** @hidden */
  88558. _alternateCamera: Camera;
  88559. /** @hidden */
  88560. _projectionMatrix: Matrix;
  88561. /** @hidden */
  88562. _postProcesses: Nullable<PostProcess>[];
  88563. /** @hidden */
  88564. _activeMeshes: SmartArray<AbstractMesh>;
  88565. protected _globalPosition: Vector3;
  88566. /** hidden */
  88567. _computedViewMatrix: Matrix;
  88568. private _doNotComputeProjectionMatrix;
  88569. private _transformMatrix;
  88570. private _frustumPlanes;
  88571. private _refreshFrustumPlanes;
  88572. private _storedFov;
  88573. private _stateStored;
  88574. /**
  88575. * Instantiates a new camera object.
  88576. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88577. * @see http://doc.babylonjs.com/features/cameras
  88578. * @param name Defines the name of the camera in the scene
  88579. * @param position Defines the position of the camera
  88580. * @param scene Defines the scene the camera belongs too
  88581. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88582. */
  88583. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88584. /**
  88585. * Store current camera state (fov, position, etc..)
  88586. * @returns the camera
  88587. */
  88588. storeState(): Camera;
  88589. /**
  88590. * Restores the camera state values if it has been stored. You must call storeState() first
  88591. */
  88592. protected _restoreStateValues(): boolean;
  88593. /**
  88594. * Restored camera state. You must call storeState() first.
  88595. * @returns true if restored and false otherwise
  88596. */
  88597. restoreState(): boolean;
  88598. /**
  88599. * Gets the class name of the camera.
  88600. * @returns the class name
  88601. */
  88602. getClassName(): string;
  88603. /** @hidden */
  88604. readonly _isCamera: boolean;
  88605. /**
  88606. * Gets a string representation of the camera useful for debug purpose.
  88607. * @param fullDetails Defines that a more verboe level of logging is required
  88608. * @returns the string representation
  88609. */
  88610. toString(fullDetails?: boolean): string;
  88611. /**
  88612. * Gets the current world space position of the camera.
  88613. */
  88614. readonly globalPosition: Vector3;
  88615. /**
  88616. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88617. * @returns the active meshe list
  88618. */
  88619. getActiveMeshes(): SmartArray<AbstractMesh>;
  88620. /**
  88621. * Check wether a mesh is part of the current active mesh list of the camera
  88622. * @param mesh Defines the mesh to check
  88623. * @returns true if active, false otherwise
  88624. */
  88625. isActiveMesh(mesh: Mesh): boolean;
  88626. /**
  88627. * Is this camera ready to be used/rendered
  88628. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88629. * @return true if the camera is ready
  88630. */
  88631. isReady(completeCheck?: boolean): boolean;
  88632. /** @hidden */
  88633. _initCache(): void;
  88634. /** @hidden */
  88635. _updateCache(ignoreParentClass?: boolean): void;
  88636. /** @hidden */
  88637. _isSynchronized(): boolean;
  88638. /** @hidden */
  88639. _isSynchronizedViewMatrix(): boolean;
  88640. /** @hidden */
  88641. _isSynchronizedProjectionMatrix(): boolean;
  88642. /**
  88643. * Attach the input controls to a specific dom element to get the input from.
  88644. * @param element Defines the element the controls should be listened from
  88645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88646. */
  88647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88648. /**
  88649. * Detach the current controls from the specified dom element.
  88650. * @param element Defines the element to stop listening the inputs from
  88651. */
  88652. detachControl(element: HTMLElement): void;
  88653. /**
  88654. * Update the camera state according to the different inputs gathered during the frame.
  88655. */
  88656. update(): void;
  88657. /** @hidden */
  88658. _checkInputs(): void;
  88659. /** @hidden */
  88660. readonly rigCameras: Camera[];
  88661. /**
  88662. * Gets the post process used by the rig cameras
  88663. */
  88664. readonly rigPostProcess: Nullable<PostProcess>;
  88665. /**
  88666. * Internal, gets the first post proces.
  88667. * @returns the first post process to be run on this camera.
  88668. */
  88669. _getFirstPostProcess(): Nullable<PostProcess>;
  88670. private _cascadePostProcessesToRigCams;
  88671. /**
  88672. * Attach a post process to the camera.
  88673. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88674. * @param postProcess The post process to attach to the camera
  88675. * @param insertAt The position of the post process in case several of them are in use in the scene
  88676. * @returns the position the post process has been inserted at
  88677. */
  88678. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88679. /**
  88680. * Detach a post process to the camera.
  88681. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88682. * @param postProcess The post process to detach from the camera
  88683. */
  88684. detachPostProcess(postProcess: PostProcess): void;
  88685. /**
  88686. * Gets the current world matrix of the camera
  88687. */
  88688. getWorldMatrix(): Matrix;
  88689. /** @hidden */
  88690. _getViewMatrix(): Matrix;
  88691. /**
  88692. * Gets the current view matrix of the camera.
  88693. * @param force forces the camera to recompute the matrix without looking at the cached state
  88694. * @returns the view matrix
  88695. */
  88696. getViewMatrix(force?: boolean): Matrix;
  88697. /**
  88698. * Freeze the projection matrix.
  88699. * It will prevent the cache check of the camera projection compute and can speed up perf
  88700. * if no parameter of the camera are meant to change
  88701. * @param projection Defines manually a projection if necessary
  88702. */
  88703. freezeProjectionMatrix(projection?: Matrix): void;
  88704. /**
  88705. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88706. */
  88707. unfreezeProjectionMatrix(): void;
  88708. /**
  88709. * Gets the current projection matrix of the camera.
  88710. * @param force forces the camera to recompute the matrix without looking at the cached state
  88711. * @returns the projection matrix
  88712. */
  88713. getProjectionMatrix(force?: boolean): Matrix;
  88714. /**
  88715. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88716. * @returns a Matrix
  88717. */
  88718. getTransformationMatrix(): Matrix;
  88719. private _updateFrustumPlanes;
  88720. /**
  88721. * Checks if a cullable object (mesh...) is in the camera frustum
  88722. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88723. * @param target The object to check
  88724. * @returns true if the object is in frustum otherwise false
  88725. */
  88726. isInFrustum(target: ICullable): boolean;
  88727. /**
  88728. * Checks if a cullable object (mesh...) is in the camera frustum
  88729. * Unlike isInFrustum this cheks the full bounding box
  88730. * @param target The object to check
  88731. * @returns true if the object is in frustum otherwise false
  88732. */
  88733. isCompletelyInFrustum(target: ICullable): boolean;
  88734. /**
  88735. * Gets a ray in the forward direction from the camera.
  88736. * @param length Defines the length of the ray to create
  88737. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88738. * @param origin Defines the start point of the ray which defaults to the camera position
  88739. * @returns the forward ray
  88740. */
  88741. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88742. /**
  88743. * Releases resources associated with this node.
  88744. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88745. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88746. */
  88747. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88748. /** @hidden */
  88749. _isLeftCamera: boolean;
  88750. /**
  88751. * Gets the left camera of a rig setup in case of Rigged Camera
  88752. */
  88753. readonly isLeftCamera: boolean;
  88754. /** @hidden */
  88755. _isRightCamera: boolean;
  88756. /**
  88757. * Gets the right camera of a rig setup in case of Rigged Camera
  88758. */
  88759. readonly isRightCamera: boolean;
  88760. /**
  88761. * Gets the left camera of a rig setup in case of Rigged Camera
  88762. */
  88763. readonly leftCamera: Nullable<FreeCamera>;
  88764. /**
  88765. * Gets the right camera of a rig setup in case of Rigged Camera
  88766. */
  88767. readonly rightCamera: Nullable<FreeCamera>;
  88768. /**
  88769. * Gets the left camera target of a rig setup in case of Rigged Camera
  88770. * @returns the target position
  88771. */
  88772. getLeftTarget(): Nullable<Vector3>;
  88773. /**
  88774. * Gets the right camera target of a rig setup in case of Rigged Camera
  88775. * @returns the target position
  88776. */
  88777. getRightTarget(): Nullable<Vector3>;
  88778. /**
  88779. * @hidden
  88780. */
  88781. setCameraRigMode(mode: number, rigParams: any): void;
  88782. /** @hidden */
  88783. static _setStereoscopicRigMode(camera: Camera): void;
  88784. /** @hidden */
  88785. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88786. /** @hidden */
  88787. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88788. /** @hidden */
  88789. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88790. /** @hidden */
  88791. _getVRProjectionMatrix(): Matrix;
  88792. protected _updateCameraRotationMatrix(): void;
  88793. protected _updateWebVRCameraRotationMatrix(): void;
  88794. /**
  88795. * This function MUST be overwritten by the different WebVR cameras available.
  88796. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88797. * @hidden
  88798. */
  88799. _getWebVRProjectionMatrix(): Matrix;
  88800. /**
  88801. * This function MUST be overwritten by the different WebVR cameras available.
  88802. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88803. * @hidden
  88804. */
  88805. _getWebVRViewMatrix(): Matrix;
  88806. /** @hidden */
  88807. setCameraRigParameter(name: string, value: any): void;
  88808. /**
  88809. * needs to be overridden by children so sub has required properties to be copied
  88810. * @hidden
  88811. */
  88812. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88813. /**
  88814. * May need to be overridden by children
  88815. * @hidden
  88816. */
  88817. _updateRigCameras(): void;
  88818. /** @hidden */
  88819. _setupInputs(): void;
  88820. /**
  88821. * Serialiaze the camera setup to a json represention
  88822. * @returns the JSON representation
  88823. */
  88824. serialize(): any;
  88825. /**
  88826. * Clones the current camera.
  88827. * @param name The cloned camera name
  88828. * @returns the cloned camera
  88829. */
  88830. clone(name: string): Camera;
  88831. /**
  88832. * Gets the direction of the camera relative to a given local axis.
  88833. * @param localAxis Defines the reference axis to provide a relative direction.
  88834. * @return the direction
  88835. */
  88836. getDirection(localAxis: Vector3): Vector3;
  88837. /**
  88838. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88839. * @param localAxis Defines the reference axis to provide a relative direction.
  88840. * @param result Defines the vector to store the result in
  88841. */
  88842. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88843. /**
  88844. * Gets a camera constructor for a given camera type
  88845. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88846. * @param name The name of the camera the result will be able to instantiate
  88847. * @param scene The scene the result will construct the camera in
  88848. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88849. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88850. * @returns a factory method to construc the camera
  88851. */
  88852. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88853. /**
  88854. * Compute the world matrix of the camera.
  88855. * @returns the camera workd matrix
  88856. */
  88857. computeWorldMatrix(): Matrix;
  88858. /**
  88859. * Parse a JSON and creates the camera from the parsed information
  88860. * @param parsedCamera The JSON to parse
  88861. * @param scene The scene to instantiate the camera in
  88862. * @returns the newly constructed camera
  88863. */
  88864. static Parse(parsedCamera: any, scene: Scene): Camera;
  88865. }
  88866. }
  88867. declare module BABYLON {
  88868. /**
  88869. * Interface for any object that can request an animation frame
  88870. */
  88871. export interface ICustomAnimationFrameRequester {
  88872. /**
  88873. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  88874. */
  88875. renderFunction?: Function;
  88876. /**
  88877. * Called to request the next frame to render to
  88878. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  88879. */
  88880. requestAnimationFrame: Function;
  88881. /**
  88882. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  88883. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  88884. */
  88885. requestID?: number;
  88886. }
  88887. /**
  88888. * Interface containing an array of animations
  88889. */
  88890. export interface IAnimatable {
  88891. /**
  88892. * Array of animations
  88893. */
  88894. animations: Array<Animation>;
  88895. }
  88896. /** Interface used by value gradients (color, factor, ...) */
  88897. export interface IValueGradient {
  88898. /**
  88899. * Gets or sets the gradient value (between 0 and 1)
  88900. */
  88901. gradient: number;
  88902. }
  88903. /** Class used to store color4 gradient */
  88904. export class ColorGradient implements IValueGradient {
  88905. /**
  88906. * Gets or sets the gradient value (between 0 and 1)
  88907. */
  88908. gradient: number;
  88909. /**
  88910. * Gets or sets first associated color
  88911. */
  88912. color1: Color4;
  88913. /**
  88914. * Gets or sets second associated color
  88915. */
  88916. color2?: Color4;
  88917. /**
  88918. * Will get a color picked randomly between color1 and color2.
  88919. * If color2 is undefined then color1 will be used
  88920. * @param result defines the target Color4 to store the result in
  88921. */
  88922. getColorToRef(result: Color4): void;
  88923. }
  88924. /** Class used to store color 3 gradient */
  88925. export class Color3Gradient implements IValueGradient {
  88926. /**
  88927. * Gets or sets the gradient value (between 0 and 1)
  88928. */
  88929. gradient: number;
  88930. /**
  88931. * Gets or sets the associated color
  88932. */
  88933. color: Color3;
  88934. }
  88935. /** Class used to store factor gradient */
  88936. export class FactorGradient implements IValueGradient {
  88937. /**
  88938. * Gets or sets the gradient value (between 0 and 1)
  88939. */
  88940. gradient: number;
  88941. /**
  88942. * Gets or sets first associated factor
  88943. */
  88944. factor1: number;
  88945. /**
  88946. * Gets or sets second associated factor
  88947. */
  88948. factor2?: number;
  88949. /**
  88950. * Will get a number picked randomly between factor1 and factor2.
  88951. * If factor2 is undefined then factor1 will be used
  88952. * @returns the picked number
  88953. */
  88954. getFactor(): number;
  88955. }
  88956. /**
  88957. * @ignore
  88958. * Application error to support additional information when loading a file
  88959. */
  88960. export class LoadFileError extends Error {
  88961. /** defines the optional web request */
  88962. request?: WebRequest | undefined;
  88963. private static _setPrototypeOf;
  88964. /**
  88965. * Creates a new LoadFileError
  88966. * @param message defines the message of the error
  88967. * @param request defines the optional web request
  88968. */
  88969. constructor(message: string,
  88970. /** defines the optional web request */
  88971. request?: WebRequest | undefined);
  88972. }
  88973. /**
  88974. * Class used to define a retry strategy when error happens while loading assets
  88975. */
  88976. export class RetryStrategy {
  88977. /**
  88978. * Function used to defines an exponential back off strategy
  88979. * @param maxRetries defines the maximum number of retries (3 by default)
  88980. * @param baseInterval defines the interval between retries
  88981. * @returns the strategy function to use
  88982. */
  88983. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88984. }
  88985. /**
  88986. * File request interface
  88987. */
  88988. export interface IFileRequest {
  88989. /**
  88990. * Raised when the request is complete (success or error).
  88991. */
  88992. onCompleteObservable: Observable<IFileRequest>;
  88993. /**
  88994. * Aborts the request for a file.
  88995. */
  88996. abort: () => void;
  88997. }
  88998. /**
  88999. * Class containing a set of static utilities functions
  89000. */
  89001. export class Tools {
  89002. /**
  89003. * Gets or sets the base URL to use to load assets
  89004. */
  89005. static BaseUrl: string;
  89006. /**
  89007. * Enable/Disable Custom HTTP Request Headers globally.
  89008. * default = false
  89009. * @see CustomRequestHeaders
  89010. */
  89011. static UseCustomRequestHeaders: boolean;
  89012. /**
  89013. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  89014. * i.e. when loading files, where the server/service expects an Authorization header
  89015. */
  89016. static CustomRequestHeaders: {
  89017. [key: string]: string;
  89018. };
  89019. /**
  89020. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  89021. */
  89022. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  89023. /**
  89024. * Default behaviour for cors in the application.
  89025. * It can be a string if the expected behavior is identical in the entire app.
  89026. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  89027. */
  89028. static CorsBehavior: string | ((url: string | string[]) => string);
  89029. /**
  89030. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  89031. * @ignorenaming
  89032. */
  89033. static UseFallbackTexture: boolean;
  89034. /**
  89035. * Use this object to register external classes like custom textures or material
  89036. * to allow the laoders to instantiate them
  89037. */
  89038. static RegisteredExternalClasses: {
  89039. [key: string]: Object;
  89040. };
  89041. /**
  89042. * Texture content used if a texture cannot loaded
  89043. * @ignorenaming
  89044. */
  89045. static fallbackTexture: string;
  89046. /**
  89047. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  89048. * @param u defines the coordinate on X axis
  89049. * @param v defines the coordinate on Y axis
  89050. * @param width defines the width of the source data
  89051. * @param height defines the height of the source data
  89052. * @param pixels defines the source byte array
  89053. * @param color defines the output color
  89054. */
  89055. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  89056. /**
  89057. * Interpolates between a and b via alpha
  89058. * @param a The lower value (returned when alpha = 0)
  89059. * @param b The upper value (returned when alpha = 1)
  89060. * @param alpha The interpolation-factor
  89061. * @return The mixed value
  89062. */
  89063. static Mix(a: number, b: number, alpha: number): number;
  89064. /**
  89065. * Tries to instantiate a new object from a given class name
  89066. * @param className defines the class name to instantiate
  89067. * @returns the new object or null if the system was not able to do the instantiation
  89068. */
  89069. static Instantiate(className: string): any;
  89070. /**
  89071. * Provides a slice function that will work even on IE
  89072. * @param data defines the array to slice
  89073. * @param start defines the start of the data (optional)
  89074. * @param end defines the end of the data (optional)
  89075. * @returns the new sliced array
  89076. */
  89077. static Slice<T>(data: T, start?: number, end?: number): T;
  89078. /**
  89079. * Polyfill for setImmediate
  89080. * @param action defines the action to execute after the current execution block
  89081. */
  89082. static SetImmediate(action: () => void): void;
  89083. /**
  89084. * Function indicating if a number is an exponent of 2
  89085. * @param value defines the value to test
  89086. * @returns true if the value is an exponent of 2
  89087. */
  89088. static IsExponentOfTwo(value: number): boolean;
  89089. private static _tmpFloatArray;
  89090. /**
  89091. * Returns the nearest 32-bit single precision float representation of a Number
  89092. * @param value A Number. If the parameter is of a different type, it will get converted
  89093. * to a number or to NaN if it cannot be converted
  89094. * @returns number
  89095. */
  89096. static FloatRound(value: number): number;
  89097. /**
  89098. * Find the next highest power of two.
  89099. * @param x Number to start search from.
  89100. * @return Next highest power of two.
  89101. */
  89102. static CeilingPOT(x: number): number;
  89103. /**
  89104. * Find the next lowest power of two.
  89105. * @param x Number to start search from.
  89106. * @return Next lowest power of two.
  89107. */
  89108. static FloorPOT(x: number): number;
  89109. /**
  89110. * Find the nearest power of two.
  89111. * @param x Number to start search from.
  89112. * @return Next nearest power of two.
  89113. */
  89114. static NearestPOT(x: number): number;
  89115. /**
  89116. * Get the closest exponent of two
  89117. * @param value defines the value to approximate
  89118. * @param max defines the maximum value to return
  89119. * @param mode defines how to define the closest value
  89120. * @returns closest exponent of two of the given value
  89121. */
  89122. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89123. /**
  89124. * Extracts the filename from a path
  89125. * @param path defines the path to use
  89126. * @returns the filename
  89127. */
  89128. static GetFilename(path: string): string;
  89129. /**
  89130. * Extracts the "folder" part of a path (everything before the filename).
  89131. * @param uri The URI to extract the info from
  89132. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89133. * @returns The "folder" part of the path
  89134. */
  89135. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89136. /**
  89137. * Extracts text content from a DOM element hierarchy
  89138. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89139. */
  89140. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89141. /**
  89142. * Convert an angle in radians to degrees
  89143. * @param angle defines the angle to convert
  89144. * @returns the angle in degrees
  89145. */
  89146. static ToDegrees(angle: number): number;
  89147. /**
  89148. * Convert an angle in degrees to radians
  89149. * @param angle defines the angle to convert
  89150. * @returns the angle in radians
  89151. */
  89152. static ToRadians(angle: number): number;
  89153. /**
  89154. * Encode a buffer to a base64 string
  89155. * @param buffer defines the buffer to encode
  89156. * @returns the encoded string
  89157. */
  89158. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89159. /**
  89160. * Extracts minimum and maximum values from a list of indexed positions
  89161. * @param positions defines the positions to use
  89162. * @param indices defines the indices to the positions
  89163. * @param indexStart defines the start index
  89164. * @param indexCount defines the end index
  89165. * @param bias defines bias value to add to the result
  89166. * @return minimum and maximum values
  89167. */
  89168. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89169. minimum: Vector3;
  89170. maximum: Vector3;
  89171. };
  89172. /**
  89173. * Extracts minimum and maximum values from a list of positions
  89174. * @param positions defines the positions to use
  89175. * @param start defines the start index in the positions array
  89176. * @param count defines the number of positions to handle
  89177. * @param bias defines bias value to add to the result
  89178. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89179. * @return minimum and maximum values
  89180. */
  89181. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89182. minimum: Vector3;
  89183. maximum: Vector3;
  89184. };
  89185. /**
  89186. * Returns an array if obj is not an array
  89187. * @param obj defines the object to evaluate as an array
  89188. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89189. * @returns either obj directly if obj is an array or a new array containing obj
  89190. */
  89191. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89192. /**
  89193. * Gets the pointer prefix to use
  89194. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89195. */
  89196. static GetPointerPrefix(): string;
  89197. /**
  89198. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89199. * @param func - the function to be called
  89200. * @param requester - the object that will request the next frame. Falls back to window.
  89201. * @returns frame number
  89202. */
  89203. static QueueNewFrame(func: () => void, requester?: any): number;
  89204. /**
  89205. * Ask the browser to promote the current element to fullscreen rendering mode
  89206. * @param element defines the DOM element to promote
  89207. */
  89208. static RequestFullscreen(element: HTMLElement): void;
  89209. /**
  89210. * Asks the browser to exit fullscreen mode
  89211. */
  89212. static ExitFullscreen(): void;
  89213. /**
  89214. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89215. * @param url define the url we are trying
  89216. * @param element define the dom element where to configure the cors policy
  89217. */
  89218. static SetCorsBehavior(url: string | string[], element: {
  89219. crossOrigin: string | null;
  89220. }): void;
  89221. /**
  89222. * Removes unwanted characters from an url
  89223. * @param url defines the url to clean
  89224. * @returns the cleaned url
  89225. */
  89226. static CleanUrl(url: string): string;
  89227. /**
  89228. * Gets or sets a function used to pre-process url before using them to load assets
  89229. */
  89230. static PreprocessUrl: (url: string) => string;
  89231. /**
  89232. * Loads an image as an HTMLImageElement.
  89233. * @param input url string, ArrayBuffer, or Blob to load
  89234. * @param onLoad callback called when the image successfully loads
  89235. * @param onError callback called when the image fails to load
  89236. * @param offlineProvider offline provider for caching
  89237. * @returns the HTMLImageElement of the loaded image
  89238. */
  89239. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89240. /**
  89241. * Loads a file
  89242. * @param url url string, ArrayBuffer, or Blob to load
  89243. * @param onSuccess callback called when the file successfully loads
  89244. * @param onProgress callback called while file is loading (if the server supports this mode)
  89245. * @param offlineProvider defines the offline provider for caching
  89246. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89247. * @param onError callback called when the file fails to load
  89248. * @returns a file request object
  89249. */
  89250. 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;
  89251. /**
  89252. * Load a script (identified by an url). When the url returns, the
  89253. * content of this file is added into a new script element, attached to the DOM (body element)
  89254. * @param scriptUrl defines the url of the script to laod
  89255. * @param onSuccess defines the callback called when the script is loaded
  89256. * @param onError defines the callback to call if an error occurs
  89257. */
  89258. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89259. /**
  89260. * Loads a file from a blob
  89261. * @param fileToLoad defines the blob to use
  89262. * @param callback defines the callback to call when data is loaded
  89263. * @param progressCallback defines the callback to call during loading process
  89264. * @returns a file request object
  89265. */
  89266. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89267. /**
  89268. * Loads a file
  89269. * @param fileToLoad defines the file to load
  89270. * @param callback defines the callback to call when data is loaded
  89271. * @param progressCallBack defines the callback to call during loading process
  89272. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89273. * @returns a file request object
  89274. */
  89275. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89276. /**
  89277. * Creates a data url from a given string content
  89278. * @param content defines the content to convert
  89279. * @returns the new data url link
  89280. */
  89281. static FileAsURL(content: string): string;
  89282. /**
  89283. * Format the given number to a specific decimal format
  89284. * @param value defines the number to format
  89285. * @param decimals defines the number of decimals to use
  89286. * @returns the formatted string
  89287. */
  89288. static Format(value: number, decimals?: number): string;
  89289. /**
  89290. * Checks if a given vector is inside a specific range
  89291. * @param v defines the vector to test
  89292. * @param min defines the minimum range
  89293. * @param max defines the maximum range
  89294. */
  89295. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89296. /**
  89297. * Tries to copy an object by duplicating every property
  89298. * @param source defines the source object
  89299. * @param destination defines the target object
  89300. * @param doNotCopyList defines a list of properties to avoid
  89301. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89302. */
  89303. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89304. /**
  89305. * Gets a boolean indicating if the given object has no own property
  89306. * @param obj defines the object to test
  89307. * @returns true if object has no own property
  89308. */
  89309. static IsEmpty(obj: any): boolean;
  89310. /**
  89311. * Function used to register events at window level
  89312. * @param events defines the events to register
  89313. */
  89314. static RegisterTopRootEvents(events: {
  89315. name: string;
  89316. handler: Nullable<(e: FocusEvent) => any>;
  89317. }[]): void;
  89318. /**
  89319. * Function used to unregister events from window level
  89320. * @param events defines the events to unregister
  89321. */
  89322. static UnregisterTopRootEvents(events: {
  89323. name: string;
  89324. handler: Nullable<(e: FocusEvent) => any>;
  89325. }[]): void;
  89326. /**
  89327. * @ignore
  89328. */
  89329. static _ScreenshotCanvas: HTMLCanvasElement;
  89330. /**
  89331. * Dumps the current bound framebuffer
  89332. * @param width defines the rendering width
  89333. * @param height defines the rendering height
  89334. * @param engine defines the hosting engine
  89335. * @param successCallback defines the callback triggered once the data are available
  89336. * @param mimeType defines the mime type of the result
  89337. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89338. */
  89339. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89340. /**
  89341. * Converts the canvas data to blob.
  89342. * This acts as a polyfill for browsers not supporting the to blob function.
  89343. * @param canvas Defines the canvas to extract the data from
  89344. * @param successCallback Defines the callback triggered once the data are available
  89345. * @param mimeType Defines the mime type of the result
  89346. */
  89347. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89348. /**
  89349. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89350. * @param successCallback defines the callback triggered once the data are available
  89351. * @param mimeType defines the mime type of the result
  89352. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89353. */
  89354. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89355. /**
  89356. * Downloads a blob in the browser
  89357. * @param blob defines the blob to download
  89358. * @param fileName defines the name of the downloaded file
  89359. */
  89360. static Download(blob: Blob, fileName: string): void;
  89361. /**
  89362. * Captures a screenshot of the current rendering
  89363. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89364. * @param engine defines the rendering engine
  89365. * @param camera defines the source camera
  89366. * @param size This parameter can be set to a single number or to an object with the
  89367. * following (optional) properties: precision, width, height. If a single number is passed,
  89368. * it will be used for both width and height. If an object is passed, the screenshot size
  89369. * will be derived from the parameters. The precision property is a multiplier allowing
  89370. * rendering at a higher or lower resolution
  89371. * @param successCallback defines the callback receives a single parameter which contains the
  89372. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89373. * src parameter of an <img> to display it
  89374. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89375. * Check your browser for supported MIME types
  89376. */
  89377. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89378. /**
  89379. * Generates an image screenshot from the specified camera.
  89380. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89381. * @param engine The engine to use for rendering
  89382. * @param camera The camera to use for rendering
  89383. * @param size This parameter can be set to a single number or to an object with the
  89384. * following (optional) properties: precision, width, height. If a single number is passed,
  89385. * it will be used for both width and height. If an object is passed, the screenshot size
  89386. * will be derived from the parameters. The precision property is a multiplier allowing
  89387. * rendering at a higher or lower resolution
  89388. * @param successCallback The callback receives a single parameter which contains the
  89389. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89390. * src parameter of an <img> to display it
  89391. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89392. * Check your browser for supported MIME types
  89393. * @param samples Texture samples (default: 1)
  89394. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89395. * @param fileName A name for for the downloaded file.
  89396. */
  89397. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89398. /**
  89399. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89400. * Be aware Math.random() could cause collisions, but:
  89401. * "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"
  89402. * @returns a pseudo random id
  89403. */
  89404. static RandomId(): string;
  89405. /**
  89406. * Test if the given uri is a base64 string
  89407. * @param uri The uri to test
  89408. * @return True if the uri is a base64 string or false otherwise
  89409. */
  89410. static IsBase64(uri: string): boolean;
  89411. /**
  89412. * Decode the given base64 uri.
  89413. * @param uri The uri to decode
  89414. * @return The decoded base64 data.
  89415. */
  89416. static DecodeBase64(uri: string): ArrayBuffer;
  89417. /**
  89418. * No log
  89419. */
  89420. static readonly NoneLogLevel: number;
  89421. /**
  89422. * Only message logs
  89423. */
  89424. static readonly MessageLogLevel: number;
  89425. /**
  89426. * Only warning logs
  89427. */
  89428. static readonly WarningLogLevel: number;
  89429. /**
  89430. * Only error logs
  89431. */
  89432. static readonly ErrorLogLevel: number;
  89433. /**
  89434. * All logs
  89435. */
  89436. static readonly AllLogLevel: number;
  89437. /**
  89438. * Gets a value indicating the number of loading errors
  89439. * @ignorenaming
  89440. */
  89441. static readonly errorsCount: number;
  89442. /**
  89443. * Callback called when a new log is added
  89444. */
  89445. static OnNewCacheEntry: (entry: string) => void;
  89446. /**
  89447. * Log a message to the console
  89448. * @param message defines the message to log
  89449. */
  89450. static Log(message: string): void;
  89451. /**
  89452. * Write a warning message to the console
  89453. * @param message defines the message to log
  89454. */
  89455. static Warn(message: string): void;
  89456. /**
  89457. * Write an error message to the console
  89458. * @param message defines the message to log
  89459. */
  89460. static Error(message: string): void;
  89461. /**
  89462. * Gets current log cache (list of logs)
  89463. */
  89464. static readonly LogCache: string;
  89465. /**
  89466. * Clears the log cache
  89467. */
  89468. static ClearLogCache(): void;
  89469. /**
  89470. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89471. */
  89472. static LogLevels: number;
  89473. /**
  89474. * Checks if the loaded document was accessed via `file:`-Protocol.
  89475. * @returns boolean
  89476. */
  89477. static IsFileURL(): boolean;
  89478. /**
  89479. * Checks if the window object exists
  89480. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89481. */
  89482. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89483. /**
  89484. * No performance log
  89485. */
  89486. static readonly PerformanceNoneLogLevel: number;
  89487. /**
  89488. * Use user marks to log performance
  89489. */
  89490. static readonly PerformanceUserMarkLogLevel: number;
  89491. /**
  89492. * Log performance to the console
  89493. */
  89494. static readonly PerformanceConsoleLogLevel: number;
  89495. private static _performance;
  89496. /**
  89497. * Sets the current performance log level
  89498. */
  89499. static PerformanceLogLevel: number;
  89500. private static _StartPerformanceCounterDisabled;
  89501. private static _EndPerformanceCounterDisabled;
  89502. private static _StartUserMark;
  89503. private static _EndUserMark;
  89504. private static _StartPerformanceConsole;
  89505. private static _EndPerformanceConsole;
  89506. /**
  89507. * Starts a performance counter
  89508. */
  89509. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89510. /**
  89511. * Ends a specific performance coutner
  89512. */
  89513. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89514. /**
  89515. * Gets either window.performance.now() if supported or Date.now() else
  89516. */
  89517. static readonly Now: number;
  89518. /**
  89519. * This method will return the name of the class used to create the instance of the given object.
  89520. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89521. * @param object the object to get the class name from
  89522. * @param isType defines if the object is actually a type
  89523. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89524. */
  89525. static GetClassName(object: any, isType?: boolean): string;
  89526. /**
  89527. * Gets the first element of an array satisfying a given predicate
  89528. * @param array defines the array to browse
  89529. * @param predicate defines the predicate to use
  89530. * @returns null if not found or the element
  89531. */
  89532. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89533. /**
  89534. * This method will return the name of the full name of the class, including its owning module (if any).
  89535. * 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).
  89536. * @param object the object to get the class name from
  89537. * @param isType defines if the object is actually a type
  89538. * @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.
  89539. * @ignorenaming
  89540. */
  89541. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89542. /**
  89543. * Returns a promise that resolves after the given amount of time.
  89544. * @param delay Number of milliseconds to delay
  89545. * @returns Promise that resolves after the given amount of time
  89546. */
  89547. static DelayAsync(delay: number): Promise<void>;
  89548. /**
  89549. * Gets the current gradient from an array of IValueGradient
  89550. * @param ratio defines the current ratio to get
  89551. * @param gradients defines the array of IValueGradient
  89552. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89553. */
  89554. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89555. }
  89556. /**
  89557. * This class is used to track a performance counter which is number based.
  89558. * The user has access to many properties which give statistics of different nature.
  89559. *
  89560. * The implementer can track two kinds of Performance Counter: time and count.
  89561. * 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.
  89562. * 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.
  89563. */
  89564. export class PerfCounter {
  89565. /**
  89566. * Gets or sets a global boolean to turn on and off all the counters
  89567. */
  89568. static Enabled: boolean;
  89569. /**
  89570. * Returns the smallest value ever
  89571. */
  89572. readonly min: number;
  89573. /**
  89574. * Returns the biggest value ever
  89575. */
  89576. readonly max: number;
  89577. /**
  89578. * Returns the average value since the performance counter is running
  89579. */
  89580. readonly average: number;
  89581. /**
  89582. * Returns the average value of the last second the counter was monitored
  89583. */
  89584. readonly lastSecAverage: number;
  89585. /**
  89586. * Returns the current value
  89587. */
  89588. readonly current: number;
  89589. /**
  89590. * Gets the accumulated total
  89591. */
  89592. readonly total: number;
  89593. /**
  89594. * Gets the total value count
  89595. */
  89596. readonly count: number;
  89597. /**
  89598. * Creates a new counter
  89599. */
  89600. constructor();
  89601. /**
  89602. * Call this method to start monitoring a new frame.
  89603. * 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.
  89604. */
  89605. fetchNewFrame(): void;
  89606. /**
  89607. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89608. * @param newCount the count value to add to the monitored count
  89609. * @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.
  89610. */
  89611. addCount(newCount: number, fetchResult: boolean): void;
  89612. /**
  89613. * Start monitoring this performance counter
  89614. */
  89615. beginMonitoring(): void;
  89616. /**
  89617. * Compute the time lapsed since the previous beginMonitoring() call.
  89618. * @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
  89619. */
  89620. endMonitoring(newFrame?: boolean): void;
  89621. private _fetchResult;
  89622. private _startMonitoringTime;
  89623. private _min;
  89624. private _max;
  89625. private _average;
  89626. private _current;
  89627. private _totalValueCount;
  89628. private _totalAccumulated;
  89629. private _lastSecAverage;
  89630. private _lastSecAccumulated;
  89631. private _lastSecTime;
  89632. private _lastSecValueCount;
  89633. }
  89634. /**
  89635. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89636. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89637. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89638. * @param name The name of the class, case should be preserved
  89639. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  89640. */
  89641. export function className(name: string, module?: string): (target: Object) => void;
  89642. /**
  89643. * An implementation of a loop for asynchronous functions.
  89644. */
  89645. export class AsyncLoop {
  89646. /**
  89647. * Defines the number of iterations for the loop
  89648. */
  89649. iterations: number;
  89650. /**
  89651. * Defines the current index of the loop.
  89652. */
  89653. index: number;
  89654. private _done;
  89655. private _fn;
  89656. private _successCallback;
  89657. /**
  89658. * Constructor.
  89659. * @param iterations the number of iterations.
  89660. * @param func the function to run each iteration
  89661. * @param successCallback the callback that will be called upon succesful execution
  89662. * @param offset starting offset.
  89663. */
  89664. constructor(
  89665. /**
  89666. * Defines the number of iterations for the loop
  89667. */
  89668. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  89669. /**
  89670. * Execute the next iteration. Must be called after the last iteration was finished.
  89671. */
  89672. executeNext(): void;
  89673. /**
  89674. * Break the loop and run the success callback.
  89675. */
  89676. breakLoop(): void;
  89677. /**
  89678. * Create and run an async loop.
  89679. * @param iterations the number of iterations.
  89680. * @param fn the function to run each iteration
  89681. * @param successCallback the callback that will be called upon succesful execution
  89682. * @param offset starting offset.
  89683. * @returns the created async loop object
  89684. */
  89685. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  89686. /**
  89687. * A for-loop that will run a given number of iterations synchronous and the rest async.
  89688. * @param iterations total number of iterations
  89689. * @param syncedIterations number of synchronous iterations in each async iteration.
  89690. * @param fn the function to call each iteration.
  89691. * @param callback a success call back that will be called when iterating stops.
  89692. * @param breakFunction a break condition (optional)
  89693. * @param timeout timeout settings for the setTimeout function. default - 0.
  89694. * @returns the created async loop object
  89695. */
  89696. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  89697. }
  89698. }
  89699. declare module BABYLON {
  89700. /** @hidden */
  89701. export interface ICollisionCoordinator {
  89702. createCollider(): Collider;
  89703. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89704. init(scene: Scene): void;
  89705. }
  89706. /** @hidden */
  89707. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  89708. private _scene;
  89709. private _scaledPosition;
  89710. private _scaledVelocity;
  89711. private _finalPosition;
  89712. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89713. createCollider(): Collider;
  89714. init(scene: Scene): void;
  89715. private _collideWithWorld;
  89716. }
  89717. }
  89718. declare module BABYLON {
  89719. /**
  89720. * This class defines the direct association between an animation and a target
  89721. */
  89722. export class TargetedAnimation {
  89723. /**
  89724. * Animation to perform
  89725. */
  89726. animation: Animation;
  89727. /**
  89728. * Target to animate
  89729. */
  89730. target: any;
  89731. }
  89732. /**
  89733. * Use this class to create coordinated animations on multiple targets
  89734. */
  89735. export class AnimationGroup implements IDisposable {
  89736. /** The name of the animation group */
  89737. name: string;
  89738. private _scene;
  89739. private _targetedAnimations;
  89740. private _animatables;
  89741. private _from;
  89742. private _to;
  89743. private _isStarted;
  89744. private _isPaused;
  89745. private _speedRatio;
  89746. /**
  89747. * Gets or sets the unique id of the node
  89748. */
  89749. uniqueId: number;
  89750. /**
  89751. * This observable will notify when one animation have ended
  89752. */
  89753. onAnimationEndObservable: Observable<TargetedAnimation>;
  89754. /**
  89755. * Observer raised when one animation loops
  89756. */
  89757. onAnimationLoopObservable: Observable<TargetedAnimation>;
  89758. /**
  89759. * This observable will notify when all animations have ended.
  89760. */
  89761. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  89762. /**
  89763. * This observable will notify when all animations have paused.
  89764. */
  89765. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  89766. /**
  89767. * This observable will notify when all animations are playing.
  89768. */
  89769. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  89770. /**
  89771. * Gets the first frame
  89772. */
  89773. readonly from: number;
  89774. /**
  89775. * Gets the last frame
  89776. */
  89777. readonly to: number;
  89778. /**
  89779. * Define if the animations are started
  89780. */
  89781. readonly isStarted: boolean;
  89782. /**
  89783. * Gets a value indicating that the current group is playing
  89784. */
  89785. readonly isPlaying: boolean;
  89786. /**
  89787. * Gets or sets the speed ratio to use for all animations
  89788. */
  89789. /**
  89790. * Gets or sets the speed ratio to use for all animations
  89791. */
  89792. speedRatio: number;
  89793. /**
  89794. * Gets the targeted animations for this animation group
  89795. */
  89796. readonly targetedAnimations: Array<TargetedAnimation>;
  89797. /**
  89798. * returning the list of animatables controlled by this animation group.
  89799. */
  89800. readonly animatables: Array<Animatable>;
  89801. /**
  89802. * Instantiates a new Animation Group.
  89803. * This helps managing several animations at once.
  89804. * @see http://doc.babylonjs.com/how_to/group
  89805. * @param name Defines the name of the group
  89806. * @param scene Defines the scene the group belongs to
  89807. */
  89808. constructor(
  89809. /** The name of the animation group */
  89810. name: string, scene?: Nullable<Scene>);
  89811. /**
  89812. * Add an animation (with its target) in the group
  89813. * @param animation defines the animation we want to add
  89814. * @param target defines the target of the animation
  89815. * @returns the TargetedAnimation object
  89816. */
  89817. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  89818. /**
  89819. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  89820. * It can add constant keys at begin or end
  89821. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  89822. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  89823. * @returns the animation group
  89824. */
  89825. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  89826. /**
  89827. * Start all animations on given targets
  89828. * @param loop defines if animations must loop
  89829. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  89830. * @param from defines the from key (optional)
  89831. * @param to defines the to key (optional)
  89832. * @returns the current animation group
  89833. */
  89834. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  89835. /**
  89836. * Pause all animations
  89837. * @returns the animation group
  89838. */
  89839. pause(): AnimationGroup;
  89840. /**
  89841. * Play all animations to initial state
  89842. * This function will start() the animations if they were not started or will restart() them if they were paused
  89843. * @param loop defines if animations must loop
  89844. * @returns the animation group
  89845. */
  89846. play(loop?: boolean): AnimationGroup;
  89847. /**
  89848. * Reset all animations to initial state
  89849. * @returns the animation group
  89850. */
  89851. reset(): AnimationGroup;
  89852. /**
  89853. * Restart animations from key 0
  89854. * @returns the animation group
  89855. */
  89856. restart(): AnimationGroup;
  89857. /**
  89858. * Stop all animations
  89859. * @returns the animation group
  89860. */
  89861. stop(): AnimationGroup;
  89862. /**
  89863. * Set animation weight for all animatables
  89864. * @param weight defines the weight to use
  89865. * @return the animationGroup
  89866. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89867. */
  89868. setWeightForAllAnimatables(weight: number): AnimationGroup;
  89869. /**
  89870. * Synchronize and normalize all animatables with a source animatable
  89871. * @param root defines the root animatable to synchronize with
  89872. * @return the animationGroup
  89873. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89874. */
  89875. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  89876. /**
  89877. * Goes to a specific frame in this animation group
  89878. * @param frame the frame number to go to
  89879. * @return the animationGroup
  89880. */
  89881. goToFrame(frame: number): AnimationGroup;
  89882. /**
  89883. * Dispose all associated resources
  89884. */
  89885. dispose(): void;
  89886. private _checkAnimationGroupEnded;
  89887. /**
  89888. * Clone the current animation group and returns a copy
  89889. * @param newName defines the name of the new group
  89890. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  89891. * @returns the new aniamtion group
  89892. */
  89893. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  89894. /**
  89895. * Returns a new AnimationGroup object parsed from the source provided.
  89896. * @param parsedAnimationGroup defines the source
  89897. * @param scene defines the scene that will receive the animationGroup
  89898. * @returns a new AnimationGroup
  89899. */
  89900. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  89901. /**
  89902. * Returns the string "AnimationGroup"
  89903. * @returns "AnimationGroup"
  89904. */
  89905. getClassName(): string;
  89906. /**
  89907. * Creates a detailled string about the object
  89908. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  89909. * @returns a string representing the object
  89910. */
  89911. toString(fullDetails?: boolean): string;
  89912. }
  89913. }
  89914. declare module BABYLON {
  89915. /**
  89916. * Define an interface for all classes that will hold resources
  89917. */
  89918. export interface IDisposable {
  89919. /**
  89920. * Releases all held resources
  89921. */
  89922. dispose(): void;
  89923. }
  89924. /** Interface defining initialization parameters for Scene class */
  89925. export interface SceneOptions {
  89926. /**
  89927. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  89928. * It will improve performance when the number of geometries becomes important.
  89929. */
  89930. useGeometryUniqueIdsMap?: boolean;
  89931. /**
  89932. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  89933. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89934. */
  89935. useMaterialMeshMap?: boolean;
  89936. /**
  89937. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  89938. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89939. */
  89940. useClonedMeshhMap?: boolean;
  89941. }
  89942. /**
  89943. * Represents a scene to be rendered by the engine.
  89944. * @see http://doc.babylonjs.com/features/scene
  89945. */
  89946. export class Scene extends AbstractScene implements IAnimatable {
  89947. private static _uniqueIdCounter;
  89948. /** The fog is deactivated */
  89949. static readonly FOGMODE_NONE: number;
  89950. /** The fog density is following an exponential function */
  89951. static readonly FOGMODE_EXP: number;
  89952. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89953. static readonly FOGMODE_EXP2: number;
  89954. /** The fog density is following a linear function. */
  89955. static readonly FOGMODE_LINEAR: number;
  89956. /**
  89957. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89958. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89959. */
  89960. static MinDeltaTime: number;
  89961. /**
  89962. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89963. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89964. */
  89965. static MaxDeltaTime: number;
  89966. /**
  89967. * Factory used to create the default material.
  89968. * @param name The name of the material to create
  89969. * @param scene The scene to create the material for
  89970. * @returns The default material
  89971. */
  89972. static DefaultMaterialFactory(scene: Scene): Material;
  89973. /**
  89974. * Factory used to create the a collision coordinator.
  89975. * @returns The collision coordinator
  89976. */
  89977. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89978. /** @hidden */
  89979. readonly _isScene: boolean;
  89980. /**
  89981. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89982. */
  89983. autoClear: boolean;
  89984. /**
  89985. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89986. */
  89987. autoClearDepthAndStencil: boolean;
  89988. /**
  89989. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89990. */
  89991. clearColor: Color4;
  89992. /**
  89993. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89994. */
  89995. ambientColor: Color3;
  89996. /** @hidden */
  89997. _environmentBRDFTexture: BaseTexture;
  89998. /** @hidden */
  89999. protected _environmentTexture: Nullable<BaseTexture>;
  90000. /**
  90001. * Texture used in all pbr material as the reflection texture.
  90002. * As in the majority of the scene they are the same (exception for multi room and so on),
  90003. * this is easier to reference from here than from all the materials.
  90004. */
  90005. /**
  90006. * Texture used in all pbr material as the reflection texture.
  90007. * As in the majority of the scene they are the same (exception for multi room and so on),
  90008. * this is easier to set here than in all the materials.
  90009. */
  90010. environmentTexture: Nullable<BaseTexture>;
  90011. /** @hidden */
  90012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90013. /**
  90014. * Default image processing configuration used either in the rendering
  90015. * Forward main pass or through the imageProcessingPostProcess if present.
  90016. * As in the majority of the scene they are the same (exception for multi camera),
  90017. * this is easier to reference from here than from all the materials and post process.
  90018. *
  90019. * No setter as we it is a shared configuration, you can set the values instead.
  90020. */
  90021. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  90022. private _forceWireframe;
  90023. /**
  90024. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  90025. */
  90026. forceWireframe: boolean;
  90027. private _forcePointsCloud;
  90028. /**
  90029. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  90030. */
  90031. forcePointsCloud: boolean;
  90032. /**
  90033. * Gets or sets the active clipplane 1
  90034. */
  90035. clipPlane: Nullable<Plane>;
  90036. /**
  90037. * Gets or sets the active clipplane 2
  90038. */
  90039. clipPlane2: Nullable<Plane>;
  90040. /**
  90041. * Gets or sets the active clipplane 3
  90042. */
  90043. clipPlane3: Nullable<Plane>;
  90044. /**
  90045. * Gets or sets the active clipplane 4
  90046. */
  90047. clipPlane4: Nullable<Plane>;
  90048. /**
  90049. * Gets or sets a boolean indicating if animations are enabled
  90050. */
  90051. animationsEnabled: boolean;
  90052. private _animationPropertiesOverride;
  90053. /**
  90054. * Gets or sets the animation properties override
  90055. */
  90056. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90057. /**
  90058. * Gets or sets a boolean indicating if a constant deltatime has to be used
  90059. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  90060. */
  90061. useConstantAnimationDeltaTime: boolean;
  90062. /**
  90063. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90064. * Please note that it requires to run a ray cast through the scene on every frame
  90065. */
  90066. constantlyUpdateMeshUnderPointer: boolean;
  90067. /**
  90068. * Defines the HTML cursor to use when hovering over interactive elements
  90069. */
  90070. hoverCursor: string;
  90071. /**
  90072. * Defines the HTML default cursor to use (empty by default)
  90073. */
  90074. defaultCursor: string;
  90075. /**
  90076. * This is used to call preventDefault() on pointer down
  90077. * in order to block unwanted artifacts like system double clicks
  90078. */
  90079. preventDefaultOnPointerDown: boolean;
  90080. /**
  90081. * This is used to call preventDefault() on pointer up
  90082. * in order to block unwanted artifacts like system double clicks
  90083. */
  90084. preventDefaultOnPointerUp: boolean;
  90085. /**
  90086. * Gets or sets user defined metadata
  90087. */
  90088. metadata: any;
  90089. /**
  90090. * For internal use only. Please do not use.
  90091. */
  90092. reservedDataStore: any;
  90093. /**
  90094. * Gets the name of the plugin used to load this scene (null by default)
  90095. */
  90096. loadingPluginName: string;
  90097. /**
  90098. * Use this array to add regular expressions used to disable offline support for specific urls
  90099. */
  90100. disableOfflineSupportExceptionRules: RegExp[];
  90101. /**
  90102. * An event triggered when the scene is disposed.
  90103. */
  90104. onDisposeObservable: Observable<Scene>;
  90105. private _onDisposeObserver;
  90106. /** Sets a function to be executed when this scene is disposed. */
  90107. onDispose: () => void;
  90108. /**
  90109. * An event triggered before rendering the scene (right after animations and physics)
  90110. */
  90111. onBeforeRenderObservable: Observable<Scene>;
  90112. private _onBeforeRenderObserver;
  90113. /** Sets a function to be executed before rendering this scene */
  90114. beforeRender: Nullable<() => void>;
  90115. /**
  90116. * An event triggered after rendering the scene
  90117. */
  90118. onAfterRenderObservable: Observable<Scene>;
  90119. private _onAfterRenderObserver;
  90120. /** Sets a function to be executed after rendering this scene */
  90121. afterRender: Nullable<() => void>;
  90122. /**
  90123. * An event triggered before animating the scene
  90124. */
  90125. onBeforeAnimationsObservable: Observable<Scene>;
  90126. /**
  90127. * An event triggered after animations processing
  90128. */
  90129. onAfterAnimationsObservable: Observable<Scene>;
  90130. /**
  90131. * An event triggered before draw calls are ready to be sent
  90132. */
  90133. onBeforeDrawPhaseObservable: Observable<Scene>;
  90134. /**
  90135. * An event triggered after draw calls have been sent
  90136. */
  90137. onAfterDrawPhaseObservable: Observable<Scene>;
  90138. /**
  90139. * An event triggered when the scene is ready
  90140. */
  90141. onReadyObservable: Observable<Scene>;
  90142. /**
  90143. * An event triggered before rendering a camera
  90144. */
  90145. onBeforeCameraRenderObservable: Observable<Camera>;
  90146. private _onBeforeCameraRenderObserver;
  90147. /** Sets a function to be executed before rendering a camera*/
  90148. beforeCameraRender: () => void;
  90149. /**
  90150. * An event triggered after rendering a camera
  90151. */
  90152. onAfterCameraRenderObservable: Observable<Camera>;
  90153. private _onAfterCameraRenderObserver;
  90154. /** Sets a function to be executed after rendering a camera*/
  90155. afterCameraRender: () => void;
  90156. /**
  90157. * An event triggered when active meshes evaluation is about to start
  90158. */
  90159. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90160. /**
  90161. * An event triggered when active meshes evaluation is done
  90162. */
  90163. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90164. /**
  90165. * An event triggered when particles rendering is about to start
  90166. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90167. */
  90168. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90169. /**
  90170. * An event triggered when particles rendering is done
  90171. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90172. */
  90173. onAfterParticlesRenderingObservable: Observable<Scene>;
  90174. /**
  90175. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90176. */
  90177. onDataLoadedObservable: Observable<Scene>;
  90178. /**
  90179. * An event triggered when a camera is created
  90180. */
  90181. onNewCameraAddedObservable: Observable<Camera>;
  90182. /**
  90183. * An event triggered when a camera is removed
  90184. */
  90185. onCameraRemovedObservable: Observable<Camera>;
  90186. /**
  90187. * An event triggered when a light is created
  90188. */
  90189. onNewLightAddedObservable: Observable<Light>;
  90190. /**
  90191. * An event triggered when a light is removed
  90192. */
  90193. onLightRemovedObservable: Observable<Light>;
  90194. /**
  90195. * An event triggered when a geometry is created
  90196. */
  90197. onNewGeometryAddedObservable: Observable<Geometry>;
  90198. /**
  90199. * An event triggered when a geometry is removed
  90200. */
  90201. onGeometryRemovedObservable: Observable<Geometry>;
  90202. /**
  90203. * An event triggered when a transform node is created
  90204. */
  90205. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90206. /**
  90207. * An event triggered when a transform node is removed
  90208. */
  90209. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90210. /**
  90211. * An event triggered when a mesh is created
  90212. */
  90213. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90214. /**
  90215. * An event triggered when a mesh is removed
  90216. */
  90217. onMeshRemovedObservable: Observable<AbstractMesh>;
  90218. /**
  90219. * An event triggered when a skeleton is created
  90220. */
  90221. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90222. /**
  90223. * An event triggered when a skeleton is removed
  90224. */
  90225. onSkeletonRemovedObservable: Observable<Skeleton>;
  90226. /**
  90227. * An event triggered when a material is created
  90228. */
  90229. onNewMaterialAddedObservable: Observable<Material>;
  90230. /**
  90231. * An event triggered when a material is removed
  90232. */
  90233. onMaterialRemovedObservable: Observable<Material>;
  90234. /**
  90235. * An event triggered when a texture is created
  90236. */
  90237. onNewTextureAddedObservable: Observable<BaseTexture>;
  90238. /**
  90239. * An event triggered when a texture is removed
  90240. */
  90241. onTextureRemovedObservable: Observable<BaseTexture>;
  90242. /**
  90243. * An event triggered when render targets are about to be rendered
  90244. * Can happen multiple times per frame.
  90245. */
  90246. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90247. /**
  90248. * An event triggered when render targets were rendered.
  90249. * Can happen multiple times per frame.
  90250. */
  90251. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90252. /**
  90253. * An event triggered before calculating deterministic simulation step
  90254. */
  90255. onBeforeStepObservable: Observable<Scene>;
  90256. /**
  90257. * An event triggered after calculating deterministic simulation step
  90258. */
  90259. onAfterStepObservable: Observable<Scene>;
  90260. /**
  90261. * An event triggered when the activeCamera property is updated
  90262. */
  90263. onActiveCameraChanged: Observable<Scene>;
  90264. /**
  90265. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90266. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90267. * 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)
  90268. */
  90269. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90270. /**
  90271. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90272. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90273. * 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)
  90274. */
  90275. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90276. /**
  90277. * This Observable will when a mesh has been imported into the scene.
  90278. */
  90279. onMeshImportedObservable: Observable<AbstractMesh>;
  90280. /**
  90281. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90282. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90283. */
  90284. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90285. /** @hidden */
  90286. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90287. /**
  90288. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90289. */
  90290. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90291. /**
  90292. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90293. */
  90294. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90295. /**
  90296. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90297. */
  90298. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90299. private _onPointerMove;
  90300. private _onPointerDown;
  90301. private _onPointerUp;
  90302. /** Callback called when a pointer move is detected */
  90303. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90304. /** Callback called when a pointer down is detected */
  90305. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90306. /** Callback called when a pointer up is detected */
  90307. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90308. /** Callback called when a pointer pick is detected */
  90309. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90310. /**
  90311. * 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).
  90312. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90313. */
  90314. onPrePointerObservable: Observable<PointerInfoPre>;
  90315. /**
  90316. * Observable event triggered each time an input event is received from the rendering canvas
  90317. */
  90318. onPointerObservable: Observable<PointerInfo>;
  90319. /**
  90320. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90321. */
  90322. readonly unTranslatedPointer: Vector2;
  90323. /** The distance in pixel that you have to move to prevent some events */
  90324. static DragMovementThreshold: number;
  90325. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90326. static LongPressDelay: number;
  90327. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90328. static DoubleClickDelay: number;
  90329. /** If you need to check double click without raising a single click at first click, enable this flag */
  90330. static ExclusiveDoubleClickMode: boolean;
  90331. private _initClickEvent;
  90332. private _initActionManager;
  90333. private _delayedSimpleClick;
  90334. private _delayedSimpleClickTimeout;
  90335. private _previousDelayedSimpleClickTimeout;
  90336. private _meshPickProceed;
  90337. private _previousButtonPressed;
  90338. private _currentPickResult;
  90339. private _previousPickResult;
  90340. private _totalPointersPressed;
  90341. private _doubleClickOccured;
  90342. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90343. cameraToUseForPointers: Nullable<Camera>;
  90344. private _pointerX;
  90345. private _pointerY;
  90346. private _unTranslatedPointerX;
  90347. private _unTranslatedPointerY;
  90348. private _startingPointerPosition;
  90349. private _previousStartingPointerPosition;
  90350. private _startingPointerTime;
  90351. private _previousStartingPointerTime;
  90352. private _pointerCaptures;
  90353. private _timeAccumulator;
  90354. private _currentStepId;
  90355. private _currentInternalStep;
  90356. /** @hidden */
  90357. _mirroredCameraPosition: Nullable<Vector3>;
  90358. /**
  90359. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90360. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90361. */
  90362. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90363. /**
  90364. * Observable event triggered each time an keyboard event is received from the hosting window
  90365. */
  90366. onKeyboardObservable: Observable<KeyboardInfo>;
  90367. private _onKeyDown;
  90368. private _onKeyUp;
  90369. private _onCanvasFocusObserver;
  90370. private _onCanvasBlurObserver;
  90371. private _useRightHandedSystem;
  90372. /**
  90373. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90374. */
  90375. useRightHandedSystem: boolean;
  90376. /**
  90377. * Sets the step Id used by deterministic lock step
  90378. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90379. * @param newStepId defines the step Id
  90380. */
  90381. setStepId(newStepId: number): void;
  90382. /**
  90383. * Gets the step Id used by deterministic lock step
  90384. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90385. * @returns the step Id
  90386. */
  90387. getStepId(): number;
  90388. /**
  90389. * Gets the internal step used by deterministic lock step
  90390. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90391. * @returns the internal step
  90392. */
  90393. getInternalStep(): number;
  90394. private _fogEnabled;
  90395. /**
  90396. * Gets or sets a boolean indicating if fog is enabled on this scene
  90397. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90398. * (Default is true)
  90399. */
  90400. fogEnabled: boolean;
  90401. private _fogMode;
  90402. /**
  90403. * Gets or sets the fog mode to use
  90404. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90405. * | mode | value |
  90406. * | --- | --- |
  90407. * | FOGMODE_NONE | 0 |
  90408. * | FOGMODE_EXP | 1 |
  90409. * | FOGMODE_EXP2 | 2 |
  90410. * | FOGMODE_LINEAR | 3 |
  90411. */
  90412. fogMode: number;
  90413. /**
  90414. * Gets or sets the fog color to use
  90415. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90416. * (Default is Color3(0.2, 0.2, 0.3))
  90417. */
  90418. fogColor: Color3;
  90419. /**
  90420. * Gets or sets the fog density to use
  90421. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90422. * (Default is 0.1)
  90423. */
  90424. fogDensity: number;
  90425. /**
  90426. * Gets or sets the fog start distance to use
  90427. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90428. * (Default is 0)
  90429. */
  90430. fogStart: number;
  90431. /**
  90432. * Gets or sets the fog end distance to use
  90433. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90434. * (Default is 1000)
  90435. */
  90436. fogEnd: number;
  90437. private _shadowsEnabled;
  90438. /**
  90439. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90440. */
  90441. shadowsEnabled: boolean;
  90442. private _lightsEnabled;
  90443. /**
  90444. * Gets or sets a boolean indicating if lights are enabled on this scene
  90445. */
  90446. lightsEnabled: boolean;
  90447. /** All of the active cameras added to this scene. */
  90448. activeCameras: Camera[];
  90449. private _activeCamera;
  90450. /** Gets or sets the current active camera */
  90451. activeCamera: Nullable<Camera>;
  90452. private _defaultMaterial;
  90453. /** The default material used on meshes when no material is affected */
  90454. /** The default material used on meshes when no material is affected */
  90455. defaultMaterial: Material;
  90456. private _texturesEnabled;
  90457. /**
  90458. * Gets or sets a boolean indicating if textures are enabled on this scene
  90459. */
  90460. texturesEnabled: boolean;
  90461. /**
  90462. * Gets or sets a boolean indicating if particles are enabled on this scene
  90463. */
  90464. particlesEnabled: boolean;
  90465. /**
  90466. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90467. */
  90468. spritesEnabled: boolean;
  90469. private _skeletonsEnabled;
  90470. /**
  90471. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90472. */
  90473. skeletonsEnabled: boolean;
  90474. /**
  90475. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90476. */
  90477. lensFlaresEnabled: boolean;
  90478. /**
  90479. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90481. */
  90482. collisionsEnabled: boolean;
  90483. private _collisionCoordinator;
  90484. /** @hidden */
  90485. readonly collisionCoordinator: ICollisionCoordinator;
  90486. /**
  90487. * Defines the gravity applied to this scene (used only for collisions)
  90488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90489. */
  90490. gravity: Vector3;
  90491. /**
  90492. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90493. */
  90494. postProcessesEnabled: boolean;
  90495. /**
  90496. * The list of postprocesses added to the scene
  90497. */
  90498. postProcesses: PostProcess[];
  90499. /**
  90500. * Gets the current postprocess manager
  90501. */
  90502. postProcessManager: PostProcessManager;
  90503. /**
  90504. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90505. */
  90506. renderTargetsEnabled: boolean;
  90507. /**
  90508. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90509. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90510. */
  90511. dumpNextRenderTargets: boolean;
  90512. /**
  90513. * The list of user defined render targets added to the scene
  90514. */
  90515. customRenderTargets: RenderTargetTexture[];
  90516. /**
  90517. * Defines if texture loading must be delayed
  90518. * If true, textures will only be loaded when they need to be rendered
  90519. */
  90520. useDelayedTextureLoading: boolean;
  90521. /**
  90522. * Gets the list of meshes imported to the scene through SceneLoader
  90523. */
  90524. importedMeshesFiles: String[];
  90525. /**
  90526. * Gets or sets a boolean indicating if probes are enabled on this scene
  90527. */
  90528. probesEnabled: boolean;
  90529. /**
  90530. * Gets or sets the current offline provider to use to store scene data
  90531. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90532. */
  90533. offlineProvider: IOfflineProvider;
  90534. /**
  90535. * Gets or sets the action manager associated with the scene
  90536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90537. */
  90538. actionManager: AbstractActionManager;
  90539. private _meshesForIntersections;
  90540. /**
  90541. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90542. */
  90543. proceduralTexturesEnabled: boolean;
  90544. private _engine;
  90545. private _totalVertices;
  90546. /** @hidden */
  90547. _activeIndices: PerfCounter;
  90548. /** @hidden */
  90549. _activeParticles: PerfCounter;
  90550. /** @hidden */
  90551. _activeBones: PerfCounter;
  90552. private _animationRatio;
  90553. /** @hidden */
  90554. _animationTimeLast: number;
  90555. /** @hidden */
  90556. _animationTime: number;
  90557. /**
  90558. * Gets or sets a general scale for animation speed
  90559. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90560. */
  90561. animationTimeScale: number;
  90562. /** @hidden */
  90563. _cachedMaterial: Nullable<Material>;
  90564. /** @hidden */
  90565. _cachedEffect: Nullable<Effect>;
  90566. /** @hidden */
  90567. _cachedVisibility: Nullable<number>;
  90568. private _renderId;
  90569. private _frameId;
  90570. private _executeWhenReadyTimeoutId;
  90571. private _intermediateRendering;
  90572. private _viewUpdateFlag;
  90573. private _projectionUpdateFlag;
  90574. private _alternateViewUpdateFlag;
  90575. private _alternateProjectionUpdateFlag;
  90576. /** @hidden */
  90577. _toBeDisposed: Nullable<IDisposable>[];
  90578. private _activeRequests;
  90579. /** @hidden */
  90580. _pendingData: any[];
  90581. private _isDisposed;
  90582. /**
  90583. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90584. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90585. */
  90586. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90587. private _activeMeshes;
  90588. private _processedMaterials;
  90589. private _renderTargets;
  90590. /** @hidden */
  90591. _activeParticleSystems: SmartArray<IParticleSystem>;
  90592. private _activeSkeletons;
  90593. private _softwareSkinnedMeshes;
  90594. private _renderingManager;
  90595. /** @hidden */
  90596. _activeAnimatables: Animatable[];
  90597. private _transformMatrix;
  90598. private _sceneUbo;
  90599. private _alternateSceneUbo;
  90600. private _viewMatrix;
  90601. private _projectionMatrix;
  90602. private _alternateViewMatrix;
  90603. private _alternateProjectionMatrix;
  90604. private _alternateTransformMatrix;
  90605. private _useAlternateCameraConfiguration;
  90606. private _alternateRendering;
  90607. private _wheelEventName;
  90608. /** @hidden */
  90609. _forcedViewPosition: Nullable<Vector3>;
  90610. /** @hidden */
  90611. readonly _isAlternateRenderingEnabled: boolean;
  90612. private _frustumPlanes;
  90613. /**
  90614. * Gets the list of frustum planes (built from the active camera)
  90615. */
  90616. readonly frustumPlanes: Plane[];
  90617. /**
  90618. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90619. * This is useful if there are more lights that the maximum simulteanous authorized
  90620. */
  90621. requireLightSorting: boolean;
  90622. /** @hidden */
  90623. readonly useMaterialMeshMap: boolean;
  90624. /** @hidden */
  90625. readonly useClonedMeshhMap: boolean;
  90626. private _pointerOverMesh;
  90627. private _pickedDownMesh;
  90628. private _pickedUpMesh;
  90629. private _externalData;
  90630. private _uid;
  90631. /**
  90632. * @hidden
  90633. * Backing store of defined scene components.
  90634. */
  90635. _components: ISceneComponent[];
  90636. /**
  90637. * @hidden
  90638. * Backing store of defined scene components.
  90639. */
  90640. _serializableComponents: ISceneSerializableComponent[];
  90641. /**
  90642. * List of components to register on the next registration step.
  90643. */
  90644. private _transientComponents;
  90645. /**
  90646. * Registers the transient components if needed.
  90647. */
  90648. private _registerTransientComponents;
  90649. /**
  90650. * @hidden
  90651. * Add a component to the scene.
  90652. * Note that the ccomponent could be registered on th next frame if this is called after
  90653. * the register component stage.
  90654. * @param component Defines the component to add to the scene
  90655. */
  90656. _addComponent(component: ISceneComponent): void;
  90657. /**
  90658. * @hidden
  90659. * Gets a component from the scene.
  90660. * @param name defines the name of the component to retrieve
  90661. * @returns the component or null if not present
  90662. */
  90663. _getComponent(name: string): Nullable<ISceneComponent>;
  90664. /**
  90665. * @hidden
  90666. * Defines the actions happening before camera updates.
  90667. */
  90668. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  90669. /**
  90670. * @hidden
  90671. * Defines the actions happening before clear the canvas.
  90672. */
  90673. _beforeClearStage: Stage<SimpleStageAction>;
  90674. /**
  90675. * @hidden
  90676. * Defines the actions when collecting render targets for the frame.
  90677. */
  90678. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90679. /**
  90680. * @hidden
  90681. * Defines the actions happening for one camera in the frame.
  90682. */
  90683. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90684. /**
  90685. * @hidden
  90686. * Defines the actions happening during the per mesh ready checks.
  90687. */
  90688. _isReadyForMeshStage: Stage<MeshStageAction>;
  90689. /**
  90690. * @hidden
  90691. * Defines the actions happening before evaluate active mesh checks.
  90692. */
  90693. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  90694. /**
  90695. * @hidden
  90696. * Defines the actions happening during the evaluate sub mesh checks.
  90697. */
  90698. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  90699. /**
  90700. * @hidden
  90701. * Defines the actions happening during the active mesh stage.
  90702. */
  90703. _activeMeshStage: Stage<ActiveMeshStageAction>;
  90704. /**
  90705. * @hidden
  90706. * Defines the actions happening during the per camera render target step.
  90707. */
  90708. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  90709. /**
  90710. * @hidden
  90711. * Defines the actions happening just before the active camera is drawing.
  90712. */
  90713. _beforeCameraDrawStage: Stage<CameraStageAction>;
  90714. /**
  90715. * @hidden
  90716. * Defines the actions happening just before a render target is drawing.
  90717. */
  90718. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90719. /**
  90720. * @hidden
  90721. * Defines the actions happening just before a rendering group is drawing.
  90722. */
  90723. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90724. /**
  90725. * @hidden
  90726. * Defines the actions happening just before a mesh is drawing.
  90727. */
  90728. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90729. /**
  90730. * @hidden
  90731. * Defines the actions happening just after a mesh has been drawn.
  90732. */
  90733. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90734. /**
  90735. * @hidden
  90736. * Defines the actions happening just after a rendering group has been drawn.
  90737. */
  90738. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90739. /**
  90740. * @hidden
  90741. * Defines the actions happening just after the active camera has been drawn.
  90742. */
  90743. _afterCameraDrawStage: Stage<CameraStageAction>;
  90744. /**
  90745. * @hidden
  90746. * Defines the actions happening just after a render target has been drawn.
  90747. */
  90748. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90749. /**
  90750. * @hidden
  90751. * Defines the actions happening just after rendering all cameras and computing intersections.
  90752. */
  90753. _afterRenderStage: Stage<SimpleStageAction>;
  90754. /**
  90755. * @hidden
  90756. * Defines the actions happening when a pointer move event happens.
  90757. */
  90758. _pointerMoveStage: Stage<PointerMoveStageAction>;
  90759. /**
  90760. * @hidden
  90761. * Defines the actions happening when a pointer down event happens.
  90762. */
  90763. _pointerDownStage: Stage<PointerUpDownStageAction>;
  90764. /**
  90765. * @hidden
  90766. * Defines the actions happening when a pointer up event happens.
  90767. */
  90768. _pointerUpStage: Stage<PointerUpDownStageAction>;
  90769. /**
  90770. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  90771. */
  90772. private geometriesByUniqueId;
  90773. /**
  90774. * Creates a new Scene
  90775. * @param engine defines the engine to use to render this scene
  90776. * @param options defines the scene options
  90777. */
  90778. constructor(engine: Engine, options?: SceneOptions);
  90779. private _defaultMeshCandidates;
  90780. /**
  90781. * @hidden
  90782. */
  90783. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  90784. private _defaultSubMeshCandidates;
  90785. /**
  90786. * @hidden
  90787. */
  90788. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  90789. /**
  90790. * Sets the default candidate providers for the scene.
  90791. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  90792. * and getCollidingSubMeshCandidates to their default function
  90793. */
  90794. setDefaultCandidateProviders(): void;
  90795. /**
  90796. * Gets the mesh that is currently under the pointer
  90797. */
  90798. readonly meshUnderPointer: Nullable<AbstractMesh>;
  90799. /**
  90800. * Gets or sets the current on-screen X position of the pointer
  90801. */
  90802. pointerX: number;
  90803. /**
  90804. * Gets or sets the current on-screen Y position of the pointer
  90805. */
  90806. pointerY: number;
  90807. /**
  90808. * Gets the cached material (ie. the latest rendered one)
  90809. * @returns the cached material
  90810. */
  90811. getCachedMaterial(): Nullable<Material>;
  90812. /**
  90813. * Gets the cached effect (ie. the latest rendered one)
  90814. * @returns the cached effect
  90815. */
  90816. getCachedEffect(): Nullable<Effect>;
  90817. /**
  90818. * Gets the cached visibility state (ie. the latest rendered one)
  90819. * @returns the cached visibility state
  90820. */
  90821. getCachedVisibility(): Nullable<number>;
  90822. /**
  90823. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  90824. * @param material defines the current material
  90825. * @param effect defines the current effect
  90826. * @param visibility defines the current visibility state
  90827. * @returns true if one parameter is not cached
  90828. */
  90829. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  90830. /**
  90831. * Gets the engine associated with the scene
  90832. * @returns an Engine
  90833. */
  90834. getEngine(): Engine;
  90835. /**
  90836. * Gets the total number of vertices rendered per frame
  90837. * @returns the total number of vertices rendered per frame
  90838. */
  90839. getTotalVertices(): number;
  90840. /**
  90841. * Gets the performance counter for total vertices
  90842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90843. */
  90844. readonly totalVerticesPerfCounter: PerfCounter;
  90845. /**
  90846. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  90847. * @returns the total number of active indices rendered per frame
  90848. */
  90849. getActiveIndices(): number;
  90850. /**
  90851. * Gets the performance counter for active indices
  90852. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90853. */
  90854. readonly totalActiveIndicesPerfCounter: PerfCounter;
  90855. /**
  90856. * Gets the total number of active particles rendered per frame
  90857. * @returns the total number of active particles rendered per frame
  90858. */
  90859. getActiveParticles(): number;
  90860. /**
  90861. * Gets the performance counter for active particles
  90862. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90863. */
  90864. readonly activeParticlesPerfCounter: PerfCounter;
  90865. /**
  90866. * Gets the total number of active bones rendered per frame
  90867. * @returns the total number of active bones rendered per frame
  90868. */
  90869. getActiveBones(): number;
  90870. /**
  90871. * Gets the performance counter for active bones
  90872. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90873. */
  90874. readonly activeBonesPerfCounter: PerfCounter;
  90875. /**
  90876. * Gets the array of active meshes
  90877. * @returns an array of AbstractMesh
  90878. */
  90879. getActiveMeshes(): SmartArray<AbstractMesh>;
  90880. /**
  90881. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  90882. * @returns a number
  90883. */
  90884. getAnimationRatio(): number;
  90885. /**
  90886. * Gets an unique Id for the current render phase
  90887. * @returns a number
  90888. */
  90889. getRenderId(): number;
  90890. /**
  90891. * Gets an unique Id for the current frame
  90892. * @returns a number
  90893. */
  90894. getFrameId(): number;
  90895. /** Call this function if you want to manually increment the render Id*/
  90896. incrementRenderId(): void;
  90897. private _updatePointerPosition;
  90898. private _createUbo;
  90899. private _createAlternateUbo;
  90900. private _setRayOnPointerInfo;
  90901. /**
  90902. * Use this method to simulate a pointer move on a mesh
  90903. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90904. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90905. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90906. * @returns the current scene
  90907. */
  90908. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90909. private _processPointerMove;
  90910. private _checkPrePointerObservable;
  90911. /**
  90912. * Use this method to simulate a pointer down on a mesh
  90913. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90914. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90915. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90916. * @returns the current scene
  90917. */
  90918. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90919. private _processPointerDown;
  90920. /**
  90921. * Use this method to simulate a pointer up on a mesh
  90922. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90923. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90924. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90925. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  90926. * @returns the current scene
  90927. */
  90928. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  90929. private _processPointerUp;
  90930. /**
  90931. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  90932. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  90933. * @returns true if the pointer was captured
  90934. */
  90935. isPointerCaptured(pointerId?: number): boolean;
  90936. /** @hidden */
  90937. _isPointerSwiping(): boolean;
  90938. /**
  90939. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  90940. * @param attachUp defines if you want to attach events to pointerup
  90941. * @param attachDown defines if you want to attach events to pointerdown
  90942. * @param attachMove defines if you want to attach events to pointermove
  90943. */
  90944. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90945. /** Detaches all event handlers*/
  90946. detachControl(): void;
  90947. /**
  90948. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90949. * Delay loaded resources are not taking in account
  90950. * @return true if all required resources are ready
  90951. */
  90952. isReady(): boolean;
  90953. /** Resets all cached information relative to material (including effect and visibility) */
  90954. resetCachedMaterial(): void;
  90955. /**
  90956. * Registers a function to be called before every frame render
  90957. * @param func defines the function to register
  90958. */
  90959. registerBeforeRender(func: () => void): void;
  90960. /**
  90961. * Unregisters a function called before every frame render
  90962. * @param func defines the function to unregister
  90963. */
  90964. unregisterBeforeRender(func: () => void): void;
  90965. /**
  90966. * Registers a function to be called after every frame render
  90967. * @param func defines the function to register
  90968. */
  90969. registerAfterRender(func: () => void): void;
  90970. /**
  90971. * Unregisters a function called after every frame render
  90972. * @param func defines the function to unregister
  90973. */
  90974. unregisterAfterRender(func: () => void): void;
  90975. private _executeOnceBeforeRender;
  90976. /**
  90977. * The provided function will run before render once and will be disposed afterwards.
  90978. * A timeout delay can be provided so that the function will be executed in N ms.
  90979. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90980. * @param func The function to be executed.
  90981. * @param timeout optional delay in ms
  90982. */
  90983. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90984. /** @hidden */
  90985. _addPendingData(data: any): void;
  90986. /** @hidden */
  90987. _removePendingData(data: any): void;
  90988. /**
  90989. * Returns the number of items waiting to be loaded
  90990. * @returns the number of items waiting to be loaded
  90991. */
  90992. getWaitingItemsCount(): number;
  90993. /**
  90994. * Returns a boolean indicating if the scene is still loading data
  90995. */
  90996. readonly isLoading: boolean;
  90997. /**
  90998. * Registers a function to be executed when the scene is ready
  90999. * @param {Function} func - the function to be executed
  91000. */
  91001. executeWhenReady(func: () => void): void;
  91002. /**
  91003. * Returns a promise that resolves when the scene is ready
  91004. * @returns A promise that resolves when the scene is ready
  91005. */
  91006. whenReadyAsync(): Promise<void>;
  91007. /** @hidden */
  91008. _checkIsReady(): void;
  91009. /**
  91010. * Gets all animatable attached to the scene
  91011. */
  91012. readonly animatables: Animatable[];
  91013. /**
  91014. * Resets the last animation time frame.
  91015. * Useful to override when animations start running when loading a scene for the first time.
  91016. */
  91017. resetLastAnimationTimeFrame(): void;
  91018. /** @hidden */
  91019. _switchToAlternateCameraConfiguration(active: boolean): void;
  91020. /**
  91021. * Gets the current view matrix
  91022. * @returns a Matrix
  91023. */
  91024. getViewMatrix(): Matrix;
  91025. /**
  91026. * Gets the current projection matrix
  91027. * @returns a Matrix
  91028. */
  91029. getProjectionMatrix(): Matrix;
  91030. /**
  91031. * Gets the current transform matrix
  91032. * @returns a Matrix made of View * Projection
  91033. */
  91034. getTransformMatrix(): Matrix;
  91035. /**
  91036. * Sets the current transform matrix
  91037. * @param view defines the View matrix to use
  91038. * @param projection defines the Projection matrix to use
  91039. */
  91040. setTransformMatrix(view: Matrix, projection: Matrix): void;
  91041. /** @hidden */
  91042. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  91043. /**
  91044. * Gets the uniform buffer used to store scene data
  91045. * @returns a UniformBuffer
  91046. */
  91047. getSceneUniformBuffer(): UniformBuffer;
  91048. /**
  91049. * Gets an unique (relatively to the current scene) Id
  91050. * @returns an unique number for the scene
  91051. */
  91052. getUniqueId(): number;
  91053. /**
  91054. * Add a mesh to the list of scene's meshes
  91055. * @param newMesh defines the mesh to add
  91056. * @param recursive if all child meshes should also be added to the scene
  91057. */
  91058. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  91059. /**
  91060. * Remove a mesh for the list of scene's meshes
  91061. * @param toRemove defines the mesh to remove
  91062. * @param recursive if all child meshes should also be removed from the scene
  91063. * @returns the index where the mesh was in the mesh list
  91064. */
  91065. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91066. /**
  91067. * Add a transform node to the list of scene's transform nodes
  91068. * @param newTransformNode defines the transform node to add
  91069. */
  91070. addTransformNode(newTransformNode: TransformNode): void;
  91071. /**
  91072. * Remove a transform node for the list of scene's transform nodes
  91073. * @param toRemove defines the transform node to remove
  91074. * @returns the index where the transform node was in the transform node list
  91075. */
  91076. removeTransformNode(toRemove: TransformNode): number;
  91077. /**
  91078. * Remove a skeleton for the list of scene's skeletons
  91079. * @param toRemove defines the skeleton to remove
  91080. * @returns the index where the skeleton was in the skeleton list
  91081. */
  91082. removeSkeleton(toRemove: Skeleton): number;
  91083. /**
  91084. * Remove a morph target for the list of scene's morph targets
  91085. * @param toRemove defines the morph target to remove
  91086. * @returns the index where the morph target was in the morph target list
  91087. */
  91088. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91089. /**
  91090. * Remove a light for the list of scene's lights
  91091. * @param toRemove defines the light to remove
  91092. * @returns the index where the light was in the light list
  91093. */
  91094. removeLight(toRemove: Light): number;
  91095. /**
  91096. * Remove a camera for the list of scene's cameras
  91097. * @param toRemove defines the camera to remove
  91098. * @returns the index where the camera was in the camera list
  91099. */
  91100. removeCamera(toRemove: Camera): number;
  91101. /**
  91102. * Remove a particle system for the list of scene's particle systems
  91103. * @param toRemove defines the particle system to remove
  91104. * @returns the index where the particle system was in the particle system list
  91105. */
  91106. removeParticleSystem(toRemove: IParticleSystem): number;
  91107. /**
  91108. * Remove a animation for the list of scene's animations
  91109. * @param toRemove defines the animation to remove
  91110. * @returns the index where the animation was in the animation list
  91111. */
  91112. removeAnimation(toRemove: Animation): number;
  91113. /**
  91114. * Removes the given animation group from this scene.
  91115. * @param toRemove The animation group to remove
  91116. * @returns The index of the removed animation group
  91117. */
  91118. removeAnimationGroup(toRemove: AnimationGroup): number;
  91119. /**
  91120. * Removes the given multi-material from this scene.
  91121. * @param toRemove The multi-material to remove
  91122. * @returns The index of the removed multi-material
  91123. */
  91124. removeMultiMaterial(toRemove: MultiMaterial): number;
  91125. /**
  91126. * Removes the given material from this scene.
  91127. * @param toRemove The material to remove
  91128. * @returns The index of the removed material
  91129. */
  91130. removeMaterial(toRemove: Material): number;
  91131. /**
  91132. * Removes the given action manager from this scene.
  91133. * @param toRemove The action manager to remove
  91134. * @returns The index of the removed action manager
  91135. */
  91136. removeActionManager(toRemove: AbstractActionManager): number;
  91137. /**
  91138. * Removes the given texture from this scene.
  91139. * @param toRemove The texture to remove
  91140. * @returns The index of the removed texture
  91141. */
  91142. removeTexture(toRemove: BaseTexture): number;
  91143. /**
  91144. * Adds the given light to this scene
  91145. * @param newLight The light to add
  91146. */
  91147. addLight(newLight: Light): void;
  91148. /**
  91149. * Sorts the list list based on light priorities
  91150. */
  91151. sortLightsByPriority(): void;
  91152. /**
  91153. * Adds the given camera to this scene
  91154. * @param newCamera The camera to add
  91155. */
  91156. addCamera(newCamera: Camera): void;
  91157. /**
  91158. * Adds the given skeleton to this scene
  91159. * @param newSkeleton The skeleton to add
  91160. */
  91161. addSkeleton(newSkeleton: Skeleton): void;
  91162. /**
  91163. * Adds the given particle system to this scene
  91164. * @param newParticleSystem The particle system to add
  91165. */
  91166. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91167. /**
  91168. * Adds the given animation to this scene
  91169. * @param newAnimation The animation to add
  91170. */
  91171. addAnimation(newAnimation: Animation): void;
  91172. /**
  91173. * Adds the given animation group to this scene.
  91174. * @param newAnimationGroup The animation group to add
  91175. */
  91176. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91177. /**
  91178. * Adds the given multi-material to this scene
  91179. * @param newMultiMaterial The multi-material to add
  91180. */
  91181. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91182. /**
  91183. * Adds the given material to this scene
  91184. * @param newMaterial The material to add
  91185. */
  91186. addMaterial(newMaterial: Material): void;
  91187. /**
  91188. * Adds the given morph target to this scene
  91189. * @param newMorphTargetManager The morph target to add
  91190. */
  91191. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91192. /**
  91193. * Adds the given geometry to this scene
  91194. * @param newGeometry The geometry to add
  91195. */
  91196. addGeometry(newGeometry: Geometry): void;
  91197. /**
  91198. * Adds the given action manager to this scene
  91199. * @param newActionManager The action manager to add
  91200. */
  91201. addActionManager(newActionManager: AbstractActionManager): void;
  91202. /**
  91203. * Adds the given texture to this scene.
  91204. * @param newTexture The texture to add
  91205. */
  91206. addTexture(newTexture: BaseTexture): void;
  91207. /**
  91208. * Switch active camera
  91209. * @param newCamera defines the new active camera
  91210. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91211. */
  91212. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91213. /**
  91214. * sets the active camera of the scene using its ID
  91215. * @param id defines the camera's ID
  91216. * @return the new active camera or null if none found.
  91217. */
  91218. setActiveCameraByID(id: string): Nullable<Camera>;
  91219. /**
  91220. * sets the active camera of the scene using its name
  91221. * @param name defines the camera's name
  91222. * @returns the new active camera or null if none found.
  91223. */
  91224. setActiveCameraByName(name: string): Nullable<Camera>;
  91225. /**
  91226. * get an animation group using its name
  91227. * @param name defines the material's name
  91228. * @return the animation group or null if none found.
  91229. */
  91230. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91231. /**
  91232. * Get a material using its unique id
  91233. * @param uniqueId defines the material's unique id
  91234. * @return the material or null if none found.
  91235. */
  91236. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  91237. /**
  91238. * get a material using its id
  91239. * @param id defines the material's ID
  91240. * @return the material or null if none found.
  91241. */
  91242. getMaterialByID(id: string): Nullable<Material>;
  91243. /**
  91244. * Gets a material using its name
  91245. * @param name defines the material's name
  91246. * @return the material or null if none found.
  91247. */
  91248. getMaterialByName(name: string): Nullable<Material>;
  91249. /**
  91250. * Gets a camera using its id
  91251. * @param id defines the id to look for
  91252. * @returns the camera or null if not found
  91253. */
  91254. getCameraByID(id: string): Nullable<Camera>;
  91255. /**
  91256. * Gets a camera using its unique id
  91257. * @param uniqueId defines the unique id to look for
  91258. * @returns the camera or null if not found
  91259. */
  91260. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91261. /**
  91262. * Gets a camera using its name
  91263. * @param name defines the camera's name
  91264. * @return the camera or null if none found.
  91265. */
  91266. getCameraByName(name: string): Nullable<Camera>;
  91267. /**
  91268. * Gets a bone using its id
  91269. * @param id defines the bone's id
  91270. * @return the bone or null if not found
  91271. */
  91272. getBoneByID(id: string): Nullable<Bone>;
  91273. /**
  91274. * Gets a bone using its id
  91275. * @param name defines the bone's name
  91276. * @return the bone or null if not found
  91277. */
  91278. getBoneByName(name: string): Nullable<Bone>;
  91279. /**
  91280. * Gets a light node using its name
  91281. * @param name defines the the light's name
  91282. * @return the light or null if none found.
  91283. */
  91284. getLightByName(name: string): Nullable<Light>;
  91285. /**
  91286. * Gets a light node using its id
  91287. * @param id defines the light's id
  91288. * @return the light or null if none found.
  91289. */
  91290. getLightByID(id: string): Nullable<Light>;
  91291. /**
  91292. * Gets a light node using its scene-generated unique ID
  91293. * @param uniqueId defines the light's unique id
  91294. * @return the light or null if none found.
  91295. */
  91296. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91297. /**
  91298. * Gets a particle system by id
  91299. * @param id defines the particle system id
  91300. * @return the corresponding system or null if none found
  91301. */
  91302. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91303. /**
  91304. * Gets a geometry using its ID
  91305. * @param id defines the geometry's id
  91306. * @return the geometry or null if none found.
  91307. */
  91308. getGeometryByID(id: string): Nullable<Geometry>;
  91309. private _getGeometryByUniqueID;
  91310. /**
  91311. * Add a new geometry to this scene
  91312. * @param geometry defines the geometry to be added to the scene.
  91313. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91314. * @return a boolean defining if the geometry was added or not
  91315. */
  91316. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91317. /**
  91318. * Removes an existing geometry
  91319. * @param geometry defines the geometry to be removed from the scene
  91320. * @return a boolean defining if the geometry was removed or not
  91321. */
  91322. removeGeometry(geometry: Geometry): boolean;
  91323. /**
  91324. * Gets the list of geometries attached to the scene
  91325. * @returns an array of Geometry
  91326. */
  91327. getGeometries(): Geometry[];
  91328. /**
  91329. * Gets the first added mesh found of a given ID
  91330. * @param id defines the id to search for
  91331. * @return the mesh found or null if not found at all
  91332. */
  91333. getMeshByID(id: string): Nullable<AbstractMesh>;
  91334. /**
  91335. * Gets a list of meshes using their id
  91336. * @param id defines the id to search for
  91337. * @returns a list of meshes
  91338. */
  91339. getMeshesByID(id: string): Array<AbstractMesh>;
  91340. /**
  91341. * Gets the first added transform node found of a given ID
  91342. * @param id defines the id to search for
  91343. * @return the found transform node or null if not found at all.
  91344. */
  91345. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91346. /**
  91347. * Gets a transform node with its auto-generated unique id
  91348. * @param uniqueId efines the unique id to search for
  91349. * @return the found transform node or null if not found at all.
  91350. */
  91351. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  91352. /**
  91353. * Gets a list of transform nodes using their id
  91354. * @param id defines the id to search for
  91355. * @returns a list of transform nodes
  91356. */
  91357. getTransformNodesByID(id: string): Array<TransformNode>;
  91358. /**
  91359. * Gets a mesh with its auto-generated unique id
  91360. * @param uniqueId defines the unique id to search for
  91361. * @return the found mesh or null if not found at all.
  91362. */
  91363. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91364. /**
  91365. * Gets a the last added mesh using a given id
  91366. * @param id defines the id to search for
  91367. * @return the found mesh or null if not found at all.
  91368. */
  91369. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91370. /**
  91371. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91372. * @param id defines the id to search for
  91373. * @return the found node or null if not found at all
  91374. */
  91375. getLastEntryByID(id: string): Nullable<Node>;
  91376. /**
  91377. * Gets a node (Mesh, Camera, Light) using a given id
  91378. * @param id defines the id to search for
  91379. * @return the found node or null if not found at all
  91380. */
  91381. getNodeByID(id: string): Nullable<Node>;
  91382. /**
  91383. * Gets a node (Mesh, Camera, Light) using a given name
  91384. * @param name defines the name to search for
  91385. * @return the found node or null if not found at all.
  91386. */
  91387. getNodeByName(name: string): Nullable<Node>;
  91388. /**
  91389. * Gets a mesh using a given name
  91390. * @param name defines the name to search for
  91391. * @return the found mesh or null if not found at all.
  91392. */
  91393. getMeshByName(name: string): Nullable<AbstractMesh>;
  91394. /**
  91395. * Gets a transform node using a given name
  91396. * @param name defines the name to search for
  91397. * @return the found transform node or null if not found at all.
  91398. */
  91399. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91400. /**
  91401. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91402. * @param id defines the id to search for
  91403. * @return the found skeleton or null if not found at all.
  91404. */
  91405. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91406. /**
  91407. * Gets a skeleton using a given auto generated unique id
  91408. * @param uniqueId defines the unique id to search for
  91409. * @return the found skeleton or null if not found at all.
  91410. */
  91411. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  91412. /**
  91413. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91414. * @param id defines the id to search for
  91415. * @return the found skeleton or null if not found at all.
  91416. */
  91417. getSkeletonById(id: string): Nullable<Skeleton>;
  91418. /**
  91419. * Gets a skeleton using a given name
  91420. * @param name defines the name to search for
  91421. * @return the found skeleton or null if not found at all.
  91422. */
  91423. getSkeletonByName(name: string): Nullable<Skeleton>;
  91424. /**
  91425. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91426. * @param id defines the id to search for
  91427. * @return the found morph target manager or null if not found at all.
  91428. */
  91429. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91430. /**
  91431. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91432. * @param id defines the id to search for
  91433. * @return the found morph target or null if not found at all.
  91434. */
  91435. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91436. /**
  91437. * Gets a boolean indicating if the given mesh is active
  91438. * @param mesh defines the mesh to look for
  91439. * @returns true if the mesh is in the active list
  91440. */
  91441. isActiveMesh(mesh: AbstractMesh): boolean;
  91442. /**
  91443. * Return a unique id as a string which can serve as an identifier for the scene
  91444. */
  91445. readonly uid: string;
  91446. /**
  91447. * Add an externaly attached data from its key.
  91448. * This method call will fail and return false, if such key already exists.
  91449. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91450. * @param key the unique key that identifies the data
  91451. * @param data the data object to associate to the key for this Engine instance
  91452. * @return true if no such key were already present and the data was added successfully, false otherwise
  91453. */
  91454. addExternalData<T>(key: string, data: T): boolean;
  91455. /**
  91456. * Get an externaly attached data from its key
  91457. * @param key the unique key that identifies the data
  91458. * @return the associated data, if present (can be null), or undefined if not present
  91459. */
  91460. getExternalData<T>(key: string): Nullable<T>;
  91461. /**
  91462. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91463. * @param key the unique key that identifies the data
  91464. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91465. * @return the associated data, can be null if the factory returned null.
  91466. */
  91467. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91468. /**
  91469. * Remove an externaly attached data from the Engine instance
  91470. * @param key the unique key that identifies the data
  91471. * @return true if the data was successfully removed, false if it doesn't exist
  91472. */
  91473. removeExternalData(key: string): boolean;
  91474. private _evaluateSubMesh;
  91475. /**
  91476. * Clear the processed materials smart array preventing retention point in material dispose.
  91477. */
  91478. freeProcessedMaterials(): void;
  91479. private _preventFreeActiveMeshesAndRenderingGroups;
  91480. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91481. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91482. * when disposing several meshes in a row or a hierarchy of meshes.
  91483. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91484. */
  91485. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91486. /**
  91487. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91488. */
  91489. freeActiveMeshes(): void;
  91490. /**
  91491. * Clear the info related to rendering groups preventing retention points during dispose.
  91492. */
  91493. freeRenderingGroups(): void;
  91494. /** @hidden */
  91495. _isInIntermediateRendering(): boolean;
  91496. /**
  91497. * Lambda returning the list of potentially active meshes.
  91498. */
  91499. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91500. /**
  91501. * Lambda returning the list of potentially active sub meshes.
  91502. */
  91503. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91504. /**
  91505. * Lambda returning the list of potentially intersecting sub meshes.
  91506. */
  91507. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91508. /**
  91509. * Lambda returning the list of potentially colliding sub meshes.
  91510. */
  91511. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91512. private _activeMeshesFrozen;
  91513. /**
  91514. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91515. * @returns the current scene
  91516. */
  91517. freezeActiveMeshes(): Scene;
  91518. /**
  91519. * Use this function to restart evaluating active meshes on every frame
  91520. * @returns the current scene
  91521. */
  91522. unfreezeActiveMeshes(): Scene;
  91523. private _evaluateActiveMeshes;
  91524. private _activeMesh;
  91525. /**
  91526. * Update the transform matrix to update from the current active camera
  91527. * @param force defines a boolean used to force the update even if cache is up to date
  91528. */
  91529. updateTransformMatrix(force?: boolean): void;
  91530. /**
  91531. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  91532. * @param alternateCamera defines the camera to use
  91533. */
  91534. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  91535. /** @hidden */
  91536. _allowPostProcessClearColor: boolean;
  91537. private _renderForCamera;
  91538. private _processSubCameras;
  91539. private _checkIntersections;
  91540. /** @hidden */
  91541. _advancePhysicsEngineStep(step: number): void;
  91542. /**
  91543. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91544. */
  91545. getDeterministicFrameTime: () => number;
  91546. /** @hidden */
  91547. _animate(): void;
  91548. /**
  91549. * Render the scene
  91550. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91551. */
  91552. render(updateCameras?: boolean): void;
  91553. /**
  91554. * Freeze all materials
  91555. * A frozen material will not be updatable but should be faster to render
  91556. */
  91557. freezeMaterials(): void;
  91558. /**
  91559. * Unfreeze all materials
  91560. * A frozen material will not be updatable but should be faster to render
  91561. */
  91562. unfreezeMaterials(): void;
  91563. /**
  91564. * Releases all held ressources
  91565. */
  91566. dispose(): void;
  91567. /**
  91568. * Gets if the scene is already disposed
  91569. */
  91570. readonly isDisposed: boolean;
  91571. /**
  91572. * Call this function to reduce memory footprint of the scene.
  91573. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91574. */
  91575. clearCachedVertexData(): void;
  91576. /**
  91577. * This function will remove the local cached buffer data from texture.
  91578. * It will save memory but will prevent the texture from being rebuilt
  91579. */
  91580. cleanCachedTextureBuffer(): void;
  91581. /**
  91582. * Get the world extend vectors with an optional filter
  91583. *
  91584. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91585. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91586. */
  91587. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91588. min: Vector3;
  91589. max: Vector3;
  91590. };
  91591. /**
  91592. * Creates a ray that can be used to pick in the scene
  91593. * @param x defines the x coordinate of the origin (on-screen)
  91594. * @param y defines the y coordinate of the origin (on-screen)
  91595. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91596. * @param camera defines the camera to use for the picking
  91597. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91598. * @returns a Ray
  91599. */
  91600. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91601. /**
  91602. * Creates a ray that can be used to pick in the scene
  91603. * @param x defines the x coordinate of the origin (on-screen)
  91604. * @param y defines the y coordinate of the origin (on-screen)
  91605. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91606. * @param result defines the ray where to store the picking ray
  91607. * @param camera defines the camera to use for the picking
  91608. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91609. * @returns the current scene
  91610. */
  91611. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91612. /**
  91613. * Creates a ray that can be used to pick in the scene
  91614. * @param x defines the x coordinate of the origin (on-screen)
  91615. * @param y defines the y coordinate of the origin (on-screen)
  91616. * @param camera defines the camera to use for the picking
  91617. * @returns a Ray
  91618. */
  91619. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91620. /**
  91621. * Creates a ray that can be used to pick in the scene
  91622. * @param x defines the x coordinate of the origin (on-screen)
  91623. * @param y defines the y coordinate of the origin (on-screen)
  91624. * @param result defines the ray where to store the picking ray
  91625. * @param camera defines the camera to use for the picking
  91626. * @returns the current scene
  91627. */
  91628. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91629. /** Launch a ray to try to pick a mesh in the scene
  91630. * @param x position on screen
  91631. * @param y position on screen
  91632. * @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
  91633. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91634. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91636. * @returns a PickingInfo
  91637. */
  91638. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91639. /** Use the given ray to pick a mesh in the scene
  91640. * @param ray The ray to use to pick meshes
  91641. * @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
  91642. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91643. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91644. * @returns a PickingInfo
  91645. */
  91646. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91647. /**
  91648. * Launch a ray to try to pick a mesh in the scene
  91649. * @param x X position on screen
  91650. * @param y Y position on screen
  91651. * @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
  91652. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91653. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91654. * @returns an array of PickingInfo
  91655. */
  91656. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91657. /**
  91658. * Launch a ray to try to pick a mesh in the scene
  91659. * @param ray Ray to use
  91660. * @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
  91661. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91662. * @returns an array of PickingInfo
  91663. */
  91664. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91665. /**
  91666. * Force the value of meshUnderPointer
  91667. * @param mesh defines the mesh to use
  91668. */
  91669. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91670. /**
  91671. * Gets the mesh under the pointer
  91672. * @returns a Mesh or null if no mesh is under the pointer
  91673. */
  91674. getPointerOverMesh(): Nullable<AbstractMesh>;
  91675. /** @hidden */
  91676. _rebuildGeometries(): void;
  91677. /** @hidden */
  91678. _rebuildTextures(): void;
  91679. private _getByTags;
  91680. /**
  91681. * Get a list of meshes by tags
  91682. * @param tagsQuery defines the tags query to use
  91683. * @param forEach defines a predicate used to filter results
  91684. * @returns an array of Mesh
  91685. */
  91686. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  91687. /**
  91688. * Get a list of cameras by tags
  91689. * @param tagsQuery defines the tags query to use
  91690. * @param forEach defines a predicate used to filter results
  91691. * @returns an array of Camera
  91692. */
  91693. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  91694. /**
  91695. * Get a list of lights by tags
  91696. * @param tagsQuery defines the tags query to use
  91697. * @param forEach defines a predicate used to filter results
  91698. * @returns an array of Light
  91699. */
  91700. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  91701. /**
  91702. * Get a list of materials by tags
  91703. * @param tagsQuery defines the tags query to use
  91704. * @param forEach defines a predicate used to filter results
  91705. * @returns an array of Material
  91706. */
  91707. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  91708. /**
  91709. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91710. * This allowed control for front to back rendering or reversly depending of the special needs.
  91711. *
  91712. * @param renderingGroupId The rendering group id corresponding to its index
  91713. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91714. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91715. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91716. */
  91717. 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;
  91718. /**
  91719. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91720. *
  91721. * @param renderingGroupId The rendering group id corresponding to its index
  91722. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91723. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91724. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91725. */
  91726. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91727. /**
  91728. * Gets the current auto clear configuration for one rendering group of the rendering
  91729. * manager.
  91730. * @param index the rendering group index to get the information for
  91731. * @returns The auto clear setup for the requested rendering group
  91732. */
  91733. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91734. private _blockMaterialDirtyMechanism;
  91735. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  91736. blockMaterialDirtyMechanism: boolean;
  91737. /**
  91738. * Will flag all materials as dirty to trigger new shader compilation
  91739. * @param flag defines the flag used to specify which material part must be marked as dirty
  91740. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  91741. */
  91742. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  91743. /** @hidden */
  91744. _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;
  91745. /** @hidden */
  91746. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91747. }
  91748. }
  91749. declare module BABYLON {
  91750. /**
  91751. * Set of assets to keep when moving a scene into an asset container.
  91752. */
  91753. export class KeepAssets extends AbstractScene {
  91754. }
  91755. /**
  91756. * Container with a set of assets that can be added or removed from a scene.
  91757. */
  91758. export class AssetContainer extends AbstractScene {
  91759. /**
  91760. * The scene the AssetContainer belongs to.
  91761. */
  91762. scene: Scene;
  91763. /**
  91764. * Instantiates an AssetContainer.
  91765. * @param scene The scene the AssetContainer belongs to.
  91766. */
  91767. constructor(scene: Scene);
  91768. /**
  91769. * Adds all the assets from the container to the scene.
  91770. */
  91771. addAllToScene(): void;
  91772. /**
  91773. * Removes all the assets in the container from the scene
  91774. */
  91775. removeAllFromScene(): void;
  91776. /**
  91777. * Disposes all the assets in the container
  91778. */
  91779. dispose(): void;
  91780. private _moveAssets;
  91781. /**
  91782. * Removes all the assets contained in the scene and adds them to the container.
  91783. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  91784. */
  91785. moveAllFromScene(keepAssets?: KeepAssets): void;
  91786. /**
  91787. * 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.
  91788. * @returns the root mesh
  91789. */
  91790. createRootMesh(): Mesh;
  91791. }
  91792. }
  91793. declare module BABYLON {
  91794. /**
  91795. * Defines how the parser contract is defined.
  91796. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  91797. */
  91798. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  91799. /**
  91800. * Defines how the individual parser contract is defined.
  91801. * These parser can parse an individual asset
  91802. */
  91803. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  91804. /**
  91805. * Base class of the scene acting as a container for the different elements composing a scene.
  91806. * This class is dynamically extended by the different components of the scene increasing
  91807. * flexibility and reducing coupling
  91808. */
  91809. export abstract class AbstractScene {
  91810. /**
  91811. * Stores the list of available parsers in the application.
  91812. */
  91813. private static _BabylonFileParsers;
  91814. /**
  91815. * Stores the list of available individual parsers in the application.
  91816. */
  91817. private static _IndividualBabylonFileParsers;
  91818. /**
  91819. * Adds a parser in the list of available ones
  91820. * @param name Defines the name of the parser
  91821. * @param parser Defines the parser to add
  91822. */
  91823. static AddParser(name: string, parser: BabylonFileParser): void;
  91824. /**
  91825. * Gets a general parser from the list of avaialble ones
  91826. * @param name Defines the name of the parser
  91827. * @returns the requested parser or null
  91828. */
  91829. static GetParser(name: string): Nullable<BabylonFileParser>;
  91830. /**
  91831. * Adds n individual parser in the list of available ones
  91832. * @param name Defines the name of the parser
  91833. * @param parser Defines the parser to add
  91834. */
  91835. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  91836. /**
  91837. * Gets an individual parser from the list of avaialble ones
  91838. * @param name Defines the name of the parser
  91839. * @returns the requested parser or null
  91840. */
  91841. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  91842. /**
  91843. * Parser json data and populate both a scene and its associated container object
  91844. * @param jsonData Defines the data to parse
  91845. * @param scene Defines the scene to parse the data for
  91846. * @param container Defines the container attached to the parsing sequence
  91847. * @param rootUrl Defines the root url of the data
  91848. */
  91849. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  91850. /**
  91851. * Gets the list of root nodes (ie. nodes with no parent)
  91852. */
  91853. rootNodes: Node[];
  91854. /** All of the cameras added to this scene
  91855. * @see http://doc.babylonjs.com/babylon101/cameras
  91856. */
  91857. cameras: Camera[];
  91858. /**
  91859. * All of the lights added to this scene
  91860. * @see http://doc.babylonjs.com/babylon101/lights
  91861. */
  91862. lights: Light[];
  91863. /**
  91864. * All of the (abstract) meshes added to this scene
  91865. */
  91866. meshes: AbstractMesh[];
  91867. /**
  91868. * The list of skeletons added to the scene
  91869. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91870. */
  91871. skeletons: Skeleton[];
  91872. /**
  91873. * All of the particle systems added to this scene
  91874. * @see http://doc.babylonjs.com/babylon101/particles
  91875. */
  91876. particleSystems: IParticleSystem[];
  91877. /**
  91878. * Gets a list of Animations associated with the scene
  91879. */
  91880. animations: Animation[];
  91881. /**
  91882. * All of the animation groups added to this scene
  91883. * @see http://doc.babylonjs.com/how_to/group
  91884. */
  91885. animationGroups: AnimationGroup[];
  91886. /**
  91887. * All of the multi-materials added to this scene
  91888. * @see http://doc.babylonjs.com/how_to/multi_materials
  91889. */
  91890. multiMaterials: MultiMaterial[];
  91891. /**
  91892. * All of the materials added to this scene
  91893. * In the context of a Scene, it is not supposed to be modified manually.
  91894. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  91895. * Note also that the order of the Material wihin the array is not significant and might change.
  91896. * @see http://doc.babylonjs.com/babylon101/materials
  91897. */
  91898. materials: Material[];
  91899. /**
  91900. * The list of morph target managers added to the scene
  91901. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  91902. */
  91903. morphTargetManagers: MorphTargetManager[];
  91904. /**
  91905. * The list of geometries used in the scene.
  91906. */
  91907. geometries: Geometry[];
  91908. /**
  91909. * All of the tranform nodes added to this scene
  91910. * In the context of a Scene, it is not supposed to be modified manually.
  91911. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  91912. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  91913. * @see http://doc.babylonjs.com/how_to/transformnode
  91914. */
  91915. transformNodes: TransformNode[];
  91916. /**
  91917. * ActionManagers available on the scene.
  91918. */
  91919. actionManagers: AbstractActionManager[];
  91920. /**
  91921. * Textures to keep.
  91922. */
  91923. textures: BaseTexture[];
  91924. }
  91925. }
  91926. declare module BABYLON {
  91927. /**
  91928. * Defines a sound that can be played in the application.
  91929. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  91930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91931. */
  91932. export class Sound {
  91933. /**
  91934. * The name of the sound in the scene.
  91935. */
  91936. name: string;
  91937. /**
  91938. * Does the sound autoplay once loaded.
  91939. */
  91940. autoplay: boolean;
  91941. /**
  91942. * Does the sound loop after it finishes playing once.
  91943. */
  91944. loop: boolean;
  91945. /**
  91946. * Does the sound use a custom attenuation curve to simulate the falloff
  91947. * happening when the source gets further away from the camera.
  91948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91949. */
  91950. useCustomAttenuation: boolean;
  91951. /**
  91952. * The sound track id this sound belongs to.
  91953. */
  91954. soundTrackId: number;
  91955. /**
  91956. * Is this sound currently played.
  91957. */
  91958. isPlaying: boolean;
  91959. /**
  91960. * Is this sound currently paused.
  91961. */
  91962. isPaused: boolean;
  91963. /**
  91964. * Does this sound enables spatial sound.
  91965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91966. */
  91967. spatialSound: boolean;
  91968. /**
  91969. * Define the reference distance the sound should be heard perfectly.
  91970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91971. */
  91972. refDistance: number;
  91973. /**
  91974. * Define the roll off factor of spatial sounds.
  91975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91976. */
  91977. rolloffFactor: number;
  91978. /**
  91979. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91981. */
  91982. maxDistance: number;
  91983. /**
  91984. * Define the distance attenuation model the sound will follow.
  91985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91986. */
  91987. distanceModel: string;
  91988. /**
  91989. * @hidden
  91990. * Back Compat
  91991. **/
  91992. onended: () => any;
  91993. /**
  91994. * Observable event when the current playing sound finishes.
  91995. */
  91996. onEndedObservable: Observable<Sound>;
  91997. private _panningModel;
  91998. private _playbackRate;
  91999. private _streaming;
  92000. private _startTime;
  92001. private _startOffset;
  92002. private _position;
  92003. /** @hidden */
  92004. _positionInEmitterSpace: boolean;
  92005. private _localDirection;
  92006. private _volume;
  92007. private _isReadyToPlay;
  92008. private _isDirectional;
  92009. private _readyToPlayCallback;
  92010. private _audioBuffer;
  92011. private _soundSource;
  92012. private _streamingSource;
  92013. private _soundPanner;
  92014. private _soundGain;
  92015. private _inputAudioNode;
  92016. private _outputAudioNode;
  92017. private _coneInnerAngle;
  92018. private _coneOuterAngle;
  92019. private _coneOuterGain;
  92020. private _scene;
  92021. private _connectedTransformNode;
  92022. private _customAttenuationFunction;
  92023. private _registerFunc;
  92024. private _isOutputConnected;
  92025. private _htmlAudioElement;
  92026. private _urlType;
  92027. /** @hidden */
  92028. static _SceneComponentInitialization: (scene: Scene) => void;
  92029. /**
  92030. * Create a sound and attach it to a scene
  92031. * @param name Name of your sound
  92032. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  92033. * @param scene defines the scene the sound belongs to
  92034. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  92035. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  92036. */
  92037. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  92038. /**
  92039. * Release the sound and its associated resources
  92040. */
  92041. dispose(): void;
  92042. /**
  92043. * Gets if the sounds is ready to be played or not.
  92044. * @returns true if ready, otherwise false
  92045. */
  92046. isReady(): boolean;
  92047. private _soundLoaded;
  92048. /**
  92049. * Sets the data of the sound from an audiobuffer
  92050. * @param audioBuffer The audioBuffer containing the data
  92051. */
  92052. setAudioBuffer(audioBuffer: AudioBuffer): void;
  92053. /**
  92054. * Updates the current sounds options such as maxdistance, loop...
  92055. * @param options A JSON object containing values named as the object properties
  92056. */
  92057. updateOptions(options: any): void;
  92058. private _createSpatialParameters;
  92059. private _updateSpatialParameters;
  92060. /**
  92061. * Switch the panning model to HRTF:
  92062. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92064. */
  92065. switchPanningModelToHRTF(): void;
  92066. /**
  92067. * Switch the panning model to Equal Power:
  92068. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92070. */
  92071. switchPanningModelToEqualPower(): void;
  92072. private _switchPanningModel;
  92073. /**
  92074. * Connect this sound to a sound track audio node like gain...
  92075. * @param soundTrackAudioNode the sound track audio node to connect to
  92076. */
  92077. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92078. /**
  92079. * Transform this sound into a directional source
  92080. * @param coneInnerAngle Size of the inner cone in degree
  92081. * @param coneOuterAngle Size of the outer cone in degree
  92082. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92083. */
  92084. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92085. /**
  92086. * Gets or sets the inner angle for the directional cone.
  92087. */
  92088. /**
  92089. * Gets or sets the inner angle for the directional cone.
  92090. */
  92091. directionalConeInnerAngle: number;
  92092. /**
  92093. * Gets or sets the outer angle for the directional cone.
  92094. */
  92095. /**
  92096. * Gets or sets the outer angle for the directional cone.
  92097. */
  92098. directionalConeOuterAngle: number;
  92099. /**
  92100. * Sets the position of the emitter if spatial sound is enabled
  92101. * @param newPosition Defines the new posisiton
  92102. */
  92103. setPosition(newPosition: Vector3): void;
  92104. /**
  92105. * Sets the local direction of the emitter if spatial sound is enabled
  92106. * @param newLocalDirection Defines the new local direction
  92107. */
  92108. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92109. private _updateDirection;
  92110. /** @hidden */
  92111. updateDistanceFromListener(): void;
  92112. /**
  92113. * Sets a new custom attenuation function for the sound.
  92114. * @param callback Defines the function used for the attenuation
  92115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92116. */
  92117. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92118. /**
  92119. * Play the sound
  92120. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92121. * @param offset (optional) Start the sound setting it at a specific time
  92122. */
  92123. play(time?: number, offset?: number): void;
  92124. private _onended;
  92125. /**
  92126. * Stop the sound
  92127. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92128. */
  92129. stop(time?: number): void;
  92130. /**
  92131. * Put the sound in pause
  92132. */
  92133. pause(): void;
  92134. /**
  92135. * Sets a dedicated volume for this sounds
  92136. * @param newVolume Define the new volume of the sound
  92137. * @param time Define in how long the sound should be at this value
  92138. */
  92139. setVolume(newVolume: number, time?: number): void;
  92140. /**
  92141. * Set the sound play back rate
  92142. * @param newPlaybackRate Define the playback rate the sound should be played at
  92143. */
  92144. setPlaybackRate(newPlaybackRate: number): void;
  92145. /**
  92146. * Gets the volume of the sound.
  92147. * @returns the volume of the sound
  92148. */
  92149. getVolume(): number;
  92150. /**
  92151. * Attach the sound to a dedicated mesh
  92152. * @param transformNode The transform node to connect the sound with
  92153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92154. */
  92155. attachToMesh(transformNode: TransformNode): void;
  92156. /**
  92157. * Detach the sound from the previously attached mesh
  92158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92159. */
  92160. detachFromMesh(): void;
  92161. private _onRegisterAfterWorldMatrixUpdate;
  92162. /**
  92163. * Clone the current sound in the scene.
  92164. * @returns the new sound clone
  92165. */
  92166. clone(): Nullable<Sound>;
  92167. /**
  92168. * Gets the current underlying audio buffer containing the data
  92169. * @returns the audio buffer
  92170. */
  92171. getAudioBuffer(): Nullable<AudioBuffer>;
  92172. /**
  92173. * Serializes the Sound in a JSON representation
  92174. * @returns the JSON representation of the sound
  92175. */
  92176. serialize(): any;
  92177. /**
  92178. * Parse a JSON representation of a sound to innstantiate in a given scene
  92179. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92180. * @param scene Define the scene the new parsed sound should be created in
  92181. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92182. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92183. * @returns the newly parsed sound
  92184. */
  92185. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92186. }
  92187. }
  92188. declare module BABYLON {
  92189. /**
  92190. * This defines an action helpful to play a defined sound on a triggered action.
  92191. */
  92192. export class PlaySoundAction extends Action {
  92193. private _sound;
  92194. /**
  92195. * Instantiate the action
  92196. * @param triggerOptions defines the trigger options
  92197. * @param sound defines the sound to play
  92198. * @param condition defines the trigger related conditions
  92199. */
  92200. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92201. /** @hidden */
  92202. _prepare(): void;
  92203. /**
  92204. * Execute the action and play the sound.
  92205. */
  92206. execute(): void;
  92207. /**
  92208. * Serializes the actions and its related information.
  92209. * @param parent defines the object to serialize in
  92210. * @returns the serialized object
  92211. */
  92212. serialize(parent: any): any;
  92213. }
  92214. /**
  92215. * This defines an action helpful to stop a defined sound on a triggered action.
  92216. */
  92217. export class StopSoundAction extends Action {
  92218. private _sound;
  92219. /**
  92220. * Instantiate the action
  92221. * @param triggerOptions defines the trigger options
  92222. * @param sound defines the sound to stop
  92223. * @param condition defines the trigger related conditions
  92224. */
  92225. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92226. /** @hidden */
  92227. _prepare(): void;
  92228. /**
  92229. * Execute the action and stop the sound.
  92230. */
  92231. execute(): void;
  92232. /**
  92233. * Serializes the actions and its related information.
  92234. * @param parent defines the object to serialize in
  92235. * @returns the serialized object
  92236. */
  92237. serialize(parent: any): any;
  92238. }
  92239. }
  92240. declare module BABYLON {
  92241. /**
  92242. * This defines an action responsible to change the value of a property
  92243. * by interpolating between its current value and the newly set one once triggered.
  92244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92245. */
  92246. export class InterpolateValueAction extends Action {
  92247. /**
  92248. * Defines the path of the property where the value should be interpolated
  92249. */
  92250. propertyPath: string;
  92251. /**
  92252. * Defines the target value at the end of the interpolation.
  92253. */
  92254. value: any;
  92255. /**
  92256. * Defines the time it will take for the property to interpolate to the value.
  92257. */
  92258. duration: number;
  92259. /**
  92260. * Defines if the other scene animations should be stopped when the action has been triggered
  92261. */
  92262. stopOtherAnimations?: boolean;
  92263. /**
  92264. * Defines a callback raised once the interpolation animation has been done.
  92265. */
  92266. onInterpolationDone?: () => void;
  92267. /**
  92268. * Observable triggered once the interpolation animation has been done.
  92269. */
  92270. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92271. private _target;
  92272. private _effectiveTarget;
  92273. private _property;
  92274. /**
  92275. * Instantiate the action
  92276. * @param triggerOptions defines the trigger options
  92277. * @param target defines the object containing the value to interpolate
  92278. * @param propertyPath defines the path to the property in the target object
  92279. * @param value defines the target value at the end of the interpolation
  92280. * @param duration deines the time it will take for the property to interpolate to the value.
  92281. * @param condition defines the trigger related conditions
  92282. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92283. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92284. */
  92285. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92286. /** @hidden */
  92287. _prepare(): void;
  92288. /**
  92289. * Execute the action starts the value interpolation.
  92290. */
  92291. execute(): void;
  92292. /**
  92293. * Serializes the actions and its related information.
  92294. * @param parent defines the object to serialize in
  92295. * @returns the serialized object
  92296. */
  92297. serialize(parent: any): any;
  92298. }
  92299. }
  92300. declare module BABYLON {
  92301. /**
  92302. * Options allowed during the creation of a sound track.
  92303. */
  92304. export interface ISoundTrackOptions {
  92305. /**
  92306. * The volume the sound track should take during creation
  92307. */
  92308. volume?: number;
  92309. /**
  92310. * Define if the sound track is the main sound track of the scene
  92311. */
  92312. mainTrack?: boolean;
  92313. }
  92314. /**
  92315. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92316. * It will be also used in a future release to apply effects on a specific track.
  92317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92318. */
  92319. export class SoundTrack {
  92320. /**
  92321. * The unique identifier of the sound track in the scene.
  92322. */
  92323. id: number;
  92324. /**
  92325. * The list of sounds included in the sound track.
  92326. */
  92327. soundCollection: Array<Sound>;
  92328. private _outputAudioNode;
  92329. private _scene;
  92330. private _isMainTrack;
  92331. private _connectedAnalyser;
  92332. private _options;
  92333. private _isInitialized;
  92334. /**
  92335. * Creates a new sound track.
  92336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92337. * @param scene Define the scene the sound track belongs to
  92338. * @param options
  92339. */
  92340. constructor(scene: Scene, options?: ISoundTrackOptions);
  92341. private _initializeSoundTrackAudioGraph;
  92342. /**
  92343. * Release the sound track and its associated resources
  92344. */
  92345. dispose(): void;
  92346. /**
  92347. * Adds a sound to this sound track
  92348. * @param sound define the cound to add
  92349. * @ignoreNaming
  92350. */
  92351. AddSound(sound: Sound): void;
  92352. /**
  92353. * Removes a sound to this sound track
  92354. * @param sound define the cound to remove
  92355. * @ignoreNaming
  92356. */
  92357. RemoveSound(sound: Sound): void;
  92358. /**
  92359. * Set a global volume for the full sound track.
  92360. * @param newVolume Define the new volume of the sound track
  92361. */
  92362. setVolume(newVolume: number): void;
  92363. /**
  92364. * Switch the panning model to HRTF:
  92365. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92367. */
  92368. switchPanningModelToHRTF(): void;
  92369. /**
  92370. * Switch the panning model to Equal Power:
  92371. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92373. */
  92374. switchPanningModelToEqualPower(): void;
  92375. /**
  92376. * Connect the sound track to an audio analyser allowing some amazing
  92377. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92378. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92379. * @param analyser The analyser to connect to the engine
  92380. */
  92381. connectToAnalyser(analyser: Analyser): void;
  92382. }
  92383. }
  92384. declare module BABYLON {
  92385. interface AbstractScene {
  92386. /**
  92387. * The list of sounds used in the scene.
  92388. */
  92389. sounds: Nullable<Array<Sound>>;
  92390. }
  92391. interface Scene {
  92392. /**
  92393. * @hidden
  92394. * Backing field
  92395. */
  92396. _mainSoundTrack: SoundTrack;
  92397. /**
  92398. * The main sound track played by the scene.
  92399. * It cotains your primary collection of sounds.
  92400. */
  92401. mainSoundTrack: SoundTrack;
  92402. /**
  92403. * The list of sound tracks added to the scene
  92404. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92405. */
  92406. soundTracks: Nullable<Array<SoundTrack>>;
  92407. /**
  92408. * Gets a sound using a given name
  92409. * @param name defines the name to search for
  92410. * @return the found sound or null if not found at all.
  92411. */
  92412. getSoundByName(name: string): Nullable<Sound>;
  92413. /**
  92414. * Gets or sets if audio support is enabled
  92415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92416. */
  92417. audioEnabled: boolean;
  92418. /**
  92419. * Gets or sets if audio will be output to headphones
  92420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92421. */
  92422. headphone: boolean;
  92423. }
  92424. /**
  92425. * Defines the sound scene component responsible to manage any sounds
  92426. * in a given scene.
  92427. */
  92428. export class AudioSceneComponent implements ISceneSerializableComponent {
  92429. /**
  92430. * The component name helpfull to identify the component in the list of scene components.
  92431. */
  92432. readonly name: string;
  92433. /**
  92434. * The scene the component belongs to.
  92435. */
  92436. scene: Scene;
  92437. private _audioEnabled;
  92438. /**
  92439. * Gets whether audio is enabled or not.
  92440. * Please use related enable/disable method to switch state.
  92441. */
  92442. readonly audioEnabled: boolean;
  92443. private _headphone;
  92444. /**
  92445. * Gets whether audio is outputing to headphone or not.
  92446. * Please use the according Switch methods to change output.
  92447. */
  92448. readonly headphone: boolean;
  92449. /**
  92450. * Creates a new instance of the component for the given scene
  92451. * @param scene Defines the scene to register the component in
  92452. */
  92453. constructor(scene: Scene);
  92454. /**
  92455. * Registers the component in a given scene
  92456. */
  92457. register(): void;
  92458. /**
  92459. * Rebuilds the elements related to this component in case of
  92460. * context lost for instance.
  92461. */
  92462. rebuild(): void;
  92463. /**
  92464. * Serializes the component data to the specified json object
  92465. * @param serializationObject The object to serialize to
  92466. */
  92467. serialize(serializationObject: any): void;
  92468. /**
  92469. * Adds all the element from the container to the scene
  92470. * @param container the container holding the elements
  92471. */
  92472. addFromContainer(container: AbstractScene): void;
  92473. /**
  92474. * Removes all the elements in the container from the scene
  92475. * @param container contains the elements to remove
  92476. */
  92477. removeFromContainer(container: AbstractScene): void;
  92478. /**
  92479. * Disposes the component and the associated ressources.
  92480. */
  92481. dispose(): void;
  92482. /**
  92483. * Disables audio in the associated scene.
  92484. */
  92485. disableAudio(): void;
  92486. /**
  92487. * Enables audio in the associated scene.
  92488. */
  92489. enableAudio(): void;
  92490. /**
  92491. * Switch audio to headphone output.
  92492. */
  92493. switchAudioModeForHeadphones(): void;
  92494. /**
  92495. * Switch audio to normal speakers.
  92496. */
  92497. switchAudioModeForNormalSpeakers(): void;
  92498. private _afterRender;
  92499. }
  92500. }
  92501. declare module BABYLON {
  92502. /**
  92503. * Wraps one or more Sound objects and selects one with random weight for playback.
  92504. */
  92505. export class WeightedSound {
  92506. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92507. loop: boolean;
  92508. private _coneInnerAngle;
  92509. private _coneOuterAngle;
  92510. private _volume;
  92511. /** A Sound is currently playing. */
  92512. isPlaying: boolean;
  92513. /** A Sound is currently paused. */
  92514. isPaused: boolean;
  92515. private _sounds;
  92516. private _weights;
  92517. private _currentIndex?;
  92518. /**
  92519. * Creates a new WeightedSound from the list of sounds given.
  92520. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92521. * @param sounds Array of Sounds that will be selected from.
  92522. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92523. */
  92524. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92525. /**
  92526. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92527. */
  92528. /**
  92529. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92530. */
  92531. directionalConeInnerAngle: number;
  92532. /**
  92533. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92534. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92535. */
  92536. /**
  92537. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92538. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92539. */
  92540. directionalConeOuterAngle: number;
  92541. /**
  92542. * Playback volume.
  92543. */
  92544. /**
  92545. * Playback volume.
  92546. */
  92547. volume: number;
  92548. private _onended;
  92549. /**
  92550. * Suspend playback
  92551. */
  92552. pause(): void;
  92553. /**
  92554. * Stop playback
  92555. */
  92556. stop(): void;
  92557. /**
  92558. * Start playback.
  92559. * @param startOffset Position the clip head at a specific time in seconds.
  92560. */
  92561. play(startOffset?: number): void;
  92562. }
  92563. }
  92564. declare module BABYLON {
  92565. /**
  92566. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92567. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92568. */
  92569. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92570. /**
  92571. * Gets the name of the behavior.
  92572. */
  92573. readonly name: string;
  92574. /**
  92575. * The easing function used by animations
  92576. */
  92577. static EasingFunction: BackEase;
  92578. /**
  92579. * The easing mode used by animations
  92580. */
  92581. static EasingMode: number;
  92582. /**
  92583. * The duration of the animation, in milliseconds
  92584. */
  92585. transitionDuration: number;
  92586. /**
  92587. * Length of the distance animated by the transition when lower radius is reached
  92588. */
  92589. lowerRadiusTransitionRange: number;
  92590. /**
  92591. * Length of the distance animated by the transition when upper radius is reached
  92592. */
  92593. upperRadiusTransitionRange: number;
  92594. private _autoTransitionRange;
  92595. /**
  92596. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92597. */
  92598. /**
  92599. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92600. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92601. */
  92602. autoTransitionRange: boolean;
  92603. private _attachedCamera;
  92604. private _onAfterCheckInputsObserver;
  92605. private _onMeshTargetChangedObserver;
  92606. /**
  92607. * Initializes the behavior.
  92608. */
  92609. init(): void;
  92610. /**
  92611. * Attaches the behavior to its arc rotate camera.
  92612. * @param camera Defines the camera to attach the behavior to
  92613. */
  92614. attach(camera: ArcRotateCamera): void;
  92615. /**
  92616. * Detaches the behavior from its current arc rotate camera.
  92617. */
  92618. detach(): void;
  92619. private _radiusIsAnimating;
  92620. private _radiusBounceTransition;
  92621. private _animatables;
  92622. private _cachedWheelPrecision;
  92623. /**
  92624. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92625. * @param radiusLimit The limit to check against.
  92626. * @return Bool to indicate if at limit.
  92627. */
  92628. private _isRadiusAtLimit;
  92629. /**
  92630. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92631. * @param radiusDelta The delta by which to animate to. Can be negative.
  92632. */
  92633. private _applyBoundRadiusAnimation;
  92634. /**
  92635. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92636. */
  92637. protected _clearAnimationLocks(): void;
  92638. /**
  92639. * Stops and removes all animations that have been applied to the camera
  92640. */
  92641. stopAllAnimations(): void;
  92642. }
  92643. }
  92644. declare module BABYLON {
  92645. /**
  92646. * 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.
  92647. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92648. */
  92649. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  92650. /**
  92651. * Gets the name of the behavior.
  92652. */
  92653. readonly name: string;
  92654. private _mode;
  92655. private _radiusScale;
  92656. private _positionScale;
  92657. private _defaultElevation;
  92658. private _elevationReturnTime;
  92659. private _elevationReturnWaitTime;
  92660. private _zoomStopsAnimation;
  92661. private _framingTime;
  92662. /**
  92663. * The easing function used by animations
  92664. */
  92665. static EasingFunction: ExponentialEase;
  92666. /**
  92667. * The easing mode used by animations
  92668. */
  92669. static EasingMode: number;
  92670. /**
  92671. * Sets the current mode used by the behavior
  92672. */
  92673. /**
  92674. * Gets current mode used by the behavior.
  92675. */
  92676. mode: number;
  92677. /**
  92678. * Sets the scale applied to the radius (1 by default)
  92679. */
  92680. /**
  92681. * Gets the scale applied to the radius
  92682. */
  92683. radiusScale: number;
  92684. /**
  92685. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92686. */
  92687. /**
  92688. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92689. */
  92690. positionScale: number;
  92691. /**
  92692. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92693. * behaviour is triggered, in radians.
  92694. */
  92695. /**
  92696. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92697. * behaviour is triggered, in radians.
  92698. */
  92699. defaultElevation: number;
  92700. /**
  92701. * Sets the time (in milliseconds) taken to return to the default beta position.
  92702. * Negative value indicates camera should not return to default.
  92703. */
  92704. /**
  92705. * Gets the time (in milliseconds) taken to return to the default beta position.
  92706. * Negative value indicates camera should not return to default.
  92707. */
  92708. elevationReturnTime: number;
  92709. /**
  92710. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92711. */
  92712. /**
  92713. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92714. */
  92715. elevationReturnWaitTime: number;
  92716. /**
  92717. * Sets the flag that indicates if user zooming should stop animation.
  92718. */
  92719. /**
  92720. * Gets the flag that indicates if user zooming should stop animation.
  92721. */
  92722. zoomStopsAnimation: boolean;
  92723. /**
  92724. * Sets the transition time when framing the mesh, in milliseconds
  92725. */
  92726. /**
  92727. * Gets the transition time when framing the mesh, in milliseconds
  92728. */
  92729. framingTime: number;
  92730. /**
  92731. * Define if the behavior should automatically change the configured
  92732. * camera limits and sensibilities.
  92733. */
  92734. autoCorrectCameraLimitsAndSensibility: boolean;
  92735. private _onPrePointerObservableObserver;
  92736. private _onAfterCheckInputsObserver;
  92737. private _onMeshTargetChangedObserver;
  92738. private _attachedCamera;
  92739. private _isPointerDown;
  92740. private _lastInteractionTime;
  92741. /**
  92742. * Initializes the behavior.
  92743. */
  92744. init(): void;
  92745. /**
  92746. * Attaches the behavior to its arc rotate camera.
  92747. * @param camera Defines the camera to attach the behavior to
  92748. */
  92749. attach(camera: ArcRotateCamera): void;
  92750. /**
  92751. * Detaches the behavior from its current arc rotate camera.
  92752. */
  92753. detach(): void;
  92754. private _animatables;
  92755. private _betaIsAnimating;
  92756. private _betaTransition;
  92757. private _radiusTransition;
  92758. private _vectorTransition;
  92759. /**
  92760. * Targets the given mesh and updates zoom level accordingly.
  92761. * @param mesh The mesh to target.
  92762. * @param radius Optional. If a cached radius position already exists, overrides default.
  92763. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92764. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92765. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92766. */
  92767. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92768. /**
  92769. * Targets the given mesh with its children and updates zoom level accordingly.
  92770. * @param mesh The mesh to target.
  92771. * @param radius Optional. If a cached radius position already exists, overrides default.
  92772. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92773. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92774. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92775. */
  92776. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92777. /**
  92778. * Targets the given meshes with their children and updates zoom level accordingly.
  92779. * @param meshes The mesh to target.
  92780. * @param radius Optional. If a cached radius position already exists, overrides default.
  92781. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92782. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92783. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92784. */
  92785. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92786. /**
  92787. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  92788. * @param minimumWorld Determines the smaller position of the bounding box extend
  92789. * @param maximumWorld Determines the bigger position of the bounding box extend
  92790. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92791. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92792. */
  92793. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92794. /**
  92795. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  92796. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  92797. * frustum width.
  92798. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  92799. * to fully enclose the mesh in the viewing frustum.
  92800. */
  92801. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  92802. /**
  92803. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  92804. * is automatically returned to its default position (expected to be above ground plane).
  92805. */
  92806. private _maintainCameraAboveGround;
  92807. /**
  92808. * Returns the frustum slope based on the canvas ratio and camera FOV
  92809. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  92810. */
  92811. private _getFrustumSlope;
  92812. /**
  92813. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  92814. */
  92815. private _clearAnimationLocks;
  92816. /**
  92817. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92818. */
  92819. private _applyUserInteraction;
  92820. /**
  92821. * Stops and removes all animations that have been applied to the camera
  92822. */
  92823. stopAllAnimations(): void;
  92824. /**
  92825. * Gets a value indicating if the user is moving the camera
  92826. */
  92827. readonly isUserIsMoving: boolean;
  92828. /**
  92829. * The camera can move all the way towards the mesh.
  92830. */
  92831. static IgnoreBoundsSizeMode: number;
  92832. /**
  92833. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  92834. */
  92835. static FitFrustumSidesMode: number;
  92836. }
  92837. }
  92838. declare module BABYLON {
  92839. /**
  92840. * Base class for Camera Pointer Inputs.
  92841. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  92842. * for example usage.
  92843. */
  92844. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  92845. /**
  92846. * Defines the camera the input is attached to.
  92847. */
  92848. abstract camera: Camera;
  92849. /**
  92850. * Whether keyboard modifier keys are pressed at time of last mouse event.
  92851. */
  92852. protected _altKey: boolean;
  92853. protected _ctrlKey: boolean;
  92854. protected _metaKey: boolean;
  92855. protected _shiftKey: boolean;
  92856. /**
  92857. * Which mouse buttons were pressed at time of last mouse event.
  92858. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  92859. */
  92860. protected _buttonsPressed: number;
  92861. /**
  92862. * Defines the buttons associated with the input to handle camera move.
  92863. */
  92864. buttons: number[];
  92865. /**
  92866. * Attach the input controls to a specific dom element to get the input from.
  92867. * @param element Defines the element the controls should be listened from
  92868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92869. */
  92870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92871. /**
  92872. * Detach the current controls from the specified dom element.
  92873. * @param element Defines the element to stop listening the inputs from
  92874. */
  92875. detachControl(element: Nullable<HTMLElement>): void;
  92876. /**
  92877. * Gets the class name of the current input.
  92878. * @returns the class name
  92879. */
  92880. getClassName(): string;
  92881. /**
  92882. * Get the friendly name associated with the input class.
  92883. * @returns the input friendly name
  92884. */
  92885. getSimpleName(): string;
  92886. /**
  92887. * Called on pointer POINTERDOUBLETAP event.
  92888. * Override this method to provide functionality on POINTERDOUBLETAP event.
  92889. */
  92890. protected onDoubleTap(type: string): void;
  92891. /**
  92892. * Called on pointer POINTERMOVE event if only a single touch is active.
  92893. * Override this method to provide functionality.
  92894. */
  92895. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92896. /**
  92897. * Called on pointer POINTERMOVE event if multiple touches are active.
  92898. * Override this method to provide functionality.
  92899. */
  92900. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92901. /**
  92902. * Called on JS contextmenu event.
  92903. * Override this method to provide functionality.
  92904. */
  92905. protected onContextMenu(evt: PointerEvent): void;
  92906. /**
  92907. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92908. * press.
  92909. * Override this method to provide functionality.
  92910. */
  92911. protected onButtonDown(evt: PointerEvent): void;
  92912. /**
  92913. * Called each time a new POINTERUP event occurs. Ie, for each button
  92914. * release.
  92915. * Override this method to provide functionality.
  92916. */
  92917. protected onButtonUp(evt: PointerEvent): void;
  92918. /**
  92919. * Called when window becomes inactive.
  92920. * Override this method to provide functionality.
  92921. */
  92922. protected onLostFocus(): void;
  92923. private _pointerInput;
  92924. private _observer;
  92925. private _onLostFocus;
  92926. private pointA;
  92927. private pointB;
  92928. }
  92929. }
  92930. declare module BABYLON {
  92931. /**
  92932. * Manage the pointers inputs to control an arc rotate camera.
  92933. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92934. */
  92935. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  92936. /**
  92937. * Defines the camera the input is attached to.
  92938. */
  92939. camera: ArcRotateCamera;
  92940. /**
  92941. * Gets the class name of the current input.
  92942. * @returns the class name
  92943. */
  92944. getClassName(): string;
  92945. /**
  92946. * Defines the buttons associated with the input to handle camera move.
  92947. */
  92948. buttons: number[];
  92949. /**
  92950. * Defines the pointer angular sensibility along the X axis or how fast is
  92951. * the camera rotating.
  92952. */
  92953. angularSensibilityX: number;
  92954. /**
  92955. * Defines the pointer angular sensibility along the Y axis or how fast is
  92956. * the camera rotating.
  92957. */
  92958. angularSensibilityY: number;
  92959. /**
  92960. * Defines the pointer pinch precision or how fast is the camera zooming.
  92961. */
  92962. pinchPrecision: number;
  92963. /**
  92964. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92965. * from 0.
  92966. * It defines the percentage of current camera.radius to use as delta when
  92967. * pinch zoom is used.
  92968. */
  92969. pinchDeltaPercentage: number;
  92970. /**
  92971. * Defines the pointer panning sensibility or how fast is the camera moving.
  92972. */
  92973. panningSensibility: number;
  92974. /**
  92975. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92976. */
  92977. multiTouchPanning: boolean;
  92978. /**
  92979. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92980. * zoom (pinch) through multitouch.
  92981. */
  92982. multiTouchPanAndZoom: boolean;
  92983. /**
  92984. * Revers pinch action direction.
  92985. */
  92986. pinchInwards: boolean;
  92987. private _isPanClick;
  92988. private _twoFingerActivityCount;
  92989. private _isPinching;
  92990. /**
  92991. * Called on pointer POINTERMOVE event if only a single touch is active.
  92992. */
  92993. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92994. /**
  92995. * Called on pointer POINTERDOUBLETAP event.
  92996. */
  92997. protected onDoubleTap(type: string): void;
  92998. /**
  92999. * Called on pointer POINTERMOVE event if multiple touches are active.
  93000. */
  93001. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  93002. /**
  93003. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  93004. * press.
  93005. */
  93006. protected onButtonDown(evt: PointerEvent): void;
  93007. /**
  93008. * Called each time a new POINTERUP event occurs. Ie, for each button
  93009. * release.
  93010. */
  93011. protected onButtonUp(evt: PointerEvent): void;
  93012. /**
  93013. * Called when window becomes inactive.
  93014. */
  93015. protected onLostFocus(): void;
  93016. }
  93017. }
  93018. declare module BABYLON {
  93019. /**
  93020. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  93021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93022. */
  93023. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  93024. /**
  93025. * Defines the camera the input is attached to.
  93026. */
  93027. camera: ArcRotateCamera;
  93028. /**
  93029. * Defines the list of key codes associated with the up action (increase alpha)
  93030. */
  93031. keysUp: number[];
  93032. /**
  93033. * Defines the list of key codes associated with the down action (decrease alpha)
  93034. */
  93035. keysDown: number[];
  93036. /**
  93037. * Defines the list of key codes associated with the left action (increase beta)
  93038. */
  93039. keysLeft: number[];
  93040. /**
  93041. * Defines the list of key codes associated with the right action (decrease beta)
  93042. */
  93043. keysRight: number[];
  93044. /**
  93045. * Defines the list of key codes associated with the reset action.
  93046. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  93047. */
  93048. keysReset: number[];
  93049. /**
  93050. * Defines the panning sensibility of the inputs.
  93051. * (How fast is the camera paning)
  93052. */
  93053. panningSensibility: number;
  93054. /**
  93055. * Defines the zooming sensibility of the inputs.
  93056. * (How fast is the camera zooming)
  93057. */
  93058. zoomingSensibility: number;
  93059. /**
  93060. * Defines wether maintaining the alt key down switch the movement mode from
  93061. * orientation to zoom.
  93062. */
  93063. useAltToZoom: boolean;
  93064. /**
  93065. * Rotation speed of the camera
  93066. */
  93067. angularSpeed: number;
  93068. private _keys;
  93069. private _ctrlPressed;
  93070. private _altPressed;
  93071. private _onCanvasBlurObserver;
  93072. private _onKeyboardObserver;
  93073. private _engine;
  93074. private _scene;
  93075. /**
  93076. * Attach the input controls to a specific dom element to get the input from.
  93077. * @param element Defines the element the controls should be listened from
  93078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93079. */
  93080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93081. /**
  93082. * Detach the current controls from the specified dom element.
  93083. * @param element Defines the element to stop listening the inputs from
  93084. */
  93085. detachControl(element: Nullable<HTMLElement>): void;
  93086. /**
  93087. * Update the current camera state depending on the inputs that have been used this frame.
  93088. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93089. */
  93090. checkInputs(): void;
  93091. /**
  93092. * Gets the class name of the current intput.
  93093. * @returns the class name
  93094. */
  93095. getClassName(): string;
  93096. /**
  93097. * Get the friendly name associated with the input class.
  93098. * @returns the input friendly name
  93099. */
  93100. getSimpleName(): string;
  93101. }
  93102. }
  93103. declare module BABYLON {
  93104. /**
  93105. * Manage the mouse wheel inputs to control an arc rotate camera.
  93106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93107. */
  93108. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93109. /**
  93110. * Defines the camera the input is attached to.
  93111. */
  93112. camera: ArcRotateCamera;
  93113. /**
  93114. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93115. */
  93116. wheelPrecision: number;
  93117. /**
  93118. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93119. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93120. */
  93121. wheelDeltaPercentage: number;
  93122. private _wheel;
  93123. private _observer;
  93124. /**
  93125. * Attach the input controls to a specific dom element to get the input from.
  93126. * @param element Defines the element the controls should be listened from
  93127. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93128. */
  93129. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93130. /**
  93131. * Detach the current controls from the specified dom element.
  93132. * @param element Defines the element to stop listening the inputs from
  93133. */
  93134. detachControl(element: Nullable<HTMLElement>): void;
  93135. /**
  93136. * Gets the class name of the current intput.
  93137. * @returns the class name
  93138. */
  93139. getClassName(): string;
  93140. /**
  93141. * Get the friendly name associated with the input class.
  93142. * @returns the input friendly name
  93143. */
  93144. getSimpleName(): string;
  93145. }
  93146. }
  93147. declare module BABYLON {
  93148. /**
  93149. * Default Inputs manager for the ArcRotateCamera.
  93150. * It groups all the default supported inputs for ease of use.
  93151. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93152. */
  93153. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93154. /**
  93155. * Instantiates a new ArcRotateCameraInputsManager.
  93156. * @param camera Defines the camera the inputs belong to
  93157. */
  93158. constructor(camera: ArcRotateCamera);
  93159. /**
  93160. * Add mouse wheel input support to the input manager.
  93161. * @returns the current input manager
  93162. */
  93163. addMouseWheel(): ArcRotateCameraInputsManager;
  93164. /**
  93165. * Add pointers input support to the input manager.
  93166. * @returns the current input manager
  93167. */
  93168. addPointers(): ArcRotateCameraInputsManager;
  93169. /**
  93170. * Add keyboard input support to the input manager.
  93171. * @returns the current input manager
  93172. */
  93173. addKeyboard(): ArcRotateCameraInputsManager;
  93174. }
  93175. }
  93176. declare module BABYLON {
  93177. /**
  93178. * This represents an orbital type of camera.
  93179. *
  93180. * 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.
  93181. * 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.
  93182. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93183. */
  93184. export class ArcRotateCamera extends TargetCamera {
  93185. /**
  93186. * Defines the rotation angle of the camera along the longitudinal axis.
  93187. */
  93188. alpha: number;
  93189. /**
  93190. * Defines the rotation angle of the camera along the latitudinal axis.
  93191. */
  93192. beta: number;
  93193. /**
  93194. * Defines the radius of the camera from it s target point.
  93195. */
  93196. radius: number;
  93197. protected _target: Vector3;
  93198. protected _targetHost: Nullable<AbstractMesh>;
  93199. /**
  93200. * Defines the target point of the camera.
  93201. * The camera looks towards it form the radius distance.
  93202. */
  93203. target: Vector3;
  93204. /**
  93205. * Define the current local position of the camera in the scene
  93206. */
  93207. position: Vector3;
  93208. /**
  93209. * Current inertia value on the longitudinal axis.
  93210. * The bigger this number the longer it will take for the camera to stop.
  93211. */
  93212. inertialAlphaOffset: number;
  93213. /**
  93214. * Current inertia value on the latitudinal axis.
  93215. * The bigger this number the longer it will take for the camera to stop.
  93216. */
  93217. inertialBetaOffset: number;
  93218. /**
  93219. * Current inertia value on the radius axis.
  93220. * The bigger this number the longer it will take for the camera to stop.
  93221. */
  93222. inertialRadiusOffset: number;
  93223. /**
  93224. * Minimum allowed angle on the longitudinal axis.
  93225. * This can help limiting how the Camera is able to move in the scene.
  93226. */
  93227. lowerAlphaLimit: Nullable<number>;
  93228. /**
  93229. * Maximum allowed angle on the longitudinal axis.
  93230. * This can help limiting how the Camera is able to move in the scene.
  93231. */
  93232. upperAlphaLimit: Nullable<number>;
  93233. /**
  93234. * Minimum allowed angle on the latitudinal axis.
  93235. * This can help limiting how the Camera is able to move in the scene.
  93236. */
  93237. lowerBetaLimit: number;
  93238. /**
  93239. * Maximum allowed angle on the latitudinal axis.
  93240. * This can help limiting how the Camera is able to move in the scene.
  93241. */
  93242. upperBetaLimit: number;
  93243. /**
  93244. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93245. * This can help limiting how the Camera is able to move in the scene.
  93246. */
  93247. lowerRadiusLimit: Nullable<number>;
  93248. /**
  93249. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93250. * This can help limiting how the Camera is able to move in the scene.
  93251. */
  93252. upperRadiusLimit: Nullable<number>;
  93253. /**
  93254. * Defines the current inertia value used during panning of the camera along the X axis.
  93255. */
  93256. inertialPanningX: number;
  93257. /**
  93258. * Defines the current inertia value used during panning of the camera along the Y axis.
  93259. */
  93260. inertialPanningY: number;
  93261. /**
  93262. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93263. * Basically if your fingers moves away from more than this distance you will be considered
  93264. * in pinch mode.
  93265. */
  93266. pinchToPanMaxDistance: number;
  93267. /**
  93268. * Defines the maximum distance the camera can pan.
  93269. * This could help keeping the cammera always in your scene.
  93270. */
  93271. panningDistanceLimit: Nullable<number>;
  93272. /**
  93273. * Defines the target of the camera before paning.
  93274. */
  93275. panningOriginTarget: Vector3;
  93276. /**
  93277. * Defines the value of the inertia used during panning.
  93278. * 0 would mean stop inertia and one would mean no decelleration at all.
  93279. */
  93280. panningInertia: number;
  93281. /**
  93282. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93283. */
  93284. angularSensibilityX: number;
  93285. /**
  93286. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93287. */
  93288. angularSensibilityY: number;
  93289. /**
  93290. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93291. */
  93292. pinchPrecision: number;
  93293. /**
  93294. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93295. * It will be used instead of pinchDeltaPrecision if different from 0.
  93296. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93297. */
  93298. pinchDeltaPercentage: number;
  93299. /**
  93300. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93301. */
  93302. panningSensibility: number;
  93303. /**
  93304. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93305. */
  93306. keysUp: number[];
  93307. /**
  93308. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93309. */
  93310. keysDown: number[];
  93311. /**
  93312. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93313. */
  93314. keysLeft: number[];
  93315. /**
  93316. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93317. */
  93318. keysRight: number[];
  93319. /**
  93320. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93321. */
  93322. wheelPrecision: number;
  93323. /**
  93324. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93325. * It will be used instead of pinchDeltaPrecision if different from 0.
  93326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93327. */
  93328. wheelDeltaPercentage: number;
  93329. /**
  93330. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93331. */
  93332. zoomOnFactor: number;
  93333. /**
  93334. * Defines a screen offset for the camera position.
  93335. */
  93336. targetScreenOffset: Vector2;
  93337. /**
  93338. * Allows the camera to be completely reversed.
  93339. * If false the camera can not arrive upside down.
  93340. */
  93341. allowUpsideDown: boolean;
  93342. /**
  93343. * Define if double tap/click is used to restore the previously saved state of the camera.
  93344. */
  93345. useInputToRestoreState: boolean;
  93346. /** @hidden */
  93347. _viewMatrix: Matrix;
  93348. /** @hidden */
  93349. _useCtrlForPanning: boolean;
  93350. /** @hidden */
  93351. _panningMouseButton: number;
  93352. /**
  93353. * Defines the input associated to the camera.
  93354. */
  93355. inputs: ArcRotateCameraInputsManager;
  93356. /** @hidden */
  93357. _reset: () => void;
  93358. /**
  93359. * Defines the allowed panning axis.
  93360. */
  93361. panningAxis: Vector3;
  93362. protected _localDirection: Vector3;
  93363. protected _transformedDirection: Vector3;
  93364. private _bouncingBehavior;
  93365. /**
  93366. * Gets the bouncing behavior of the camera if it has been enabled.
  93367. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93368. */
  93369. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93370. /**
  93371. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93373. */
  93374. useBouncingBehavior: boolean;
  93375. private _framingBehavior;
  93376. /**
  93377. * Gets the framing behavior of the camera if it has been enabled.
  93378. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93379. */
  93380. readonly framingBehavior: Nullable<FramingBehavior>;
  93381. /**
  93382. * Defines if the framing behavior of the camera is enabled on the camera.
  93383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93384. */
  93385. useFramingBehavior: boolean;
  93386. private _autoRotationBehavior;
  93387. /**
  93388. * Gets the auto rotation behavior of the camera if it has been enabled.
  93389. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93390. */
  93391. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93392. /**
  93393. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93394. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93395. */
  93396. useAutoRotationBehavior: boolean;
  93397. /**
  93398. * Observable triggered when the mesh target has been changed on the camera.
  93399. */
  93400. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93401. /**
  93402. * Event raised when the camera is colliding with a mesh.
  93403. */
  93404. onCollide: (collidedMesh: AbstractMesh) => void;
  93405. /**
  93406. * Defines whether the camera should check collision with the objects oh the scene.
  93407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93408. */
  93409. checkCollisions: boolean;
  93410. /**
  93411. * Defines the collision radius of the camera.
  93412. * This simulates a sphere around the camera.
  93413. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93414. */
  93415. collisionRadius: Vector3;
  93416. protected _collider: Collider;
  93417. protected _previousPosition: Vector3;
  93418. protected _collisionVelocity: Vector3;
  93419. protected _newPosition: Vector3;
  93420. protected _previousAlpha: number;
  93421. protected _previousBeta: number;
  93422. protected _previousRadius: number;
  93423. protected _collisionTriggered: boolean;
  93424. protected _targetBoundingCenter: Nullable<Vector3>;
  93425. private _computationVector;
  93426. private _tempAxisVector;
  93427. private _tempAxisRotationMatrix;
  93428. /**
  93429. * Instantiates a new ArcRotateCamera in a given scene
  93430. * @param name Defines the name of the camera
  93431. * @param alpha Defines the camera rotation along the logitudinal axis
  93432. * @param beta Defines the camera rotation along the latitudinal axis
  93433. * @param radius Defines the camera distance from its target
  93434. * @param target Defines the camera target
  93435. * @param scene Defines the scene the camera belongs to
  93436. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93437. */
  93438. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93439. /** @hidden */
  93440. _initCache(): void;
  93441. /** @hidden */
  93442. _updateCache(ignoreParentClass?: boolean): void;
  93443. protected _getTargetPosition(): Vector3;
  93444. private _storedAlpha;
  93445. private _storedBeta;
  93446. private _storedRadius;
  93447. private _storedTarget;
  93448. /**
  93449. * Stores the current state of the camera (alpha, beta, radius and target)
  93450. * @returns the camera itself
  93451. */
  93452. storeState(): Camera;
  93453. /**
  93454. * @hidden
  93455. * Restored camera state. You must call storeState() first
  93456. */
  93457. _restoreStateValues(): boolean;
  93458. /** @hidden */
  93459. _isSynchronizedViewMatrix(): boolean;
  93460. /**
  93461. * Attached controls to the current camera.
  93462. * @param element Defines the element the controls should be listened from
  93463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93464. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93465. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93466. */
  93467. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93468. /**
  93469. * Detach the current controls from the camera.
  93470. * The camera will stop reacting to inputs.
  93471. * @param element Defines the element to stop listening the inputs from
  93472. */
  93473. detachControl(element: HTMLElement): void;
  93474. /** @hidden */
  93475. _checkInputs(): void;
  93476. protected _checkLimits(): void;
  93477. /**
  93478. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93479. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93480. */
  93481. rebuildAnglesAndRadius(updateView?: boolean): void;
  93482. /**
  93483. * Use a position to define the current camera related information like aplha, beta and radius
  93484. * @param position Defines the position to set the camera at
  93485. */
  93486. setPosition(position: Vector3): void;
  93487. /**
  93488. * Defines the target the camera should look at.
  93489. * This will automatically adapt alpha beta and radius to fit within the new target.
  93490. * @param target Defines the new target as a Vector or a mesh
  93491. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93492. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93493. */
  93494. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93495. /** @hidden */
  93496. _getViewMatrix(): Matrix;
  93497. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93498. /**
  93499. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93500. * @param meshes Defines the mesh to zoom on
  93501. * @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)
  93502. */
  93503. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93504. /**
  93505. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93506. * The target will be changed but the radius
  93507. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93508. * @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)
  93509. */
  93510. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93511. min: Vector3;
  93512. max: Vector3;
  93513. distance: number;
  93514. }, doNotUpdateMaxZ?: boolean): void;
  93515. /**
  93516. * @override
  93517. * Override Camera.createRigCamera
  93518. */
  93519. createRigCamera(name: string, cameraIndex: number): Camera;
  93520. /**
  93521. * @hidden
  93522. * @override
  93523. * Override Camera._updateRigCameras
  93524. */
  93525. _updateRigCameras(): void;
  93526. /**
  93527. * Destroy the camera and release the current resources hold by it.
  93528. */
  93529. dispose(): void;
  93530. /**
  93531. * Gets the current object class name.
  93532. * @return the class name
  93533. */
  93534. getClassName(): string;
  93535. }
  93536. }
  93537. declare module BABYLON {
  93538. /**
  93539. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93540. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93541. */
  93542. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93543. /**
  93544. * Gets the name of the behavior.
  93545. */
  93546. readonly name: string;
  93547. private _zoomStopsAnimation;
  93548. private _idleRotationSpeed;
  93549. private _idleRotationWaitTime;
  93550. private _idleRotationSpinupTime;
  93551. /**
  93552. * Sets the flag that indicates if user zooming should stop animation.
  93553. */
  93554. /**
  93555. * Gets the flag that indicates if user zooming should stop animation.
  93556. */
  93557. zoomStopsAnimation: boolean;
  93558. /**
  93559. * Sets the default speed at which the camera rotates around the model.
  93560. */
  93561. /**
  93562. * Gets the default speed at which the camera rotates around the model.
  93563. */
  93564. idleRotationSpeed: number;
  93565. /**
  93566. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93567. */
  93568. /**
  93569. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93570. */
  93571. idleRotationWaitTime: number;
  93572. /**
  93573. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93574. */
  93575. /**
  93576. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93577. */
  93578. idleRotationSpinupTime: number;
  93579. /**
  93580. * Gets a value indicating if the camera is currently rotating because of this behavior
  93581. */
  93582. readonly rotationInProgress: boolean;
  93583. private _onPrePointerObservableObserver;
  93584. private _onAfterCheckInputsObserver;
  93585. private _attachedCamera;
  93586. private _isPointerDown;
  93587. private _lastFrameTime;
  93588. private _lastInteractionTime;
  93589. private _cameraRotationSpeed;
  93590. /**
  93591. * Initializes the behavior.
  93592. */
  93593. init(): void;
  93594. /**
  93595. * Attaches the behavior to its arc rotate camera.
  93596. * @param camera Defines the camera to attach the behavior to
  93597. */
  93598. attach(camera: ArcRotateCamera): void;
  93599. /**
  93600. * Detaches the behavior from its current arc rotate camera.
  93601. */
  93602. detach(): void;
  93603. /**
  93604. * Returns true if user is scrolling.
  93605. * @return true if user is scrolling.
  93606. */
  93607. private _userIsZooming;
  93608. private _lastFrameRadius;
  93609. private _shouldAnimationStopForInteraction;
  93610. /**
  93611. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93612. */
  93613. private _applyUserInteraction;
  93614. private _userIsMoving;
  93615. }
  93616. }
  93617. declare module BABYLON {
  93618. /**
  93619. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93620. */
  93621. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93622. private ui;
  93623. /**
  93624. * The name of the behavior
  93625. */
  93626. name: string;
  93627. /**
  93628. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93629. */
  93630. distanceAwayFromFace: number;
  93631. /**
  93632. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93633. */
  93634. distanceAwayFromBottomOfFace: number;
  93635. private _faceVectors;
  93636. private _target;
  93637. private _scene;
  93638. private _onRenderObserver;
  93639. private _tmpMatrix;
  93640. private _tmpVector;
  93641. /**
  93642. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  93643. * @param ui The transform node that should be attched to the mesh
  93644. */
  93645. constructor(ui: TransformNode);
  93646. /**
  93647. * Initializes the behavior
  93648. */
  93649. init(): void;
  93650. private _closestFace;
  93651. private _zeroVector;
  93652. private _lookAtTmpMatrix;
  93653. private _lookAtToRef;
  93654. /**
  93655. * Attaches the AttachToBoxBehavior to the passed in mesh
  93656. * @param target The mesh that the specified node will be attached to
  93657. */
  93658. attach(target: Mesh): void;
  93659. /**
  93660. * Detaches the behavior from the mesh
  93661. */
  93662. detach(): void;
  93663. }
  93664. }
  93665. declare module BABYLON {
  93666. /**
  93667. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  93668. */
  93669. export class FadeInOutBehavior implements Behavior<Mesh> {
  93670. /**
  93671. * Time in milliseconds to delay before fading in (Default: 0)
  93672. */
  93673. delay: number;
  93674. /**
  93675. * Time in milliseconds for the mesh to fade in (Default: 300)
  93676. */
  93677. fadeInTime: number;
  93678. private _millisecondsPerFrame;
  93679. private _hovered;
  93680. private _hoverValue;
  93681. private _ownerNode;
  93682. /**
  93683. * Instatiates the FadeInOutBehavior
  93684. */
  93685. constructor();
  93686. /**
  93687. * The name of the behavior
  93688. */
  93689. readonly name: string;
  93690. /**
  93691. * Initializes the behavior
  93692. */
  93693. init(): void;
  93694. /**
  93695. * Attaches the fade behavior on the passed in mesh
  93696. * @param ownerNode The mesh that will be faded in/out once attached
  93697. */
  93698. attach(ownerNode: Mesh): void;
  93699. /**
  93700. * Detaches the behavior from the mesh
  93701. */
  93702. detach(): void;
  93703. /**
  93704. * Triggers the mesh to begin fading in or out
  93705. * @param value if the object should fade in or out (true to fade in)
  93706. */
  93707. fadeIn(value: boolean): void;
  93708. private _update;
  93709. private _setAllVisibility;
  93710. }
  93711. }
  93712. declare module BABYLON {
  93713. /**
  93714. * Class containing a set of static utilities functions for managing Pivots
  93715. * @hidden
  93716. */
  93717. export class PivotTools {
  93718. private static _PivotCached;
  93719. private static _OldPivotPoint;
  93720. private static _PivotTranslation;
  93721. private static _PivotTmpVector;
  93722. /** @hidden */
  93723. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  93724. /** @hidden */
  93725. static _RestorePivotPoint(mesh: AbstractMesh): void;
  93726. }
  93727. }
  93728. declare module BABYLON {
  93729. /**
  93730. * Class containing static functions to help procedurally build meshes
  93731. */
  93732. export class PlaneBuilder {
  93733. /**
  93734. * Creates a plane mesh
  93735. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  93736. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  93737. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  93738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93741. * @param name defines the name of the mesh
  93742. * @param options defines the options used to create the mesh
  93743. * @param scene defines the hosting scene
  93744. * @returns the plane mesh
  93745. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  93746. */
  93747. static CreatePlane(name: string, options: {
  93748. size?: number;
  93749. width?: number;
  93750. height?: number;
  93751. sideOrientation?: number;
  93752. frontUVs?: Vector4;
  93753. backUVs?: Vector4;
  93754. updatable?: boolean;
  93755. sourcePlane?: Plane;
  93756. }, scene: Scene): Mesh;
  93757. }
  93758. }
  93759. declare module BABYLON {
  93760. /**
  93761. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  93762. */
  93763. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  93764. private static _AnyMouseID;
  93765. private _attachedNode;
  93766. private _dragPlane;
  93767. private _scene;
  93768. private _pointerObserver;
  93769. private _beforeRenderObserver;
  93770. private static _planeScene;
  93771. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  93772. /**
  93773. * 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)
  93774. */
  93775. maxDragAngle: number;
  93776. /**
  93777. * @hidden
  93778. */
  93779. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  93780. /**
  93781. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93782. */
  93783. currentDraggingPointerID: number;
  93784. /**
  93785. * The last position where the pointer hit the drag plane in world space
  93786. */
  93787. lastDragPosition: Vector3;
  93788. /**
  93789. * If the behavior is currently in a dragging state
  93790. */
  93791. dragging: boolean;
  93792. /**
  93793. * 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)
  93794. */
  93795. dragDeltaRatio: number;
  93796. /**
  93797. * If the drag plane orientation should be updated during the dragging (Default: true)
  93798. */
  93799. updateDragPlane: boolean;
  93800. private _debugMode;
  93801. private _moving;
  93802. /**
  93803. * Fires each time the attached mesh is dragged with the pointer
  93804. * * delta between last drag position and current drag position in world space
  93805. * * dragDistance along the drag axis
  93806. * * dragPlaneNormal normal of the current drag plane used during the drag
  93807. * * dragPlanePoint in world space where the drag intersects the drag plane
  93808. */
  93809. onDragObservable: Observable<{
  93810. delta: Vector3;
  93811. dragPlanePoint: Vector3;
  93812. dragPlaneNormal: Vector3;
  93813. dragDistance: number;
  93814. pointerId: number;
  93815. }>;
  93816. /**
  93817. * Fires each time a drag begins (eg. mouse down on mesh)
  93818. */
  93819. onDragStartObservable: Observable<{
  93820. dragPlanePoint: Vector3;
  93821. pointerId: number;
  93822. }>;
  93823. /**
  93824. * Fires each time a drag ends (eg. mouse release after drag)
  93825. */
  93826. onDragEndObservable: Observable<{
  93827. dragPlanePoint: Vector3;
  93828. pointerId: number;
  93829. }>;
  93830. /**
  93831. * If the attached mesh should be moved when dragged
  93832. */
  93833. moveAttached: boolean;
  93834. /**
  93835. * If the drag behavior will react to drag events (Default: true)
  93836. */
  93837. enabled: boolean;
  93838. /**
  93839. * If camera controls should be detached during the drag
  93840. */
  93841. detachCameraControls: boolean;
  93842. /**
  93843. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  93844. */
  93845. useObjectOrienationForDragging: boolean;
  93846. private _options;
  93847. /**
  93848. * Creates a pointer drag behavior that can be attached to a mesh
  93849. * @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)
  93850. */
  93851. constructor(options?: {
  93852. dragAxis?: Vector3;
  93853. dragPlaneNormal?: Vector3;
  93854. });
  93855. /**
  93856. * Predicate to determine if it is valid to move the object to a new position when it is moved
  93857. */
  93858. validateDrag: (targetPosition: Vector3) => boolean;
  93859. /**
  93860. * The name of the behavior
  93861. */
  93862. readonly name: string;
  93863. /**
  93864. * Initializes the behavior
  93865. */
  93866. init(): void;
  93867. private _tmpVector;
  93868. private _alternatePickedPoint;
  93869. private _worldDragAxis;
  93870. private _targetPosition;
  93871. private _attachedElement;
  93872. /**
  93873. * Attaches the drag behavior the passed in mesh
  93874. * @param ownerNode The mesh that will be dragged around once attached
  93875. */
  93876. attach(ownerNode: AbstractMesh): void;
  93877. /**
  93878. * Force relase the drag action by code.
  93879. */
  93880. releaseDrag(): void;
  93881. private _startDragRay;
  93882. private _lastPointerRay;
  93883. /**
  93884. * Simulates the start of a pointer drag event on the behavior
  93885. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  93886. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  93887. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  93888. */
  93889. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  93890. private _startDrag;
  93891. private _dragDelta;
  93892. private _moveDrag;
  93893. private _pickWithRayOnDragPlane;
  93894. private _pointA;
  93895. private _pointB;
  93896. private _pointC;
  93897. private _lineA;
  93898. private _lineB;
  93899. private _localAxis;
  93900. private _lookAt;
  93901. private _updateDragPlanePosition;
  93902. /**
  93903. * Detaches the behavior from the mesh
  93904. */
  93905. detach(): void;
  93906. }
  93907. }
  93908. declare module BABYLON {
  93909. /**
  93910. * A behavior that when attached to a mesh will allow the mesh to be scaled
  93911. */
  93912. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  93913. private _dragBehaviorA;
  93914. private _dragBehaviorB;
  93915. private _startDistance;
  93916. private _initialScale;
  93917. private _targetScale;
  93918. private _ownerNode;
  93919. private _sceneRenderObserver;
  93920. /**
  93921. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  93922. */
  93923. constructor();
  93924. /**
  93925. * The name of the behavior
  93926. */
  93927. readonly name: string;
  93928. /**
  93929. * Initializes the behavior
  93930. */
  93931. init(): void;
  93932. private _getCurrentDistance;
  93933. /**
  93934. * Attaches the scale behavior the passed in mesh
  93935. * @param ownerNode The mesh that will be scaled around once attached
  93936. */
  93937. attach(ownerNode: Mesh): void;
  93938. /**
  93939. * Detaches the behavior from the mesh
  93940. */
  93941. detach(): void;
  93942. }
  93943. }
  93944. declare module BABYLON {
  93945. /**
  93946. * 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
  93947. */
  93948. export class SixDofDragBehavior implements Behavior<Mesh> {
  93949. private static _virtualScene;
  93950. private _ownerNode;
  93951. private _sceneRenderObserver;
  93952. private _scene;
  93953. private _targetPosition;
  93954. private _virtualOriginMesh;
  93955. private _virtualDragMesh;
  93956. private _pointerObserver;
  93957. private _moving;
  93958. private _startingOrientation;
  93959. /**
  93960. * 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)
  93961. */
  93962. private zDragFactor;
  93963. /**
  93964. * If the object should rotate to face the drag origin
  93965. */
  93966. rotateDraggedObject: boolean;
  93967. /**
  93968. * If the behavior is currently in a dragging state
  93969. */
  93970. dragging: boolean;
  93971. /**
  93972. * 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)
  93973. */
  93974. dragDeltaRatio: number;
  93975. /**
  93976. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93977. */
  93978. currentDraggingPointerID: number;
  93979. /**
  93980. * If camera controls should be detached during the drag
  93981. */
  93982. detachCameraControls: boolean;
  93983. /**
  93984. * Fires each time a drag starts
  93985. */
  93986. onDragStartObservable: Observable<{}>;
  93987. /**
  93988. * Fires each time a drag ends (eg. mouse release after drag)
  93989. */
  93990. onDragEndObservable: Observable<{}>;
  93991. /**
  93992. * 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
  93993. */
  93994. constructor();
  93995. /**
  93996. * The name of the behavior
  93997. */
  93998. readonly name: string;
  93999. /**
  94000. * Initializes the behavior
  94001. */
  94002. init(): void;
  94003. /**
  94004. * Attaches the scale behavior the passed in mesh
  94005. * @param ownerNode The mesh that will be scaled around once attached
  94006. */
  94007. attach(ownerNode: Mesh): void;
  94008. /**
  94009. * Detaches the behavior from the mesh
  94010. */
  94011. detach(): void;
  94012. }
  94013. }
  94014. declare module BABYLON {
  94015. /**
  94016. * Class used to apply inverse kinematics to bones
  94017. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  94018. */
  94019. export class BoneIKController {
  94020. private static _tmpVecs;
  94021. private static _tmpQuat;
  94022. private static _tmpMats;
  94023. /**
  94024. * Gets or sets the target mesh
  94025. */
  94026. targetMesh: AbstractMesh;
  94027. /** Gets or sets the mesh used as pole */
  94028. poleTargetMesh: AbstractMesh;
  94029. /**
  94030. * Gets or sets the bone used as pole
  94031. */
  94032. poleTargetBone: Nullable<Bone>;
  94033. /**
  94034. * Gets or sets the target position
  94035. */
  94036. targetPosition: Vector3;
  94037. /**
  94038. * Gets or sets the pole target position
  94039. */
  94040. poleTargetPosition: Vector3;
  94041. /**
  94042. * Gets or sets the pole target local offset
  94043. */
  94044. poleTargetLocalOffset: Vector3;
  94045. /**
  94046. * Gets or sets the pole angle
  94047. */
  94048. poleAngle: number;
  94049. /**
  94050. * Gets or sets the mesh associated with the controller
  94051. */
  94052. mesh: AbstractMesh;
  94053. /**
  94054. * 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)
  94055. */
  94056. slerpAmount: number;
  94057. private _bone1Quat;
  94058. private _bone1Mat;
  94059. private _bone2Ang;
  94060. private _bone1;
  94061. private _bone2;
  94062. private _bone1Length;
  94063. private _bone2Length;
  94064. private _maxAngle;
  94065. private _maxReach;
  94066. private _rightHandedSystem;
  94067. private _bendAxis;
  94068. private _slerping;
  94069. private _adjustRoll;
  94070. /**
  94071. * Gets or sets maximum allowed angle
  94072. */
  94073. maxAngle: number;
  94074. /**
  94075. * Creates a new BoneIKController
  94076. * @param mesh defines the mesh to control
  94077. * @param bone defines the bone to control
  94078. * @param options defines options to set up the controller
  94079. */
  94080. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94081. targetMesh?: AbstractMesh;
  94082. poleTargetMesh?: AbstractMesh;
  94083. poleTargetBone?: Bone;
  94084. poleTargetLocalOffset?: Vector3;
  94085. poleAngle?: number;
  94086. bendAxis?: Vector3;
  94087. maxAngle?: number;
  94088. slerpAmount?: number;
  94089. });
  94090. private _setMaxAngle;
  94091. /**
  94092. * Force the controller to update the bones
  94093. */
  94094. update(): void;
  94095. }
  94096. }
  94097. declare module BABYLON {
  94098. /**
  94099. * Class used to make a bone look toward a point in space
  94100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94101. */
  94102. export class BoneLookController {
  94103. private static _tmpVecs;
  94104. private static _tmpQuat;
  94105. private static _tmpMats;
  94106. /**
  94107. * The target Vector3 that the bone will look at
  94108. */
  94109. target: Vector3;
  94110. /**
  94111. * The mesh that the bone is attached to
  94112. */
  94113. mesh: AbstractMesh;
  94114. /**
  94115. * The bone that will be looking to the target
  94116. */
  94117. bone: Bone;
  94118. /**
  94119. * The up axis of the coordinate system that is used when the bone is rotated
  94120. */
  94121. upAxis: Vector3;
  94122. /**
  94123. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94124. */
  94125. upAxisSpace: Space;
  94126. /**
  94127. * Used to make an adjustment to the yaw of the bone
  94128. */
  94129. adjustYaw: number;
  94130. /**
  94131. * Used to make an adjustment to the pitch of the bone
  94132. */
  94133. adjustPitch: number;
  94134. /**
  94135. * Used to make an adjustment to the roll of the bone
  94136. */
  94137. adjustRoll: number;
  94138. /**
  94139. * 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)
  94140. */
  94141. slerpAmount: number;
  94142. private _minYaw;
  94143. private _maxYaw;
  94144. private _minPitch;
  94145. private _maxPitch;
  94146. private _minYawSin;
  94147. private _minYawCos;
  94148. private _maxYawSin;
  94149. private _maxYawCos;
  94150. private _midYawConstraint;
  94151. private _minPitchTan;
  94152. private _maxPitchTan;
  94153. private _boneQuat;
  94154. private _slerping;
  94155. private _transformYawPitch;
  94156. private _transformYawPitchInv;
  94157. private _firstFrameSkipped;
  94158. private _yawRange;
  94159. private _fowardAxis;
  94160. /**
  94161. * Gets or sets the minimum yaw angle that the bone can look to
  94162. */
  94163. minYaw: number;
  94164. /**
  94165. * Gets or sets the maximum yaw angle that the bone can look to
  94166. */
  94167. maxYaw: number;
  94168. /**
  94169. * Gets or sets the minimum pitch angle that the bone can look to
  94170. */
  94171. minPitch: number;
  94172. /**
  94173. * Gets or sets the maximum pitch angle that the bone can look to
  94174. */
  94175. maxPitch: number;
  94176. /**
  94177. * Create a BoneLookController
  94178. * @param mesh the mesh that the bone belongs to
  94179. * @param bone the bone that will be looking to the target
  94180. * @param target the target Vector3 to look at
  94181. * @param options optional settings:
  94182. * * maxYaw: the maximum angle the bone will yaw to
  94183. * * minYaw: the minimum angle the bone will yaw to
  94184. * * maxPitch: the maximum angle the bone will pitch to
  94185. * * minPitch: the minimum angle the bone will yaw to
  94186. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94187. * * upAxis: the up axis of the coordinate system
  94188. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94189. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94190. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94191. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94192. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94193. * * adjustRoll: used to make an adjustment to the roll of the bone
  94194. **/
  94195. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94196. maxYaw?: number;
  94197. minYaw?: number;
  94198. maxPitch?: number;
  94199. minPitch?: number;
  94200. slerpAmount?: number;
  94201. upAxis?: Vector3;
  94202. upAxisSpace?: Space;
  94203. yawAxis?: Vector3;
  94204. pitchAxis?: Vector3;
  94205. adjustYaw?: number;
  94206. adjustPitch?: number;
  94207. adjustRoll?: number;
  94208. });
  94209. /**
  94210. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94211. */
  94212. update(): void;
  94213. private _getAngleDiff;
  94214. private _getAngleBetween;
  94215. private _isAngleBetween;
  94216. }
  94217. }
  94218. declare module BABYLON {
  94219. /**
  94220. * Manage the gamepad inputs to control an arc rotate camera.
  94221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94222. */
  94223. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94224. /**
  94225. * Defines the camera the input is attached to.
  94226. */
  94227. camera: ArcRotateCamera;
  94228. /**
  94229. * Defines the gamepad the input is gathering event from.
  94230. */
  94231. gamepad: Nullable<Gamepad>;
  94232. /**
  94233. * Defines the gamepad rotation sensiblity.
  94234. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94235. */
  94236. gamepadRotationSensibility: number;
  94237. /**
  94238. * Defines the gamepad move sensiblity.
  94239. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94240. */
  94241. gamepadMoveSensibility: number;
  94242. private _onGamepadConnectedObserver;
  94243. private _onGamepadDisconnectedObserver;
  94244. /**
  94245. * Attach the input controls to a specific dom element to get the input from.
  94246. * @param element Defines the element the controls should be listened from
  94247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94248. */
  94249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94250. /**
  94251. * Detach the current controls from the specified dom element.
  94252. * @param element Defines the element to stop listening the inputs from
  94253. */
  94254. detachControl(element: Nullable<HTMLElement>): void;
  94255. /**
  94256. * Update the current camera state depending on the inputs that have been used this frame.
  94257. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94258. */
  94259. checkInputs(): void;
  94260. /**
  94261. * Gets the class name of the current intput.
  94262. * @returns the class name
  94263. */
  94264. getClassName(): string;
  94265. /**
  94266. * Get the friendly name associated with the input class.
  94267. * @returns the input friendly name
  94268. */
  94269. getSimpleName(): string;
  94270. }
  94271. }
  94272. declare module BABYLON {
  94273. interface ArcRotateCameraInputsManager {
  94274. /**
  94275. * Add orientation input support to the input manager.
  94276. * @returns the current input manager
  94277. */
  94278. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94279. }
  94280. /**
  94281. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94283. */
  94284. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94285. /**
  94286. * Defines the camera the input is attached to.
  94287. */
  94288. camera: ArcRotateCamera;
  94289. /**
  94290. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94291. */
  94292. alphaCorrection: number;
  94293. /**
  94294. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94295. */
  94296. gammaCorrection: number;
  94297. private _alpha;
  94298. private _gamma;
  94299. private _dirty;
  94300. private _deviceOrientationHandler;
  94301. /**
  94302. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94303. */
  94304. constructor();
  94305. /**
  94306. * Attach the input controls to a specific dom element to get the input from.
  94307. * @param element Defines the element the controls should be listened from
  94308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94309. */
  94310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94311. /** @hidden */
  94312. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94313. /**
  94314. * Update the current camera state depending on the inputs that have been used this frame.
  94315. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94316. */
  94317. checkInputs(): void;
  94318. /**
  94319. * Detach the current controls from the specified dom element.
  94320. * @param element Defines the element to stop listening the inputs from
  94321. */
  94322. detachControl(element: Nullable<HTMLElement>): void;
  94323. /**
  94324. * Gets the class name of the current intput.
  94325. * @returns the class name
  94326. */
  94327. getClassName(): string;
  94328. /**
  94329. * Get the friendly name associated with the input class.
  94330. * @returns the input friendly name
  94331. */
  94332. getSimpleName(): string;
  94333. }
  94334. }
  94335. declare module BABYLON {
  94336. /**
  94337. * Listen to mouse events to control the camera.
  94338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94339. */
  94340. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94341. /**
  94342. * Defines the camera the input is attached to.
  94343. */
  94344. camera: FlyCamera;
  94345. /**
  94346. * Defines if touch is enabled. (Default is true.)
  94347. */
  94348. touchEnabled: boolean;
  94349. /**
  94350. * Defines the buttons associated with the input to handle camera rotation.
  94351. */
  94352. buttons: number[];
  94353. /**
  94354. * Assign buttons for Yaw control.
  94355. */
  94356. buttonsYaw: number[];
  94357. /**
  94358. * Assign buttons for Pitch control.
  94359. */
  94360. buttonsPitch: number[];
  94361. /**
  94362. * Assign buttons for Roll control.
  94363. */
  94364. buttonsRoll: number[];
  94365. /**
  94366. * Detect if any button is being pressed while mouse is moved.
  94367. * -1 = Mouse locked.
  94368. * 0 = Left button.
  94369. * 1 = Middle Button.
  94370. * 2 = Right Button.
  94371. */
  94372. activeButton: number;
  94373. /**
  94374. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94375. * Higher values reduce its sensitivity.
  94376. */
  94377. angularSensibility: number;
  94378. private _mousemoveCallback;
  94379. private _observer;
  94380. private _rollObserver;
  94381. private previousPosition;
  94382. private noPreventDefault;
  94383. private element;
  94384. /**
  94385. * Listen to mouse events to control the camera.
  94386. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94388. */
  94389. constructor(touchEnabled?: boolean);
  94390. /**
  94391. * Attach the mouse control to the HTML DOM element.
  94392. * @param element Defines the element that listens to the input events.
  94393. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94394. */
  94395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94396. /**
  94397. * Detach the current controls from the specified dom element.
  94398. * @param element Defines the element to stop listening the inputs from
  94399. */
  94400. detachControl(element: Nullable<HTMLElement>): void;
  94401. /**
  94402. * Gets the class name of the current input.
  94403. * @returns the class name.
  94404. */
  94405. getClassName(): string;
  94406. /**
  94407. * Get the friendly name associated with the input class.
  94408. * @returns the input's friendly name.
  94409. */
  94410. getSimpleName(): string;
  94411. private _pointerInput;
  94412. private _onMouseMove;
  94413. /**
  94414. * Rotate camera by mouse offset.
  94415. */
  94416. private rotateCamera;
  94417. }
  94418. }
  94419. declare module BABYLON {
  94420. /**
  94421. * Default Inputs manager for the FlyCamera.
  94422. * It groups all the default supported inputs for ease of use.
  94423. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94424. */
  94425. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94426. /**
  94427. * Instantiates a new FlyCameraInputsManager.
  94428. * @param camera Defines the camera the inputs belong to.
  94429. */
  94430. constructor(camera: FlyCamera);
  94431. /**
  94432. * Add keyboard input support to the input manager.
  94433. * @returns the new FlyCameraKeyboardMoveInput().
  94434. */
  94435. addKeyboard(): FlyCameraInputsManager;
  94436. /**
  94437. * Add mouse input support to the input manager.
  94438. * @param touchEnabled Enable touch screen support.
  94439. * @returns the new FlyCameraMouseInput().
  94440. */
  94441. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94442. }
  94443. }
  94444. declare module BABYLON {
  94445. /**
  94446. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94447. * such as in a 3D Space Shooter or a Flight Simulator.
  94448. */
  94449. export class FlyCamera extends TargetCamera {
  94450. /**
  94451. * Define the collision ellipsoid of the camera.
  94452. * This is helpful for simulating a camera body, like a player's body.
  94453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94454. */
  94455. ellipsoid: Vector3;
  94456. /**
  94457. * Define an offset for the position of the ellipsoid around the camera.
  94458. * This can be helpful if the camera is attached away from the player's body center,
  94459. * such as at its head.
  94460. */
  94461. ellipsoidOffset: Vector3;
  94462. /**
  94463. * Enable or disable collisions of the camera with the rest of the scene objects.
  94464. */
  94465. checkCollisions: boolean;
  94466. /**
  94467. * Enable or disable gravity on the camera.
  94468. */
  94469. applyGravity: boolean;
  94470. /**
  94471. * Define the current direction the camera is moving to.
  94472. */
  94473. cameraDirection: Vector3;
  94474. /**
  94475. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94476. * This overrides and empties cameraRotation.
  94477. */
  94478. rotationQuaternion: Quaternion;
  94479. /**
  94480. * Track Roll to maintain the wanted Rolling when looking around.
  94481. */
  94482. _trackRoll: number;
  94483. /**
  94484. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94485. */
  94486. rollCorrect: number;
  94487. /**
  94488. * Mimic a banked turn, Rolling the camera when Yawing.
  94489. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94490. */
  94491. bankedTurn: boolean;
  94492. /**
  94493. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94494. */
  94495. bankedTurnLimit: number;
  94496. /**
  94497. * Value of 0 disables the banked Roll.
  94498. * Value of 1 is equal to the Yaw angle in radians.
  94499. */
  94500. bankedTurnMultiplier: number;
  94501. /**
  94502. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94503. */
  94504. inputs: FlyCameraInputsManager;
  94505. /**
  94506. * Gets the input sensibility for mouse input.
  94507. * Higher values reduce sensitivity.
  94508. */
  94509. /**
  94510. * Sets the input sensibility for a mouse input.
  94511. * Higher values reduce sensitivity.
  94512. */
  94513. angularSensibility: number;
  94514. /**
  94515. * Get the keys for camera movement forward.
  94516. */
  94517. /**
  94518. * Set the keys for camera movement forward.
  94519. */
  94520. keysForward: number[];
  94521. /**
  94522. * Get the keys for camera movement backward.
  94523. */
  94524. keysBackward: number[];
  94525. /**
  94526. * Get the keys for camera movement up.
  94527. */
  94528. /**
  94529. * Set the keys for camera movement up.
  94530. */
  94531. keysUp: number[];
  94532. /**
  94533. * Get the keys for camera movement down.
  94534. */
  94535. /**
  94536. * Set the keys for camera movement down.
  94537. */
  94538. keysDown: number[];
  94539. /**
  94540. * Get the keys for camera movement left.
  94541. */
  94542. /**
  94543. * Set the keys for camera movement left.
  94544. */
  94545. keysLeft: number[];
  94546. /**
  94547. * Set the keys for camera movement right.
  94548. */
  94549. /**
  94550. * Set the keys for camera movement right.
  94551. */
  94552. keysRight: number[];
  94553. /**
  94554. * Event raised when the camera collides with a mesh in the scene.
  94555. */
  94556. onCollide: (collidedMesh: AbstractMesh) => void;
  94557. private _collider;
  94558. private _needMoveForGravity;
  94559. private _oldPosition;
  94560. private _diffPosition;
  94561. private _newPosition;
  94562. /** @hidden */
  94563. _localDirection: Vector3;
  94564. /** @hidden */
  94565. _transformedDirection: Vector3;
  94566. /**
  94567. * Instantiates a FlyCamera.
  94568. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94569. * such as in a 3D Space Shooter or a Flight Simulator.
  94570. * @param name Define the name of the camera in the scene.
  94571. * @param position Define the starting position of the camera in the scene.
  94572. * @param scene Define the scene the camera belongs to.
  94573. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94574. */
  94575. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94576. /**
  94577. * Attach a control to the HTML DOM element.
  94578. * @param element Defines the element that listens to the input events.
  94579. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94580. */
  94581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94582. /**
  94583. * Detach a control from the HTML DOM element.
  94584. * The camera will stop reacting to that input.
  94585. * @param element Defines the element that listens to the input events.
  94586. */
  94587. detachControl(element: HTMLElement): void;
  94588. private _collisionMask;
  94589. /**
  94590. * Get the mask that the camera ignores in collision events.
  94591. */
  94592. /**
  94593. * Set the mask that the camera ignores in collision events.
  94594. */
  94595. collisionMask: number;
  94596. /** @hidden */
  94597. _collideWithWorld(displacement: Vector3): void;
  94598. /** @hidden */
  94599. private _onCollisionPositionChange;
  94600. /** @hidden */
  94601. _checkInputs(): void;
  94602. /** @hidden */
  94603. _decideIfNeedsToMove(): boolean;
  94604. /** @hidden */
  94605. _updatePosition(): void;
  94606. /**
  94607. * Restore the Roll to its target value at the rate specified.
  94608. * @param rate - Higher means slower restoring.
  94609. * @hidden
  94610. */
  94611. restoreRoll(rate: number): void;
  94612. /**
  94613. * Destroy the camera and release the current resources held by it.
  94614. */
  94615. dispose(): void;
  94616. /**
  94617. * Get the current object class name.
  94618. * @returns the class name.
  94619. */
  94620. getClassName(): string;
  94621. }
  94622. }
  94623. declare module BABYLON {
  94624. /**
  94625. * Listen to keyboard events to control the camera.
  94626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94627. */
  94628. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94629. /**
  94630. * Defines the camera the input is attached to.
  94631. */
  94632. camera: FlyCamera;
  94633. /**
  94634. * The list of keyboard keys used to control the forward move of the camera.
  94635. */
  94636. keysForward: number[];
  94637. /**
  94638. * The list of keyboard keys used to control the backward move of the camera.
  94639. */
  94640. keysBackward: number[];
  94641. /**
  94642. * The list of keyboard keys used to control the forward move of the camera.
  94643. */
  94644. keysUp: number[];
  94645. /**
  94646. * The list of keyboard keys used to control the backward move of the camera.
  94647. */
  94648. keysDown: number[];
  94649. /**
  94650. * The list of keyboard keys used to control the right strafe move of the camera.
  94651. */
  94652. keysRight: number[];
  94653. /**
  94654. * The list of keyboard keys used to control the left strafe move of the camera.
  94655. */
  94656. keysLeft: number[];
  94657. private _keys;
  94658. private _onCanvasBlurObserver;
  94659. private _onKeyboardObserver;
  94660. private _engine;
  94661. private _scene;
  94662. /**
  94663. * Attach the input controls to a specific dom element to get the input from.
  94664. * @param element Defines the element the controls should be listened from
  94665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94666. */
  94667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94668. /**
  94669. * Detach the current controls from the specified dom element.
  94670. * @param element Defines the element to stop listening the inputs from
  94671. */
  94672. detachControl(element: Nullable<HTMLElement>): void;
  94673. /**
  94674. * Gets the class name of the current intput.
  94675. * @returns the class name
  94676. */
  94677. getClassName(): string;
  94678. /** @hidden */
  94679. _onLostFocus(e: FocusEvent): void;
  94680. /**
  94681. * Get the friendly name associated with the input class.
  94682. * @returns the input friendly name
  94683. */
  94684. getSimpleName(): string;
  94685. /**
  94686. * Update the current camera state depending on the inputs that have been used this frame.
  94687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94688. */
  94689. checkInputs(): void;
  94690. }
  94691. }
  94692. declare module BABYLON {
  94693. /**
  94694. * Manage the mouse wheel inputs to control a follow camera.
  94695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94696. */
  94697. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  94698. /**
  94699. * Defines the camera the input is attached to.
  94700. */
  94701. camera: FollowCamera;
  94702. /**
  94703. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  94704. */
  94705. axisControlRadius: boolean;
  94706. /**
  94707. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  94708. */
  94709. axisControlHeight: boolean;
  94710. /**
  94711. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  94712. */
  94713. axisControlRotation: boolean;
  94714. /**
  94715. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  94716. * relation to mouseWheel events.
  94717. */
  94718. wheelPrecision: number;
  94719. /**
  94720. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94721. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94722. */
  94723. wheelDeltaPercentage: number;
  94724. private _wheel;
  94725. private _observer;
  94726. /**
  94727. * Attach the input controls to a specific dom element to get the input from.
  94728. * @param element Defines the element the controls should be listened from
  94729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94730. */
  94731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94732. /**
  94733. * Detach the current controls from the specified dom element.
  94734. * @param element Defines the element to stop listening the inputs from
  94735. */
  94736. detachControl(element: Nullable<HTMLElement>): void;
  94737. /**
  94738. * Gets the class name of the current intput.
  94739. * @returns the class name
  94740. */
  94741. getClassName(): string;
  94742. /**
  94743. * Get the friendly name associated with the input class.
  94744. * @returns the input friendly name
  94745. */
  94746. getSimpleName(): string;
  94747. }
  94748. }
  94749. declare module BABYLON {
  94750. /**
  94751. * Manage the pointers inputs to control an follow camera.
  94752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94753. */
  94754. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  94755. /**
  94756. * Defines the camera the input is attached to.
  94757. */
  94758. camera: FollowCamera;
  94759. /**
  94760. * Gets the class name of the current input.
  94761. * @returns the class name
  94762. */
  94763. getClassName(): string;
  94764. /**
  94765. * Defines the pointer angular sensibility along the X axis or how fast is
  94766. * the camera rotating.
  94767. * A negative number will reverse the axis direction.
  94768. */
  94769. angularSensibilityX: number;
  94770. /**
  94771. * Defines the pointer angular sensibility along the Y axis or how fast is
  94772. * the camera rotating.
  94773. * A negative number will reverse the axis direction.
  94774. */
  94775. angularSensibilityY: number;
  94776. /**
  94777. * Defines the pointer pinch precision or how fast is the camera zooming.
  94778. * A negative number will reverse the axis direction.
  94779. */
  94780. pinchPrecision: number;
  94781. /**
  94782. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94783. * from 0.
  94784. * It defines the percentage of current camera.radius to use as delta when
  94785. * pinch zoom is used.
  94786. */
  94787. pinchDeltaPercentage: number;
  94788. /**
  94789. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  94790. */
  94791. axisXControlRadius: boolean;
  94792. /**
  94793. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  94794. */
  94795. axisXControlHeight: boolean;
  94796. /**
  94797. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  94798. */
  94799. axisXControlRotation: boolean;
  94800. /**
  94801. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  94802. */
  94803. axisYControlRadius: boolean;
  94804. /**
  94805. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  94806. */
  94807. axisYControlHeight: boolean;
  94808. /**
  94809. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  94810. */
  94811. axisYControlRotation: boolean;
  94812. /**
  94813. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  94814. */
  94815. axisPinchControlRadius: boolean;
  94816. /**
  94817. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  94818. */
  94819. axisPinchControlHeight: boolean;
  94820. /**
  94821. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  94822. */
  94823. axisPinchControlRotation: boolean;
  94824. /**
  94825. * Log error messages if basic misconfiguration has occurred.
  94826. */
  94827. warningEnable: boolean;
  94828. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94829. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94830. private _warningCounter;
  94831. private _warning;
  94832. }
  94833. }
  94834. declare module BABYLON {
  94835. /**
  94836. * Default Inputs manager for the FollowCamera.
  94837. * It groups all the default supported inputs for ease of use.
  94838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94839. */
  94840. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  94841. /**
  94842. * Instantiates a new FollowCameraInputsManager.
  94843. * @param camera Defines the camera the inputs belong to
  94844. */
  94845. constructor(camera: FollowCamera);
  94846. /**
  94847. * Add keyboard input support to the input manager.
  94848. * @returns the current input manager
  94849. */
  94850. addKeyboard(): FollowCameraInputsManager;
  94851. /**
  94852. * Add mouse wheel input support to the input manager.
  94853. * @returns the current input manager
  94854. */
  94855. addMouseWheel(): FollowCameraInputsManager;
  94856. /**
  94857. * Add pointers input support to the input manager.
  94858. * @returns the current input manager
  94859. */
  94860. addPointers(): FollowCameraInputsManager;
  94861. /**
  94862. * Add orientation input support to the input manager.
  94863. * @returns the current input manager
  94864. */
  94865. addVRDeviceOrientation(): FollowCameraInputsManager;
  94866. }
  94867. }
  94868. declare module BABYLON {
  94869. /**
  94870. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  94871. * an arc rotate version arcFollowCamera are available.
  94872. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94873. */
  94874. export class FollowCamera extends TargetCamera {
  94875. /**
  94876. * Distance the follow camera should follow an object at
  94877. */
  94878. radius: number;
  94879. /**
  94880. * Minimum allowed distance of the camera to the axis of rotation
  94881. * (The camera can not get closer).
  94882. * This can help limiting how the Camera is able to move in the scene.
  94883. */
  94884. lowerRadiusLimit: Nullable<number>;
  94885. /**
  94886. * Maximum allowed distance of the camera to the axis of rotation
  94887. * (The camera can not get further).
  94888. * This can help limiting how the Camera is able to move in the scene.
  94889. */
  94890. upperRadiusLimit: Nullable<number>;
  94891. /**
  94892. * Define a rotation offset between the camera and the object it follows
  94893. */
  94894. rotationOffset: number;
  94895. /**
  94896. * Minimum allowed angle to camera position relative to target object.
  94897. * This can help limiting how the Camera is able to move in the scene.
  94898. */
  94899. lowerRotationOffsetLimit: Nullable<number>;
  94900. /**
  94901. * Maximum allowed angle to camera position relative to target object.
  94902. * This can help limiting how the Camera is able to move in the scene.
  94903. */
  94904. upperRotationOffsetLimit: Nullable<number>;
  94905. /**
  94906. * Define a height offset between the camera and the object it follows.
  94907. * It can help following an object from the top (like a car chaing a plane)
  94908. */
  94909. heightOffset: number;
  94910. /**
  94911. * Minimum allowed height of camera position relative to target object.
  94912. * This can help limiting how the Camera is able to move in the scene.
  94913. */
  94914. lowerHeightOffsetLimit: Nullable<number>;
  94915. /**
  94916. * Maximum allowed height of camera position relative to target object.
  94917. * This can help limiting how the Camera is able to move in the scene.
  94918. */
  94919. upperHeightOffsetLimit: Nullable<number>;
  94920. /**
  94921. * Define how fast the camera can accelerate to follow it s target.
  94922. */
  94923. cameraAcceleration: number;
  94924. /**
  94925. * Define the speed limit of the camera following an object.
  94926. */
  94927. maxCameraSpeed: number;
  94928. /**
  94929. * Define the target of the camera.
  94930. */
  94931. lockedTarget: Nullable<AbstractMesh>;
  94932. /**
  94933. * Defines the input associated with the camera.
  94934. */
  94935. inputs: FollowCameraInputsManager;
  94936. /**
  94937. * Instantiates the follow camera.
  94938. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94939. * @param name Define the name of the camera in the scene
  94940. * @param position Define the position of the camera
  94941. * @param scene Define the scene the camera belong to
  94942. * @param lockedTarget Define the target of the camera
  94943. */
  94944. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  94945. private _follow;
  94946. /**
  94947. * Attached controls to the current camera.
  94948. * @param element Defines the element the controls should be listened from
  94949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94950. */
  94951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94952. /**
  94953. * Detach the current controls from the camera.
  94954. * The camera will stop reacting to inputs.
  94955. * @param element Defines the element to stop listening the inputs from
  94956. */
  94957. detachControl(element: HTMLElement): void;
  94958. /** @hidden */
  94959. _checkInputs(): void;
  94960. private _checkLimits;
  94961. /**
  94962. * Gets the camera class name.
  94963. * @returns the class name
  94964. */
  94965. getClassName(): string;
  94966. }
  94967. /**
  94968. * Arc Rotate version of the follow camera.
  94969. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94970. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94971. */
  94972. export class ArcFollowCamera extends TargetCamera {
  94973. /** The longitudinal angle of the camera */
  94974. alpha: number;
  94975. /** The latitudinal angle of the camera */
  94976. beta: number;
  94977. /** The radius of the camera from its target */
  94978. radius: number;
  94979. /** Define the camera target (the messh it should follow) */
  94980. target: Nullable<AbstractMesh>;
  94981. private _cartesianCoordinates;
  94982. /**
  94983. * Instantiates a new ArcFollowCamera
  94984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94985. * @param name Define the name of the camera
  94986. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94987. * @param beta Define the rotation angle of the camera around the elevation axis
  94988. * @param radius Define the radius of the camera from its target point
  94989. * @param target Define the target of the camera
  94990. * @param scene Define the scene the camera belongs to
  94991. */
  94992. constructor(name: string,
  94993. /** The longitudinal angle of the camera */
  94994. alpha: number,
  94995. /** The latitudinal angle of the camera */
  94996. beta: number,
  94997. /** The radius of the camera from its target */
  94998. radius: number,
  94999. /** Define the camera target (the messh it should follow) */
  95000. target: Nullable<AbstractMesh>, scene: Scene);
  95001. private _follow;
  95002. /** @hidden */
  95003. _checkInputs(): void;
  95004. /**
  95005. * Returns the class name of the object.
  95006. * It is mostly used internally for serialization purposes.
  95007. */
  95008. getClassName(): string;
  95009. }
  95010. }
  95011. declare module BABYLON {
  95012. /**
  95013. * Manage the keyboard inputs to control the movement of a follow camera.
  95014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95015. */
  95016. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  95017. /**
  95018. * Defines the camera the input is attached to.
  95019. */
  95020. camera: FollowCamera;
  95021. /**
  95022. * Defines the list of key codes associated with the up action (increase heightOffset)
  95023. */
  95024. keysHeightOffsetIncr: number[];
  95025. /**
  95026. * Defines the list of key codes associated with the down action (decrease heightOffset)
  95027. */
  95028. keysHeightOffsetDecr: number[];
  95029. /**
  95030. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  95031. */
  95032. keysHeightOffsetModifierAlt: boolean;
  95033. /**
  95034. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  95035. */
  95036. keysHeightOffsetModifierCtrl: boolean;
  95037. /**
  95038. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  95039. */
  95040. keysHeightOffsetModifierShift: boolean;
  95041. /**
  95042. * Defines the list of key codes associated with the left action (increase rotationOffset)
  95043. */
  95044. keysRotationOffsetIncr: number[];
  95045. /**
  95046. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  95047. */
  95048. keysRotationOffsetDecr: number[];
  95049. /**
  95050. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  95051. */
  95052. keysRotationOffsetModifierAlt: boolean;
  95053. /**
  95054. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  95055. */
  95056. keysRotationOffsetModifierCtrl: boolean;
  95057. /**
  95058. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  95059. */
  95060. keysRotationOffsetModifierShift: boolean;
  95061. /**
  95062. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  95063. */
  95064. keysRadiusIncr: number[];
  95065. /**
  95066. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95067. */
  95068. keysRadiusDecr: number[];
  95069. /**
  95070. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95071. */
  95072. keysRadiusModifierAlt: boolean;
  95073. /**
  95074. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95075. */
  95076. keysRadiusModifierCtrl: boolean;
  95077. /**
  95078. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95079. */
  95080. keysRadiusModifierShift: boolean;
  95081. /**
  95082. * Defines the rate of change of heightOffset.
  95083. */
  95084. heightSensibility: number;
  95085. /**
  95086. * Defines the rate of change of rotationOffset.
  95087. */
  95088. rotationSensibility: number;
  95089. /**
  95090. * Defines the rate of change of radius.
  95091. */
  95092. radiusSensibility: number;
  95093. private _keys;
  95094. private _ctrlPressed;
  95095. private _altPressed;
  95096. private _shiftPressed;
  95097. private _onCanvasBlurObserver;
  95098. private _onKeyboardObserver;
  95099. private _engine;
  95100. private _scene;
  95101. /**
  95102. * Attach the input controls to a specific dom element to get the input from.
  95103. * @param element Defines the element the controls should be listened from
  95104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95105. */
  95106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95107. /**
  95108. * Detach the current controls from the specified dom element.
  95109. * @param element Defines the element to stop listening the inputs from
  95110. */
  95111. detachControl(element: Nullable<HTMLElement>): void;
  95112. /**
  95113. * Update the current camera state depending on the inputs that have been used this frame.
  95114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95115. */
  95116. checkInputs(): void;
  95117. /**
  95118. * Gets the class name of the current input.
  95119. * @returns the class name
  95120. */
  95121. getClassName(): string;
  95122. /**
  95123. * Get the friendly name associated with the input class.
  95124. * @returns the input friendly name
  95125. */
  95126. getSimpleName(): string;
  95127. /**
  95128. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95129. * allow modification of the heightOffset value.
  95130. */
  95131. private _modifierHeightOffset;
  95132. /**
  95133. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95134. * allow modification of the rotationOffset value.
  95135. */
  95136. private _modifierRotationOffset;
  95137. /**
  95138. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95139. * allow modification of the radius value.
  95140. */
  95141. private _modifierRadius;
  95142. }
  95143. }
  95144. declare module BABYLON {
  95145. interface FreeCameraInputsManager {
  95146. /**
  95147. * Add orientation input support to the input manager.
  95148. * @returns the current input manager
  95149. */
  95150. addDeviceOrientation(): FreeCameraInputsManager;
  95151. }
  95152. /**
  95153. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95154. * Screen rotation is taken into account.
  95155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95156. */
  95157. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95158. private _camera;
  95159. private _screenOrientationAngle;
  95160. private _constantTranform;
  95161. private _screenQuaternion;
  95162. private _alpha;
  95163. private _beta;
  95164. private _gamma;
  95165. /**
  95166. * Instantiates a new input
  95167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95168. */
  95169. constructor();
  95170. /**
  95171. * Define the camera controlled by the input.
  95172. */
  95173. camera: FreeCamera;
  95174. /**
  95175. * Attach the input controls to a specific dom element to get the input from.
  95176. * @param element Defines the element the controls should be listened from
  95177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95178. */
  95179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95180. private _orientationChanged;
  95181. private _deviceOrientation;
  95182. /**
  95183. * Detach the current controls from the specified dom element.
  95184. * @param element Defines the element to stop listening the inputs from
  95185. */
  95186. detachControl(element: Nullable<HTMLElement>): void;
  95187. /**
  95188. * Update the current camera state depending on the inputs that have been used this frame.
  95189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95190. */
  95191. checkInputs(): void;
  95192. /**
  95193. * Gets the class name of the current intput.
  95194. * @returns the class name
  95195. */
  95196. getClassName(): string;
  95197. /**
  95198. * Get the friendly name associated with the input class.
  95199. * @returns the input friendly name
  95200. */
  95201. getSimpleName(): string;
  95202. }
  95203. }
  95204. declare module BABYLON {
  95205. /**
  95206. * Manage the gamepad inputs to control a free camera.
  95207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95208. */
  95209. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  95210. /**
  95211. * Define the camera the input is attached to.
  95212. */
  95213. camera: FreeCamera;
  95214. /**
  95215. * Define the Gamepad controlling the input
  95216. */
  95217. gamepad: Nullable<Gamepad>;
  95218. /**
  95219. * Defines the gamepad rotation sensiblity.
  95220. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95221. */
  95222. gamepadAngularSensibility: number;
  95223. /**
  95224. * Defines the gamepad move sensiblity.
  95225. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95226. */
  95227. gamepadMoveSensibility: number;
  95228. private _onGamepadConnectedObserver;
  95229. private _onGamepadDisconnectedObserver;
  95230. private _cameraTransform;
  95231. private _deltaTransform;
  95232. private _vector3;
  95233. private _vector2;
  95234. /**
  95235. * Attach the input controls to a specific dom element to get the input from.
  95236. * @param element Defines the element the controls should be listened from
  95237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95238. */
  95239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95240. /**
  95241. * Detach the current controls from the specified dom element.
  95242. * @param element Defines the element to stop listening the inputs from
  95243. */
  95244. detachControl(element: Nullable<HTMLElement>): void;
  95245. /**
  95246. * Update the current camera state depending on the inputs that have been used this frame.
  95247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95248. */
  95249. checkInputs(): void;
  95250. /**
  95251. * Gets the class name of the current intput.
  95252. * @returns the class name
  95253. */
  95254. getClassName(): string;
  95255. /**
  95256. * Get the friendly name associated with the input class.
  95257. * @returns the input friendly name
  95258. */
  95259. getSimpleName(): string;
  95260. }
  95261. }
  95262. declare module BABYLON {
  95263. /**
  95264. * Defines the potential axis of a Joystick
  95265. */
  95266. export enum JoystickAxis {
  95267. /** X axis */
  95268. X = 0,
  95269. /** Y axis */
  95270. Y = 1,
  95271. /** Z axis */
  95272. Z = 2
  95273. }
  95274. /**
  95275. * Class used to define virtual joystick (used in touch mode)
  95276. */
  95277. export class VirtualJoystick {
  95278. /**
  95279. * Gets or sets a boolean indicating that left and right values must be inverted
  95280. */
  95281. reverseLeftRight: boolean;
  95282. /**
  95283. * Gets or sets a boolean indicating that up and down values must be inverted
  95284. */
  95285. reverseUpDown: boolean;
  95286. /**
  95287. * Gets the offset value for the position (ie. the change of the position value)
  95288. */
  95289. deltaPosition: Vector3;
  95290. /**
  95291. * Gets a boolean indicating if the virtual joystick was pressed
  95292. */
  95293. pressed: boolean;
  95294. /**
  95295. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95296. */
  95297. static Canvas: Nullable<HTMLCanvasElement>;
  95298. private static _globalJoystickIndex;
  95299. private static vjCanvasContext;
  95300. private static vjCanvasWidth;
  95301. private static vjCanvasHeight;
  95302. private static halfWidth;
  95303. private _action;
  95304. private _axisTargetedByLeftAndRight;
  95305. private _axisTargetedByUpAndDown;
  95306. private _joystickSensibility;
  95307. private _inversedSensibility;
  95308. private _joystickPointerID;
  95309. private _joystickColor;
  95310. private _joystickPointerPos;
  95311. private _joystickPreviousPointerPos;
  95312. private _joystickPointerStartPos;
  95313. private _deltaJoystickVector;
  95314. private _leftJoystick;
  95315. private _touches;
  95316. private _onPointerDownHandlerRef;
  95317. private _onPointerMoveHandlerRef;
  95318. private _onPointerUpHandlerRef;
  95319. private _onResize;
  95320. /**
  95321. * Creates a new virtual joystick
  95322. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95323. */
  95324. constructor(leftJoystick?: boolean);
  95325. /**
  95326. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95327. * @param newJoystickSensibility defines the new sensibility
  95328. */
  95329. setJoystickSensibility(newJoystickSensibility: number): void;
  95330. private _onPointerDown;
  95331. private _onPointerMove;
  95332. private _onPointerUp;
  95333. /**
  95334. * Change the color of the virtual joystick
  95335. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95336. */
  95337. setJoystickColor(newColor: string): void;
  95338. /**
  95339. * Defines a callback to call when the joystick is touched
  95340. * @param action defines the callback
  95341. */
  95342. setActionOnTouch(action: () => any): void;
  95343. /**
  95344. * Defines which axis you'd like to control for left & right
  95345. * @param axis defines the axis to use
  95346. */
  95347. setAxisForLeftRight(axis: JoystickAxis): void;
  95348. /**
  95349. * Defines which axis you'd like to control for up & down
  95350. * @param axis defines the axis to use
  95351. */
  95352. setAxisForUpDown(axis: JoystickAxis): void;
  95353. private _drawVirtualJoystick;
  95354. /**
  95355. * Release internal HTML canvas
  95356. */
  95357. releaseCanvas(): void;
  95358. }
  95359. }
  95360. declare module BABYLON {
  95361. interface FreeCameraInputsManager {
  95362. /**
  95363. * Add virtual joystick input support to the input manager.
  95364. * @returns the current input manager
  95365. */
  95366. addVirtualJoystick(): FreeCameraInputsManager;
  95367. }
  95368. /**
  95369. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95371. */
  95372. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95373. /**
  95374. * Defines the camera the input is attached to.
  95375. */
  95376. camera: FreeCamera;
  95377. private _leftjoystick;
  95378. private _rightjoystick;
  95379. /**
  95380. * Gets the left stick of the virtual joystick.
  95381. * @returns The virtual Joystick
  95382. */
  95383. getLeftJoystick(): VirtualJoystick;
  95384. /**
  95385. * Gets the right stick of the virtual joystick.
  95386. * @returns The virtual Joystick
  95387. */
  95388. getRightJoystick(): VirtualJoystick;
  95389. /**
  95390. * Update the current camera state depending on the inputs that have been used this frame.
  95391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95392. */
  95393. checkInputs(): void;
  95394. /**
  95395. * Attach the input controls to a specific dom element to get the input from.
  95396. * @param element Defines the element the controls should be listened from
  95397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95398. */
  95399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95400. /**
  95401. * Detach the current controls from the specified dom element.
  95402. * @param element Defines the element to stop listening the inputs from
  95403. */
  95404. detachControl(element: Nullable<HTMLElement>): void;
  95405. /**
  95406. * Gets the class name of the current intput.
  95407. * @returns the class name
  95408. */
  95409. getClassName(): string;
  95410. /**
  95411. * Get the friendly name associated with the input class.
  95412. * @returns the input friendly name
  95413. */
  95414. getSimpleName(): string;
  95415. }
  95416. }
  95417. declare module BABYLON {
  95418. /**
  95419. * This represents a FPS type of camera controlled by touch.
  95420. * This is like a universal camera minus the Gamepad controls.
  95421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95422. */
  95423. export class TouchCamera extends FreeCamera {
  95424. /**
  95425. * Defines the touch sensibility for rotation.
  95426. * The higher the faster.
  95427. */
  95428. touchAngularSensibility: number;
  95429. /**
  95430. * Defines the touch sensibility for move.
  95431. * The higher the faster.
  95432. */
  95433. touchMoveSensibility: number;
  95434. /**
  95435. * Instantiates a new touch camera.
  95436. * This represents a FPS type of camera controlled by touch.
  95437. * This is like a universal camera minus the Gamepad controls.
  95438. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95439. * @param name Define the name of the camera in the scene
  95440. * @param position Define the start position of the camera in the scene
  95441. * @param scene Define the scene the camera belongs to
  95442. */
  95443. constructor(name: string, position: Vector3, scene: Scene);
  95444. /**
  95445. * Gets the current object class name.
  95446. * @return the class name
  95447. */
  95448. getClassName(): string;
  95449. /** @hidden */
  95450. _setupInputs(): void;
  95451. }
  95452. }
  95453. declare module BABYLON {
  95454. /**
  95455. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95456. * being tilted forward or back and left or right.
  95457. */
  95458. export class DeviceOrientationCamera extends FreeCamera {
  95459. private _initialQuaternion;
  95460. private _quaternionCache;
  95461. /**
  95462. * Creates a new device orientation camera
  95463. * @param name The name of the camera
  95464. * @param position The start position camera
  95465. * @param scene The scene the camera belongs to
  95466. */
  95467. constructor(name: string, position: Vector3, scene: Scene);
  95468. /**
  95469. * Gets the current instance class name ("DeviceOrientationCamera").
  95470. * This helps avoiding instanceof at run time.
  95471. * @returns the class name
  95472. */
  95473. getClassName(): string;
  95474. /**
  95475. * @hidden
  95476. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95477. */
  95478. _checkInputs(): void;
  95479. /**
  95480. * Reset the camera to its default orientation on the specified axis only.
  95481. * @param axis The axis to reset
  95482. */
  95483. resetToCurrentRotation(axis?: Axis): void;
  95484. }
  95485. }
  95486. declare module BABYLON {
  95487. /**
  95488. * 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,
  95489. * which still works and will still be found in many Playgrounds.
  95490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95491. */
  95492. export class UniversalCamera extends TouchCamera {
  95493. /**
  95494. * Defines the gamepad rotation sensiblity.
  95495. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95496. */
  95497. gamepadAngularSensibility: number;
  95498. /**
  95499. * Defines the gamepad move sensiblity.
  95500. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95501. */
  95502. gamepadMoveSensibility: number;
  95503. /**
  95504. * 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,
  95505. * which still works and will still be found in many Playgrounds.
  95506. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95507. * @param name Define the name of the camera in the scene
  95508. * @param position Define the start position of the camera in the scene
  95509. * @param scene Define the scene the camera belongs to
  95510. */
  95511. constructor(name: string, position: Vector3, scene: Scene);
  95512. /**
  95513. * Gets the current object class name.
  95514. * @return the class name
  95515. */
  95516. getClassName(): string;
  95517. }
  95518. }
  95519. declare module BABYLON {
  95520. /**
  95521. * This represents a FPS type of camera. This is only here for back compat purpose.
  95522. * Please use the UniversalCamera instead as both are identical.
  95523. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95524. */
  95525. export class GamepadCamera extends UniversalCamera {
  95526. /**
  95527. * Instantiates a new Gamepad Camera
  95528. * This represents a FPS type of camera. This is only here for back compat purpose.
  95529. * Please use the UniversalCamera instead as both are identical.
  95530. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95531. * @param name Define the name of the camera in the scene
  95532. * @param position Define the start position of the camera in the scene
  95533. * @param scene Define the scene the camera belongs to
  95534. */
  95535. constructor(name: string, position: Vector3, scene: Scene);
  95536. /**
  95537. * Gets the current object class name.
  95538. * @return the class name
  95539. */
  95540. getClassName(): string;
  95541. }
  95542. }
  95543. declare module BABYLON {
  95544. /** @hidden */
  95545. export var passPixelShader: {
  95546. name: string;
  95547. shader: string;
  95548. };
  95549. }
  95550. declare module BABYLON {
  95551. /** @hidden */
  95552. export var passCubePixelShader: {
  95553. name: string;
  95554. shader: string;
  95555. };
  95556. }
  95557. declare module BABYLON {
  95558. /**
  95559. * PassPostProcess which produces an output the same as it's input
  95560. */
  95561. export class PassPostProcess extends PostProcess {
  95562. /**
  95563. * Creates the PassPostProcess
  95564. * @param name The name of the effect.
  95565. * @param options The required width/height ratio to downsize to before computing the render pass.
  95566. * @param camera The camera to apply the render pass to.
  95567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95568. * @param engine The engine which the post process will be applied. (default: current engine)
  95569. * @param reusable If the post process can be reused on the same frame. (default: false)
  95570. * @param textureType The type of texture to be used when performing the post processing.
  95571. * @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)
  95572. */
  95573. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95574. }
  95575. /**
  95576. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95577. */
  95578. export class PassCubePostProcess extends PostProcess {
  95579. private _face;
  95580. /**
  95581. * Gets or sets the cube face to display.
  95582. * * 0 is +X
  95583. * * 1 is -X
  95584. * * 2 is +Y
  95585. * * 3 is -Y
  95586. * * 4 is +Z
  95587. * * 5 is -Z
  95588. */
  95589. face: number;
  95590. /**
  95591. * Creates the PassCubePostProcess
  95592. * @param name The name of the effect.
  95593. * @param options The required width/height ratio to downsize to before computing the render pass.
  95594. * @param camera The camera to apply the render pass to.
  95595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95596. * @param engine The engine which the post process will be applied. (default: current engine)
  95597. * @param reusable If the post process can be reused on the same frame. (default: false)
  95598. * @param textureType The type of texture to be used when performing the post processing.
  95599. * @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)
  95600. */
  95601. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95602. }
  95603. }
  95604. declare module BABYLON {
  95605. /** @hidden */
  95606. export var anaglyphPixelShader: {
  95607. name: string;
  95608. shader: string;
  95609. };
  95610. }
  95611. declare module BABYLON {
  95612. /**
  95613. * Postprocess used to generate anaglyphic rendering
  95614. */
  95615. export class AnaglyphPostProcess extends PostProcess {
  95616. private _passedProcess;
  95617. /**
  95618. * Creates a new AnaglyphPostProcess
  95619. * @param name defines postprocess name
  95620. * @param options defines creation options or target ratio scale
  95621. * @param rigCameras defines cameras using this postprocess
  95622. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95623. * @param engine defines hosting engine
  95624. * @param reusable defines if the postprocess will be reused multiple times per frame
  95625. */
  95626. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95627. }
  95628. }
  95629. declare module BABYLON {
  95630. /**
  95631. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95632. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95633. */
  95634. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95635. /**
  95636. * Creates a new AnaglyphArcRotateCamera
  95637. * @param name defines camera name
  95638. * @param alpha defines alpha angle (in radians)
  95639. * @param beta defines beta angle (in radians)
  95640. * @param radius defines radius
  95641. * @param target defines camera target
  95642. * @param interaxialDistance defines distance between each color axis
  95643. * @param scene defines the hosting scene
  95644. */
  95645. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  95646. /**
  95647. * Gets camera class name
  95648. * @returns AnaglyphArcRotateCamera
  95649. */
  95650. getClassName(): string;
  95651. }
  95652. }
  95653. declare module BABYLON {
  95654. /**
  95655. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  95656. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95657. */
  95658. export class AnaglyphFreeCamera extends FreeCamera {
  95659. /**
  95660. * Creates a new AnaglyphFreeCamera
  95661. * @param name defines camera name
  95662. * @param position defines initial position
  95663. * @param interaxialDistance defines distance between each color axis
  95664. * @param scene defines the hosting scene
  95665. */
  95666. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95667. /**
  95668. * Gets camera class name
  95669. * @returns AnaglyphFreeCamera
  95670. */
  95671. getClassName(): string;
  95672. }
  95673. }
  95674. declare module BABYLON {
  95675. /**
  95676. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  95677. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95678. */
  95679. export class AnaglyphGamepadCamera extends GamepadCamera {
  95680. /**
  95681. * Creates a new AnaglyphGamepadCamera
  95682. * @param name defines camera name
  95683. * @param position defines initial position
  95684. * @param interaxialDistance defines distance between each color axis
  95685. * @param scene defines the hosting scene
  95686. */
  95687. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95688. /**
  95689. * Gets camera class name
  95690. * @returns AnaglyphGamepadCamera
  95691. */
  95692. getClassName(): string;
  95693. }
  95694. }
  95695. declare module BABYLON {
  95696. /**
  95697. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  95698. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95699. */
  95700. export class AnaglyphUniversalCamera extends UniversalCamera {
  95701. /**
  95702. * Creates a new AnaglyphUniversalCamera
  95703. * @param name defines camera name
  95704. * @param position defines initial position
  95705. * @param interaxialDistance defines distance between each color axis
  95706. * @param scene defines the hosting scene
  95707. */
  95708. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95709. /**
  95710. * Gets camera class name
  95711. * @returns AnaglyphUniversalCamera
  95712. */
  95713. getClassName(): string;
  95714. }
  95715. }
  95716. declare module BABYLON {
  95717. /** @hidden */
  95718. export var stereoscopicInterlacePixelShader: {
  95719. name: string;
  95720. shader: string;
  95721. };
  95722. }
  95723. declare module BABYLON {
  95724. /**
  95725. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  95726. */
  95727. export class StereoscopicInterlacePostProcess extends PostProcess {
  95728. private _stepSize;
  95729. private _passedProcess;
  95730. /**
  95731. * Initializes a StereoscopicInterlacePostProcess
  95732. * @param name The name of the effect.
  95733. * @param rigCameras The rig cameras to be appled to the post process
  95734. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  95735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95736. * @param engine The engine which the post process will be applied. (default: current engine)
  95737. * @param reusable If the post process can be reused on the same frame. (default: false)
  95738. */
  95739. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  95740. }
  95741. }
  95742. declare module BABYLON {
  95743. /**
  95744. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  95745. * @see http://doc.babylonjs.com/features/cameras
  95746. */
  95747. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  95748. /**
  95749. * Creates a new StereoscopicArcRotateCamera
  95750. * @param name defines camera name
  95751. * @param alpha defines alpha angle (in radians)
  95752. * @param beta defines beta angle (in radians)
  95753. * @param radius defines radius
  95754. * @param target defines camera target
  95755. * @param interaxialDistance defines distance between each color axis
  95756. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95757. * @param scene defines the hosting scene
  95758. */
  95759. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95760. /**
  95761. * Gets camera class name
  95762. * @returns StereoscopicArcRotateCamera
  95763. */
  95764. getClassName(): string;
  95765. }
  95766. }
  95767. declare module BABYLON {
  95768. /**
  95769. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  95770. * @see http://doc.babylonjs.com/features/cameras
  95771. */
  95772. export class StereoscopicFreeCamera extends FreeCamera {
  95773. /**
  95774. * Creates a new StereoscopicFreeCamera
  95775. * @param name defines camera name
  95776. * @param position defines initial position
  95777. * @param interaxialDistance defines distance between each color axis
  95778. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95779. * @param scene defines the hosting scene
  95780. */
  95781. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95782. /**
  95783. * Gets camera class name
  95784. * @returns StereoscopicFreeCamera
  95785. */
  95786. getClassName(): string;
  95787. }
  95788. }
  95789. declare module BABYLON {
  95790. /**
  95791. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  95792. * @see http://doc.babylonjs.com/features/cameras
  95793. */
  95794. export class StereoscopicGamepadCamera extends GamepadCamera {
  95795. /**
  95796. * Creates a new StereoscopicGamepadCamera
  95797. * @param name defines camera name
  95798. * @param position defines initial position
  95799. * @param interaxialDistance defines distance between each color axis
  95800. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95801. * @param scene defines the hosting scene
  95802. */
  95803. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95804. /**
  95805. * Gets camera class name
  95806. * @returns StereoscopicGamepadCamera
  95807. */
  95808. getClassName(): string;
  95809. }
  95810. }
  95811. declare module BABYLON {
  95812. /**
  95813. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  95814. * @see http://doc.babylonjs.com/features/cameras
  95815. */
  95816. export class StereoscopicUniversalCamera extends UniversalCamera {
  95817. /**
  95818. * Creates a new StereoscopicUniversalCamera
  95819. * @param name defines camera name
  95820. * @param position defines initial position
  95821. * @param interaxialDistance defines distance between each color axis
  95822. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95823. * @param scene defines the hosting scene
  95824. */
  95825. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95826. /**
  95827. * Gets camera class name
  95828. * @returns StereoscopicUniversalCamera
  95829. */
  95830. getClassName(): string;
  95831. }
  95832. }
  95833. declare module BABYLON {
  95834. /**
  95835. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95836. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95837. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95838. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95839. */
  95840. export class VirtualJoysticksCamera extends FreeCamera {
  95841. /**
  95842. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  95843. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95844. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95845. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95846. * @param name Define the name of the camera in the scene
  95847. * @param position Define the start position of the camera in the scene
  95848. * @param scene Define the scene the camera belongs to
  95849. */
  95850. constructor(name: string, position: Vector3, scene: Scene);
  95851. /**
  95852. * Gets the current object class name.
  95853. * @return the class name
  95854. */
  95855. getClassName(): string;
  95856. }
  95857. }
  95858. declare module BABYLON {
  95859. /**
  95860. * This represents all the required metrics to create a VR camera.
  95861. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  95862. */
  95863. export class VRCameraMetrics {
  95864. /**
  95865. * Define the horizontal resolution off the screen.
  95866. */
  95867. hResolution: number;
  95868. /**
  95869. * Define the vertical resolution off the screen.
  95870. */
  95871. vResolution: number;
  95872. /**
  95873. * Define the horizontal screen size.
  95874. */
  95875. hScreenSize: number;
  95876. /**
  95877. * Define the vertical screen size.
  95878. */
  95879. vScreenSize: number;
  95880. /**
  95881. * Define the vertical screen center position.
  95882. */
  95883. vScreenCenter: number;
  95884. /**
  95885. * Define the distance of the eyes to the screen.
  95886. */
  95887. eyeToScreenDistance: number;
  95888. /**
  95889. * Define the distance between both lenses
  95890. */
  95891. lensSeparationDistance: number;
  95892. /**
  95893. * Define the distance between both viewer's eyes.
  95894. */
  95895. interpupillaryDistance: number;
  95896. /**
  95897. * Define the distortion factor of the VR postprocess.
  95898. * Please, touch with care.
  95899. */
  95900. distortionK: number[];
  95901. /**
  95902. * Define the chromatic aberration correction factors for the VR post process.
  95903. */
  95904. chromaAbCorrection: number[];
  95905. /**
  95906. * Define the scale factor of the post process.
  95907. * The smaller the better but the slower.
  95908. */
  95909. postProcessScaleFactor: number;
  95910. /**
  95911. * Define an offset for the lens center.
  95912. */
  95913. lensCenterOffset: number;
  95914. /**
  95915. * Define if the current vr camera should compensate the distortion of the lense or not.
  95916. */
  95917. compensateDistortion: boolean;
  95918. /**
  95919. * Gets the rendering aspect ratio based on the provided resolutions.
  95920. */
  95921. readonly aspectRatio: number;
  95922. /**
  95923. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  95924. */
  95925. readonly aspectRatioFov: number;
  95926. /**
  95927. * @hidden
  95928. */
  95929. readonly leftHMatrix: Matrix;
  95930. /**
  95931. * @hidden
  95932. */
  95933. readonly rightHMatrix: Matrix;
  95934. /**
  95935. * @hidden
  95936. */
  95937. readonly leftPreViewMatrix: Matrix;
  95938. /**
  95939. * @hidden
  95940. */
  95941. readonly rightPreViewMatrix: Matrix;
  95942. /**
  95943. * Get the default VRMetrics based on the most generic setup.
  95944. * @returns the default vr metrics
  95945. */
  95946. static GetDefault(): VRCameraMetrics;
  95947. }
  95948. }
  95949. declare module BABYLON {
  95950. /** @hidden */
  95951. export var vrDistortionCorrectionPixelShader: {
  95952. name: string;
  95953. shader: string;
  95954. };
  95955. }
  95956. declare module BABYLON {
  95957. /**
  95958. * VRDistortionCorrectionPostProcess used for mobile VR
  95959. */
  95960. export class VRDistortionCorrectionPostProcess extends PostProcess {
  95961. private _isRightEye;
  95962. private _distortionFactors;
  95963. private _postProcessScaleFactor;
  95964. private _lensCenterOffset;
  95965. private _scaleIn;
  95966. private _scaleFactor;
  95967. private _lensCenter;
  95968. /**
  95969. * Initializes the VRDistortionCorrectionPostProcess
  95970. * @param name The name of the effect.
  95971. * @param camera The camera to apply the render pass to.
  95972. * @param isRightEye If this is for the right eye distortion
  95973. * @param vrMetrics All the required metrics for the VR camera
  95974. */
  95975. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95976. }
  95977. }
  95978. declare module BABYLON {
  95979. /**
  95980. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95981. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95982. */
  95983. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95984. /**
  95985. * Creates a new VRDeviceOrientationArcRotateCamera
  95986. * @param name defines camera name
  95987. * @param alpha defines the camera rotation along the logitudinal axis
  95988. * @param beta defines the camera rotation along the latitudinal axis
  95989. * @param radius defines the camera distance from its target
  95990. * @param target defines the camera target
  95991. * @param scene defines the scene the camera belongs to
  95992. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95993. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95994. */
  95995. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95996. /**
  95997. * Gets camera class name
  95998. * @returns VRDeviceOrientationArcRotateCamera
  95999. */
  96000. getClassName(): string;
  96001. }
  96002. }
  96003. declare module BABYLON {
  96004. /**
  96005. * Camera used to simulate VR rendering (based on FreeCamera)
  96006. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96007. */
  96008. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  96009. /**
  96010. * Creates a new VRDeviceOrientationFreeCamera
  96011. * @param name defines camera name
  96012. * @param position defines the start position of the camera
  96013. * @param scene defines the scene the camera belongs to
  96014. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96015. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96016. */
  96017. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96018. /**
  96019. * Gets camera class name
  96020. * @returns VRDeviceOrientationFreeCamera
  96021. */
  96022. getClassName(): string;
  96023. }
  96024. }
  96025. declare module BABYLON {
  96026. /**
  96027. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  96028. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  96029. */
  96030. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  96031. /**
  96032. * Creates a new VRDeviceOrientationGamepadCamera
  96033. * @param name defines camera name
  96034. * @param position defines the start position of the camera
  96035. * @param scene defines the scene the camera belongs to
  96036. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  96037. * @param vrCameraMetrics defines the vr metrics associated to the camera
  96038. */
  96039. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  96040. /**
  96041. * Gets camera class name
  96042. * @returns VRDeviceOrientationGamepadCamera
  96043. */
  96044. getClassName(): string;
  96045. }
  96046. }
  96047. declare module BABYLON {
  96048. /**
  96049. * Defines supported buttons for XBox360 compatible gamepads
  96050. */
  96051. export enum Xbox360Button {
  96052. /** A */
  96053. A = 0,
  96054. /** B */
  96055. B = 1,
  96056. /** X */
  96057. X = 2,
  96058. /** Y */
  96059. Y = 3,
  96060. /** Start */
  96061. Start = 4,
  96062. /** Back */
  96063. Back = 5,
  96064. /** Left button */
  96065. LB = 6,
  96066. /** Right button */
  96067. RB = 7,
  96068. /** Left stick */
  96069. LeftStick = 8,
  96070. /** Right stick */
  96071. RightStick = 9
  96072. }
  96073. /** Defines values for XBox360 DPad */
  96074. export enum Xbox360Dpad {
  96075. /** Up */
  96076. Up = 0,
  96077. /** Down */
  96078. Down = 1,
  96079. /** Left */
  96080. Left = 2,
  96081. /** Right */
  96082. Right = 3
  96083. }
  96084. /**
  96085. * Defines a XBox360 gamepad
  96086. */
  96087. export class Xbox360Pad extends Gamepad {
  96088. private _leftTrigger;
  96089. private _rightTrigger;
  96090. private _onlefttriggerchanged;
  96091. private _onrighttriggerchanged;
  96092. private _onbuttondown;
  96093. private _onbuttonup;
  96094. private _ondpaddown;
  96095. private _ondpadup;
  96096. /** Observable raised when a button is pressed */
  96097. onButtonDownObservable: Observable<Xbox360Button>;
  96098. /** Observable raised when a button is released */
  96099. onButtonUpObservable: Observable<Xbox360Button>;
  96100. /** Observable raised when a pad is pressed */
  96101. onPadDownObservable: Observable<Xbox360Dpad>;
  96102. /** Observable raised when a pad is released */
  96103. onPadUpObservable: Observable<Xbox360Dpad>;
  96104. private _buttonA;
  96105. private _buttonB;
  96106. private _buttonX;
  96107. private _buttonY;
  96108. private _buttonBack;
  96109. private _buttonStart;
  96110. private _buttonLB;
  96111. private _buttonRB;
  96112. private _buttonLeftStick;
  96113. private _buttonRightStick;
  96114. private _dPadUp;
  96115. private _dPadDown;
  96116. private _dPadLeft;
  96117. private _dPadRight;
  96118. private _isXboxOnePad;
  96119. /**
  96120. * Creates a new XBox360 gamepad object
  96121. * @param id defines the id of this gamepad
  96122. * @param index defines its index
  96123. * @param gamepad defines the internal HTML gamepad object
  96124. * @param xboxOne defines if it is a XBox One gamepad
  96125. */
  96126. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96127. /**
  96128. * Defines the callback to call when left trigger is pressed
  96129. * @param callback defines the callback to use
  96130. */
  96131. onlefttriggerchanged(callback: (value: number) => void): void;
  96132. /**
  96133. * Defines the callback to call when right trigger is pressed
  96134. * @param callback defines the callback to use
  96135. */
  96136. onrighttriggerchanged(callback: (value: number) => void): void;
  96137. /**
  96138. * Gets the left trigger value
  96139. */
  96140. /**
  96141. * Sets the left trigger value
  96142. */
  96143. leftTrigger: number;
  96144. /**
  96145. * Gets the right trigger value
  96146. */
  96147. /**
  96148. * Sets the right trigger value
  96149. */
  96150. rightTrigger: number;
  96151. /**
  96152. * Defines the callback to call when a button is pressed
  96153. * @param callback defines the callback to use
  96154. */
  96155. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96156. /**
  96157. * Defines the callback to call when a button is released
  96158. * @param callback defines the callback to use
  96159. */
  96160. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96161. /**
  96162. * Defines the callback to call when a pad is pressed
  96163. * @param callback defines the callback to use
  96164. */
  96165. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96166. /**
  96167. * Defines the callback to call when a pad is released
  96168. * @param callback defines the callback to use
  96169. */
  96170. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96171. private _setButtonValue;
  96172. private _setDPadValue;
  96173. /**
  96174. * Gets the value of the `A` button
  96175. */
  96176. /**
  96177. * Sets the value of the `A` button
  96178. */
  96179. buttonA: number;
  96180. /**
  96181. * Gets the value of the `B` button
  96182. */
  96183. /**
  96184. * Sets the value of the `B` button
  96185. */
  96186. buttonB: number;
  96187. /**
  96188. * Gets the value of the `X` button
  96189. */
  96190. /**
  96191. * Sets the value of the `X` button
  96192. */
  96193. buttonX: number;
  96194. /**
  96195. * Gets the value of the `Y` button
  96196. */
  96197. /**
  96198. * Sets the value of the `Y` button
  96199. */
  96200. buttonY: number;
  96201. /**
  96202. * Gets the value of the `Start` button
  96203. */
  96204. /**
  96205. * Sets the value of the `Start` button
  96206. */
  96207. buttonStart: number;
  96208. /**
  96209. * Gets the value of the `Back` button
  96210. */
  96211. /**
  96212. * Sets the value of the `Back` button
  96213. */
  96214. buttonBack: number;
  96215. /**
  96216. * Gets the value of the `Left` button
  96217. */
  96218. /**
  96219. * Sets the value of the `Left` button
  96220. */
  96221. buttonLB: number;
  96222. /**
  96223. * Gets the value of the `Right` button
  96224. */
  96225. /**
  96226. * Sets the value of the `Right` button
  96227. */
  96228. buttonRB: number;
  96229. /**
  96230. * Gets the value of the Left joystick
  96231. */
  96232. /**
  96233. * Sets the value of the Left joystick
  96234. */
  96235. buttonLeftStick: number;
  96236. /**
  96237. * Gets the value of the Right joystick
  96238. */
  96239. /**
  96240. * Sets the value of the Right joystick
  96241. */
  96242. buttonRightStick: number;
  96243. /**
  96244. * Gets the value of D-pad up
  96245. */
  96246. /**
  96247. * Sets the value of D-pad up
  96248. */
  96249. dPadUp: number;
  96250. /**
  96251. * Gets the value of D-pad down
  96252. */
  96253. /**
  96254. * Sets the value of D-pad down
  96255. */
  96256. dPadDown: number;
  96257. /**
  96258. * Gets the value of D-pad left
  96259. */
  96260. /**
  96261. * Sets the value of D-pad left
  96262. */
  96263. dPadLeft: number;
  96264. /**
  96265. * Gets the value of D-pad right
  96266. */
  96267. /**
  96268. * Sets the value of D-pad right
  96269. */
  96270. dPadRight: number;
  96271. /**
  96272. * Force the gamepad to synchronize with device values
  96273. */
  96274. update(): void;
  96275. /**
  96276. * Disposes the gamepad
  96277. */
  96278. dispose(): void;
  96279. }
  96280. }
  96281. declare module BABYLON {
  96282. /**
  96283. * Base class of materials working in push mode in babylon JS
  96284. * @hidden
  96285. */
  96286. export class PushMaterial extends Material {
  96287. protected _activeEffect: Effect;
  96288. protected _normalMatrix: Matrix;
  96289. /**
  96290. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96291. * This means that the material can keep using a previous shader while a new one is being compiled.
  96292. * This is mostly used when shader parallel compilation is supported (true by default)
  96293. */
  96294. allowShaderHotSwapping: boolean;
  96295. constructor(name: string, scene: Scene);
  96296. getEffect(): Effect;
  96297. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96298. /**
  96299. * Binds the given world matrix to the active effect
  96300. *
  96301. * @param world the matrix to bind
  96302. */
  96303. bindOnlyWorldMatrix(world: Matrix): void;
  96304. /**
  96305. * Binds the given normal matrix to the active effect
  96306. *
  96307. * @param normalMatrix the matrix to bind
  96308. */
  96309. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96310. bind(world: Matrix, mesh?: Mesh): void;
  96311. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96312. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96313. }
  96314. }
  96315. declare module BABYLON {
  96316. /**
  96317. * This groups all the flags used to control the materials channel.
  96318. */
  96319. export class MaterialFlags {
  96320. private static _DiffuseTextureEnabled;
  96321. /**
  96322. * Are diffuse textures enabled in the application.
  96323. */
  96324. static DiffuseTextureEnabled: boolean;
  96325. private static _AmbientTextureEnabled;
  96326. /**
  96327. * Are ambient textures enabled in the application.
  96328. */
  96329. static AmbientTextureEnabled: boolean;
  96330. private static _OpacityTextureEnabled;
  96331. /**
  96332. * Are opacity textures enabled in the application.
  96333. */
  96334. static OpacityTextureEnabled: boolean;
  96335. private static _ReflectionTextureEnabled;
  96336. /**
  96337. * Are reflection textures enabled in the application.
  96338. */
  96339. static ReflectionTextureEnabled: boolean;
  96340. private static _EmissiveTextureEnabled;
  96341. /**
  96342. * Are emissive textures enabled in the application.
  96343. */
  96344. static EmissiveTextureEnabled: boolean;
  96345. private static _SpecularTextureEnabled;
  96346. /**
  96347. * Are specular textures enabled in the application.
  96348. */
  96349. static SpecularTextureEnabled: boolean;
  96350. private static _BumpTextureEnabled;
  96351. /**
  96352. * Are bump textures enabled in the application.
  96353. */
  96354. static BumpTextureEnabled: boolean;
  96355. private static _LightmapTextureEnabled;
  96356. /**
  96357. * Are lightmap textures enabled in the application.
  96358. */
  96359. static LightmapTextureEnabled: boolean;
  96360. private static _RefractionTextureEnabled;
  96361. /**
  96362. * Are refraction textures enabled in the application.
  96363. */
  96364. static RefractionTextureEnabled: boolean;
  96365. private static _ColorGradingTextureEnabled;
  96366. /**
  96367. * Are color grading textures enabled in the application.
  96368. */
  96369. static ColorGradingTextureEnabled: boolean;
  96370. private static _FresnelEnabled;
  96371. /**
  96372. * Are fresnels enabled in the application.
  96373. */
  96374. static FresnelEnabled: boolean;
  96375. private static _ClearCoatTextureEnabled;
  96376. /**
  96377. * Are clear coat textures enabled in the application.
  96378. */
  96379. static ClearCoatTextureEnabled: boolean;
  96380. private static _ClearCoatBumpTextureEnabled;
  96381. /**
  96382. * Are clear coat bump textures enabled in the application.
  96383. */
  96384. static ClearCoatBumpTextureEnabled: boolean;
  96385. private static _ClearCoatTintTextureEnabled;
  96386. /**
  96387. * Are clear coat tint textures enabled in the application.
  96388. */
  96389. static ClearCoatTintTextureEnabled: boolean;
  96390. private static _SheenTextureEnabled;
  96391. /**
  96392. * Are sheen textures enabled in the application.
  96393. */
  96394. static SheenTextureEnabled: boolean;
  96395. private static _AnisotropicTextureEnabled;
  96396. /**
  96397. * Are anisotropic textures enabled in the application.
  96398. */
  96399. static AnisotropicTextureEnabled: boolean;
  96400. }
  96401. }
  96402. declare module BABYLON {
  96403. /** @hidden */
  96404. export var defaultFragmentDeclaration: {
  96405. name: string;
  96406. shader: string;
  96407. };
  96408. }
  96409. declare module BABYLON {
  96410. /** @hidden */
  96411. export var defaultUboDeclaration: {
  96412. name: string;
  96413. shader: string;
  96414. };
  96415. }
  96416. declare module BABYLON {
  96417. /** @hidden */
  96418. export var lightFragmentDeclaration: {
  96419. name: string;
  96420. shader: string;
  96421. };
  96422. }
  96423. declare module BABYLON {
  96424. /** @hidden */
  96425. export var lightUboDeclaration: {
  96426. name: string;
  96427. shader: string;
  96428. };
  96429. }
  96430. declare module BABYLON {
  96431. /** @hidden */
  96432. export var lightsFragmentFunctions: {
  96433. name: string;
  96434. shader: string;
  96435. };
  96436. }
  96437. declare module BABYLON {
  96438. /** @hidden */
  96439. export var shadowsFragmentFunctions: {
  96440. name: string;
  96441. shader: string;
  96442. };
  96443. }
  96444. declare module BABYLON {
  96445. /** @hidden */
  96446. export var fresnelFunction: {
  96447. name: string;
  96448. shader: string;
  96449. };
  96450. }
  96451. declare module BABYLON {
  96452. /** @hidden */
  96453. export var reflectionFunction: {
  96454. name: string;
  96455. shader: string;
  96456. };
  96457. }
  96458. declare module BABYLON {
  96459. /** @hidden */
  96460. export var bumpFragmentFunctions: {
  96461. name: string;
  96462. shader: string;
  96463. };
  96464. }
  96465. declare module BABYLON {
  96466. /** @hidden */
  96467. export var logDepthDeclaration: {
  96468. name: string;
  96469. shader: string;
  96470. };
  96471. }
  96472. declare module BABYLON {
  96473. /** @hidden */
  96474. export var bumpFragment: {
  96475. name: string;
  96476. shader: string;
  96477. };
  96478. }
  96479. declare module BABYLON {
  96480. /** @hidden */
  96481. export var depthPrePass: {
  96482. name: string;
  96483. shader: string;
  96484. };
  96485. }
  96486. declare module BABYLON {
  96487. /** @hidden */
  96488. export var lightFragment: {
  96489. name: string;
  96490. shader: string;
  96491. };
  96492. }
  96493. declare module BABYLON {
  96494. /** @hidden */
  96495. export var logDepthFragment: {
  96496. name: string;
  96497. shader: string;
  96498. };
  96499. }
  96500. declare module BABYLON {
  96501. /** @hidden */
  96502. export var defaultPixelShader: {
  96503. name: string;
  96504. shader: string;
  96505. };
  96506. }
  96507. declare module BABYLON {
  96508. /** @hidden */
  96509. export var defaultVertexDeclaration: {
  96510. name: string;
  96511. shader: string;
  96512. };
  96513. }
  96514. declare module BABYLON {
  96515. /** @hidden */
  96516. export var bumpVertexDeclaration: {
  96517. name: string;
  96518. shader: string;
  96519. };
  96520. }
  96521. declare module BABYLON {
  96522. /** @hidden */
  96523. export var bumpVertex: {
  96524. name: string;
  96525. shader: string;
  96526. };
  96527. }
  96528. declare module BABYLON {
  96529. /** @hidden */
  96530. export var fogVertex: {
  96531. name: string;
  96532. shader: string;
  96533. };
  96534. }
  96535. declare module BABYLON {
  96536. /** @hidden */
  96537. export var shadowsVertex: {
  96538. name: string;
  96539. shader: string;
  96540. };
  96541. }
  96542. declare module BABYLON {
  96543. /** @hidden */
  96544. export var pointCloudVertex: {
  96545. name: string;
  96546. shader: string;
  96547. };
  96548. }
  96549. declare module BABYLON {
  96550. /** @hidden */
  96551. export var logDepthVertex: {
  96552. name: string;
  96553. shader: string;
  96554. };
  96555. }
  96556. declare module BABYLON {
  96557. /** @hidden */
  96558. export var defaultVertexShader: {
  96559. name: string;
  96560. shader: string;
  96561. };
  96562. }
  96563. declare module BABYLON {
  96564. /** @hidden */
  96565. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96566. MAINUV1: boolean;
  96567. MAINUV2: boolean;
  96568. DIFFUSE: boolean;
  96569. DIFFUSEDIRECTUV: number;
  96570. AMBIENT: boolean;
  96571. AMBIENTDIRECTUV: number;
  96572. OPACITY: boolean;
  96573. OPACITYDIRECTUV: number;
  96574. OPACITYRGB: boolean;
  96575. REFLECTION: boolean;
  96576. EMISSIVE: boolean;
  96577. EMISSIVEDIRECTUV: number;
  96578. SPECULAR: boolean;
  96579. SPECULARDIRECTUV: number;
  96580. BUMP: boolean;
  96581. BUMPDIRECTUV: number;
  96582. PARALLAX: boolean;
  96583. PARALLAXOCCLUSION: boolean;
  96584. SPECULAROVERALPHA: boolean;
  96585. CLIPPLANE: boolean;
  96586. CLIPPLANE2: boolean;
  96587. CLIPPLANE3: boolean;
  96588. CLIPPLANE4: boolean;
  96589. ALPHATEST: boolean;
  96590. DEPTHPREPASS: boolean;
  96591. ALPHAFROMDIFFUSE: boolean;
  96592. POINTSIZE: boolean;
  96593. FOG: boolean;
  96594. SPECULARTERM: boolean;
  96595. DIFFUSEFRESNEL: boolean;
  96596. OPACITYFRESNEL: boolean;
  96597. REFLECTIONFRESNEL: boolean;
  96598. REFRACTIONFRESNEL: boolean;
  96599. EMISSIVEFRESNEL: boolean;
  96600. FRESNEL: boolean;
  96601. NORMAL: boolean;
  96602. UV1: boolean;
  96603. UV2: boolean;
  96604. VERTEXCOLOR: boolean;
  96605. VERTEXALPHA: boolean;
  96606. NUM_BONE_INFLUENCERS: number;
  96607. BonesPerMesh: number;
  96608. BONETEXTURE: boolean;
  96609. INSTANCES: boolean;
  96610. GLOSSINESS: boolean;
  96611. ROUGHNESS: boolean;
  96612. EMISSIVEASILLUMINATION: boolean;
  96613. LINKEMISSIVEWITHDIFFUSE: boolean;
  96614. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96615. LIGHTMAP: boolean;
  96616. LIGHTMAPDIRECTUV: number;
  96617. OBJECTSPACE_NORMALMAP: boolean;
  96618. USELIGHTMAPASSHADOWMAP: boolean;
  96619. REFLECTIONMAP_3D: boolean;
  96620. REFLECTIONMAP_SPHERICAL: boolean;
  96621. REFLECTIONMAP_PLANAR: boolean;
  96622. REFLECTIONMAP_CUBIC: boolean;
  96623. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96624. REFLECTIONMAP_PROJECTION: boolean;
  96625. REFLECTIONMAP_SKYBOX: boolean;
  96626. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96627. REFLECTIONMAP_EXPLICIT: boolean;
  96628. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96629. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96630. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96631. INVERTCUBICMAP: boolean;
  96632. LOGARITHMICDEPTH: boolean;
  96633. REFRACTION: boolean;
  96634. REFRACTIONMAP_3D: boolean;
  96635. REFLECTIONOVERALPHA: boolean;
  96636. TWOSIDEDLIGHTING: boolean;
  96637. SHADOWFLOAT: boolean;
  96638. MORPHTARGETS: boolean;
  96639. MORPHTARGETS_NORMAL: boolean;
  96640. MORPHTARGETS_TANGENT: boolean;
  96641. NUM_MORPH_INFLUENCERS: number;
  96642. NONUNIFORMSCALING: boolean;
  96643. PREMULTIPLYALPHA: boolean;
  96644. IMAGEPROCESSING: boolean;
  96645. VIGNETTE: boolean;
  96646. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96647. VIGNETTEBLENDMODEOPAQUE: boolean;
  96648. TONEMAPPING: boolean;
  96649. TONEMAPPING_ACES: boolean;
  96650. CONTRAST: boolean;
  96651. COLORCURVES: boolean;
  96652. COLORGRADING: boolean;
  96653. COLORGRADING3D: boolean;
  96654. SAMPLER3DGREENDEPTH: boolean;
  96655. SAMPLER3DBGRMAP: boolean;
  96656. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96657. /**
  96658. * If the reflection texture on this material is in linear color space
  96659. * @hidden
  96660. */
  96661. IS_REFLECTION_LINEAR: boolean;
  96662. /**
  96663. * If the refraction texture on this material is in linear color space
  96664. * @hidden
  96665. */
  96666. IS_REFRACTION_LINEAR: boolean;
  96667. EXPOSURE: boolean;
  96668. constructor();
  96669. setReflectionMode(modeToEnable: string): void;
  96670. }
  96671. /**
  96672. * This is the default material used in Babylon. It is the best trade off between quality
  96673. * and performances.
  96674. * @see http://doc.babylonjs.com/babylon101/materials
  96675. */
  96676. export class StandardMaterial extends PushMaterial {
  96677. private _diffuseTexture;
  96678. /**
  96679. * The basic texture of the material as viewed under a light.
  96680. */
  96681. diffuseTexture: Nullable<BaseTexture>;
  96682. private _ambientTexture;
  96683. /**
  96684. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96685. */
  96686. ambientTexture: Nullable<BaseTexture>;
  96687. private _opacityTexture;
  96688. /**
  96689. * Define the transparency of the material from a texture.
  96690. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96691. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96692. */
  96693. opacityTexture: Nullable<BaseTexture>;
  96694. private _reflectionTexture;
  96695. /**
  96696. * Define the texture used to display the reflection.
  96697. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96698. */
  96699. reflectionTexture: Nullable<BaseTexture>;
  96700. private _emissiveTexture;
  96701. /**
  96702. * Define texture of the material as if self lit.
  96703. * This will be mixed in the final result even in the absence of light.
  96704. */
  96705. emissiveTexture: Nullable<BaseTexture>;
  96706. private _specularTexture;
  96707. /**
  96708. * Define how the color and intensity of the highlight given by the light in the material.
  96709. */
  96710. specularTexture: Nullable<BaseTexture>;
  96711. private _bumpTexture;
  96712. /**
  96713. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96714. * 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.
  96715. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96716. */
  96717. bumpTexture: Nullable<BaseTexture>;
  96718. private _lightmapTexture;
  96719. /**
  96720. * Complex lighting can be computationally expensive to compute at runtime.
  96721. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96722. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96723. */
  96724. lightmapTexture: Nullable<BaseTexture>;
  96725. private _refractionTexture;
  96726. /**
  96727. * Define the texture used to display the refraction.
  96728. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96729. */
  96730. refractionTexture: Nullable<BaseTexture>;
  96731. /**
  96732. * The color of the material lit by the environmental background lighting.
  96733. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96734. */
  96735. ambientColor: Color3;
  96736. /**
  96737. * The basic color of the material as viewed under a light.
  96738. */
  96739. diffuseColor: Color3;
  96740. /**
  96741. * Define how the color and intensity of the highlight given by the light in the material.
  96742. */
  96743. specularColor: Color3;
  96744. /**
  96745. * Define the color of the material as if self lit.
  96746. * This will be mixed in the final result even in the absence of light.
  96747. */
  96748. emissiveColor: Color3;
  96749. /**
  96750. * Defines how sharp are the highlights in the material.
  96751. * The bigger the value the sharper giving a more glossy feeling to the result.
  96752. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96753. */
  96754. specularPower: number;
  96755. private _useAlphaFromDiffuseTexture;
  96756. /**
  96757. * Does the transparency come from the diffuse texture alpha channel.
  96758. */
  96759. useAlphaFromDiffuseTexture: boolean;
  96760. private _useEmissiveAsIllumination;
  96761. /**
  96762. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96763. */
  96764. useEmissiveAsIllumination: boolean;
  96765. private _linkEmissiveWithDiffuse;
  96766. /**
  96767. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96768. * the emissive level when the final color is close to one.
  96769. */
  96770. linkEmissiveWithDiffuse: boolean;
  96771. private _useSpecularOverAlpha;
  96772. /**
  96773. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96774. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96775. */
  96776. useSpecularOverAlpha: boolean;
  96777. private _useReflectionOverAlpha;
  96778. /**
  96779. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96780. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96781. */
  96782. useReflectionOverAlpha: boolean;
  96783. private _disableLighting;
  96784. /**
  96785. * Does lights from the scene impacts this material.
  96786. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96787. */
  96788. disableLighting: boolean;
  96789. private _useObjectSpaceNormalMap;
  96790. /**
  96791. * Allows using an object space normal map (instead of tangent space).
  96792. */
  96793. useObjectSpaceNormalMap: boolean;
  96794. private _useParallax;
  96795. /**
  96796. * Is parallax enabled or not.
  96797. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96798. */
  96799. useParallax: boolean;
  96800. private _useParallaxOcclusion;
  96801. /**
  96802. * Is parallax occlusion enabled or not.
  96803. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96804. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96805. */
  96806. useParallaxOcclusion: boolean;
  96807. /**
  96808. * 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.
  96809. */
  96810. parallaxScaleBias: number;
  96811. private _roughness;
  96812. /**
  96813. * Helps to define how blurry the reflections should appears in the material.
  96814. */
  96815. roughness: number;
  96816. /**
  96817. * In case of refraction, define the value of the indice of refraction.
  96818. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96819. */
  96820. indexOfRefraction: number;
  96821. /**
  96822. * Invert the refraction texture alongside the y axis.
  96823. * It can be useful with procedural textures or probe for instance.
  96824. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96825. */
  96826. invertRefractionY: boolean;
  96827. /**
  96828. * Defines the alpha limits in alpha test mode.
  96829. */
  96830. alphaCutOff: number;
  96831. private _useLightmapAsShadowmap;
  96832. /**
  96833. * In case of light mapping, define whether the map contains light or shadow informations.
  96834. */
  96835. useLightmapAsShadowmap: boolean;
  96836. private _diffuseFresnelParameters;
  96837. /**
  96838. * Define the diffuse fresnel parameters of the material.
  96839. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96840. */
  96841. diffuseFresnelParameters: FresnelParameters;
  96842. private _opacityFresnelParameters;
  96843. /**
  96844. * Define the opacity fresnel parameters of the material.
  96845. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96846. */
  96847. opacityFresnelParameters: FresnelParameters;
  96848. private _reflectionFresnelParameters;
  96849. /**
  96850. * Define the reflection fresnel parameters of the material.
  96851. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96852. */
  96853. reflectionFresnelParameters: FresnelParameters;
  96854. private _refractionFresnelParameters;
  96855. /**
  96856. * Define the refraction fresnel parameters of the material.
  96857. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96858. */
  96859. refractionFresnelParameters: FresnelParameters;
  96860. private _emissiveFresnelParameters;
  96861. /**
  96862. * Define the emissive fresnel parameters of the material.
  96863. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96864. */
  96865. emissiveFresnelParameters: FresnelParameters;
  96866. private _useReflectionFresnelFromSpecular;
  96867. /**
  96868. * If true automatically deducts the fresnels values from the material specularity.
  96869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96870. */
  96871. useReflectionFresnelFromSpecular: boolean;
  96872. private _useGlossinessFromSpecularMapAlpha;
  96873. /**
  96874. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96875. */
  96876. useGlossinessFromSpecularMapAlpha: boolean;
  96877. private _maxSimultaneousLights;
  96878. /**
  96879. * Defines the maximum number of lights that can be used in the material
  96880. */
  96881. maxSimultaneousLights: number;
  96882. private _invertNormalMapX;
  96883. /**
  96884. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96885. */
  96886. invertNormalMapX: boolean;
  96887. private _invertNormalMapY;
  96888. /**
  96889. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96890. */
  96891. invertNormalMapY: boolean;
  96892. private _twoSidedLighting;
  96893. /**
  96894. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96895. */
  96896. twoSidedLighting: boolean;
  96897. /**
  96898. * Default configuration related to image processing available in the standard Material.
  96899. */
  96900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96901. /**
  96902. * Gets the image processing configuration used either in this material.
  96903. */
  96904. /**
  96905. * Sets the Default image processing configuration used either in the this material.
  96906. *
  96907. * If sets to null, the scene one is in use.
  96908. */
  96909. imageProcessingConfiguration: ImageProcessingConfiguration;
  96910. /**
  96911. * Keep track of the image processing observer to allow dispose and replace.
  96912. */
  96913. private _imageProcessingObserver;
  96914. /**
  96915. * Attaches a new image processing configuration to the Standard Material.
  96916. * @param configuration
  96917. */
  96918. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96919. /**
  96920. * Gets wether the color curves effect is enabled.
  96921. */
  96922. /**
  96923. * Sets wether the color curves effect is enabled.
  96924. */
  96925. cameraColorCurvesEnabled: boolean;
  96926. /**
  96927. * Gets wether the color grading effect is enabled.
  96928. */
  96929. /**
  96930. * Gets wether the color grading effect is enabled.
  96931. */
  96932. cameraColorGradingEnabled: boolean;
  96933. /**
  96934. * Gets wether tonemapping is enabled or not.
  96935. */
  96936. /**
  96937. * Sets wether tonemapping is enabled or not
  96938. */
  96939. cameraToneMappingEnabled: boolean;
  96940. /**
  96941. * The camera exposure used on this material.
  96942. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96943. * This corresponds to a photographic exposure.
  96944. */
  96945. /**
  96946. * The camera exposure used on this material.
  96947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96948. * This corresponds to a photographic exposure.
  96949. */
  96950. cameraExposure: number;
  96951. /**
  96952. * Gets The camera contrast used on this material.
  96953. */
  96954. /**
  96955. * Sets The camera contrast used on this material.
  96956. */
  96957. cameraContrast: number;
  96958. /**
  96959. * Gets the Color Grading 2D Lookup Texture.
  96960. */
  96961. /**
  96962. * Sets the Color Grading 2D Lookup Texture.
  96963. */
  96964. cameraColorGradingTexture: Nullable<BaseTexture>;
  96965. /**
  96966. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96967. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96968. * 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;
  96969. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96970. */
  96971. /**
  96972. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96973. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96974. * 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;
  96975. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96976. */
  96977. cameraColorCurves: Nullable<ColorCurves>;
  96978. /**
  96979. * Custom callback helping to override the default shader used in the material.
  96980. */
  96981. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96982. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96983. protected _worldViewProjectionMatrix: Matrix;
  96984. protected _globalAmbientColor: Color3;
  96985. protected _useLogarithmicDepth: boolean;
  96986. /**
  96987. * Instantiates a new standard material.
  96988. * This is the default material used in Babylon. It is the best trade off between quality
  96989. * and performances.
  96990. * @see http://doc.babylonjs.com/babylon101/materials
  96991. * @param name Define the name of the material in the scene
  96992. * @param scene Define the scene the material belong to
  96993. */
  96994. constructor(name: string, scene: Scene);
  96995. /**
  96996. * Gets a boolean indicating that current material needs to register RTT
  96997. */
  96998. readonly hasRenderTargetTextures: boolean;
  96999. /**
  97000. * Gets the current class name of the material e.g. "StandardMaterial"
  97001. * Mainly use in serialization.
  97002. * @returns the class name
  97003. */
  97004. getClassName(): string;
  97005. /**
  97006. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97007. * You can try switching to logarithmic depth.
  97008. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97009. */
  97010. useLogarithmicDepth: boolean;
  97011. /**
  97012. * Specifies if the material will require alpha blending
  97013. * @returns a boolean specifying if alpha blending is needed
  97014. */
  97015. needAlphaBlending(): boolean;
  97016. /**
  97017. * Specifies if this material should be rendered in alpha test mode
  97018. * @returns a boolean specifying if an alpha test is needed.
  97019. */
  97020. needAlphaTesting(): boolean;
  97021. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97022. /**
  97023. * Get the texture used for alpha test purpose.
  97024. * @returns the diffuse texture in case of the standard material.
  97025. */
  97026. getAlphaTestTexture(): Nullable<BaseTexture>;
  97027. /**
  97028. * Get if the submesh is ready to be used and all its information available.
  97029. * Child classes can use it to update shaders
  97030. * @param mesh defines the mesh to check
  97031. * @param subMesh defines which submesh to check
  97032. * @param useInstances specifies that instances should be used
  97033. * @returns a boolean indicating that the submesh is ready or not
  97034. */
  97035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97036. /**
  97037. * Builds the material UBO layouts.
  97038. * Used internally during the effect preparation.
  97039. */
  97040. buildUniformLayout(): void;
  97041. /**
  97042. * Unbinds the material from the mesh
  97043. */
  97044. unbind(): void;
  97045. /**
  97046. * Binds the submesh to this material by preparing the effect and shader to draw
  97047. * @param world defines the world transformation matrix
  97048. * @param mesh defines the mesh containing the submesh
  97049. * @param subMesh defines the submesh to bind the material to
  97050. */
  97051. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97052. /**
  97053. * Get the list of animatables in the material.
  97054. * @returns the list of animatables object used in the material
  97055. */
  97056. getAnimatables(): IAnimatable[];
  97057. /**
  97058. * Gets the active textures from the material
  97059. * @returns an array of textures
  97060. */
  97061. getActiveTextures(): BaseTexture[];
  97062. /**
  97063. * Specifies if the material uses a texture
  97064. * @param texture defines the texture to check against the material
  97065. * @returns a boolean specifying if the material uses the texture
  97066. */
  97067. hasTexture(texture: BaseTexture): boolean;
  97068. /**
  97069. * Disposes the material
  97070. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97071. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97072. */
  97073. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97074. /**
  97075. * Makes a duplicate of the material, and gives it a new name
  97076. * @param name defines the new name for the duplicated material
  97077. * @returns the cloned material
  97078. */
  97079. clone(name: string): StandardMaterial;
  97080. /**
  97081. * Serializes this material in a JSON representation
  97082. * @returns the serialized material object
  97083. */
  97084. serialize(): any;
  97085. /**
  97086. * Creates a standard material from parsed material data
  97087. * @param source defines the JSON representation of the material
  97088. * @param scene defines the hosting scene
  97089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97090. * @returns a new standard material
  97091. */
  97092. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97093. /**
  97094. * Are diffuse textures enabled in the application.
  97095. */
  97096. static DiffuseTextureEnabled: boolean;
  97097. /**
  97098. * Are ambient textures enabled in the application.
  97099. */
  97100. static AmbientTextureEnabled: boolean;
  97101. /**
  97102. * Are opacity textures enabled in the application.
  97103. */
  97104. static OpacityTextureEnabled: boolean;
  97105. /**
  97106. * Are reflection textures enabled in the application.
  97107. */
  97108. static ReflectionTextureEnabled: boolean;
  97109. /**
  97110. * Are emissive textures enabled in the application.
  97111. */
  97112. static EmissiveTextureEnabled: boolean;
  97113. /**
  97114. * Are specular textures enabled in the application.
  97115. */
  97116. static SpecularTextureEnabled: boolean;
  97117. /**
  97118. * Are bump textures enabled in the application.
  97119. */
  97120. static BumpTextureEnabled: boolean;
  97121. /**
  97122. * Are lightmap textures enabled in the application.
  97123. */
  97124. static LightmapTextureEnabled: boolean;
  97125. /**
  97126. * Are refraction textures enabled in the application.
  97127. */
  97128. static RefractionTextureEnabled: boolean;
  97129. /**
  97130. * Are color grading textures enabled in the application.
  97131. */
  97132. static ColorGradingTextureEnabled: boolean;
  97133. /**
  97134. * Are fresnels enabled in the application.
  97135. */
  97136. static FresnelEnabled: boolean;
  97137. }
  97138. }
  97139. declare module BABYLON {
  97140. /**
  97141. * A class extending Texture allowing drawing on a texture
  97142. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97143. */
  97144. export class DynamicTexture extends Texture {
  97145. private _generateMipMaps;
  97146. private _canvas;
  97147. private _context;
  97148. private _engine;
  97149. /**
  97150. * Creates a DynamicTexture
  97151. * @param name defines the name of the texture
  97152. * @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
  97153. * @param scene defines the scene where you want the texture
  97154. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97155. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97156. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97157. */
  97158. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97159. /**
  97160. * Get the current class name of the texture useful for serialization or dynamic coding.
  97161. * @returns "DynamicTexture"
  97162. */
  97163. getClassName(): string;
  97164. /**
  97165. * Gets the current state of canRescale
  97166. */
  97167. readonly canRescale: boolean;
  97168. private _recreate;
  97169. /**
  97170. * Scales the texture
  97171. * @param ratio the scale factor to apply to both width and height
  97172. */
  97173. scale(ratio: number): void;
  97174. /**
  97175. * Resizes the texture
  97176. * @param width the new width
  97177. * @param height the new height
  97178. */
  97179. scaleTo(width: number, height: number): void;
  97180. /**
  97181. * Gets the context of the canvas used by the texture
  97182. * @returns the canvas context of the dynamic texture
  97183. */
  97184. getContext(): CanvasRenderingContext2D;
  97185. /**
  97186. * Clears the texture
  97187. */
  97188. clear(): void;
  97189. /**
  97190. * Updates the texture
  97191. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97192. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  97193. */
  97194. update(invertY?: boolean, premulAlpha?: boolean): void;
  97195. /**
  97196. * Draws text onto the texture
  97197. * @param text defines the text to be drawn
  97198. * @param x defines the placement of the text from the left
  97199. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  97200. * @param font defines the font to be used with font-style, font-size, font-name
  97201. * @param color defines the color used for the text
  97202. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  97203. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97204. * @param update defines whether texture is immediately update (default is true)
  97205. */
  97206. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  97207. /**
  97208. * Clones the texture
  97209. * @returns the clone of the texture.
  97210. */
  97211. clone(): DynamicTexture;
  97212. /**
  97213. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  97214. * @returns a serialized dynamic texture object
  97215. */
  97216. serialize(): any;
  97217. /** @hidden */
  97218. _rebuild(): void;
  97219. }
  97220. }
  97221. declare module BABYLON {
  97222. /** @hidden */
  97223. export var imageProcessingPixelShader: {
  97224. name: string;
  97225. shader: string;
  97226. };
  97227. }
  97228. declare module BABYLON {
  97229. /**
  97230. * ImageProcessingPostProcess
  97231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97232. */
  97233. export class ImageProcessingPostProcess extends PostProcess {
  97234. /**
  97235. * Default configuration related to image processing available in the PBR Material.
  97236. */
  97237. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97238. /**
  97239. * Gets the image processing configuration used either in this material.
  97240. */
  97241. /**
  97242. * Sets the Default image processing configuration used either in the this material.
  97243. *
  97244. * If sets to null, the scene one is in use.
  97245. */
  97246. imageProcessingConfiguration: ImageProcessingConfiguration;
  97247. /**
  97248. * Keep track of the image processing observer to allow dispose and replace.
  97249. */
  97250. private _imageProcessingObserver;
  97251. /**
  97252. * Attaches a new image processing configuration to the PBR Material.
  97253. * @param configuration
  97254. */
  97255. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97256. /**
  97257. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97258. */
  97259. /**
  97260. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97261. */
  97262. colorCurves: Nullable<ColorCurves>;
  97263. /**
  97264. * Gets wether the color curves effect is enabled.
  97265. */
  97266. /**
  97267. * Sets wether the color curves effect is enabled.
  97268. */
  97269. colorCurvesEnabled: boolean;
  97270. /**
  97271. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97272. */
  97273. /**
  97274. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97275. */
  97276. colorGradingTexture: Nullable<BaseTexture>;
  97277. /**
  97278. * Gets wether the color grading effect is enabled.
  97279. */
  97280. /**
  97281. * Gets wether the color grading effect is enabled.
  97282. */
  97283. colorGradingEnabled: boolean;
  97284. /**
  97285. * Gets exposure used in the effect.
  97286. */
  97287. /**
  97288. * Sets exposure used in the effect.
  97289. */
  97290. exposure: number;
  97291. /**
  97292. * Gets wether tonemapping is enabled or not.
  97293. */
  97294. /**
  97295. * Sets wether tonemapping is enabled or not
  97296. */
  97297. toneMappingEnabled: boolean;
  97298. /**
  97299. * Gets the type of tone mapping effect.
  97300. */
  97301. /**
  97302. * Sets the type of tone mapping effect.
  97303. */
  97304. toneMappingType: number;
  97305. /**
  97306. * Gets contrast used in the effect.
  97307. */
  97308. /**
  97309. * Sets contrast used in the effect.
  97310. */
  97311. contrast: number;
  97312. /**
  97313. * Gets Vignette stretch size.
  97314. */
  97315. /**
  97316. * Sets Vignette stretch size.
  97317. */
  97318. vignetteStretch: number;
  97319. /**
  97320. * Gets Vignette centre X Offset.
  97321. */
  97322. /**
  97323. * Sets Vignette centre X Offset.
  97324. */
  97325. vignetteCentreX: number;
  97326. /**
  97327. * Gets Vignette centre Y Offset.
  97328. */
  97329. /**
  97330. * Sets Vignette centre Y Offset.
  97331. */
  97332. vignetteCentreY: number;
  97333. /**
  97334. * Gets Vignette weight or intensity of the vignette effect.
  97335. */
  97336. /**
  97337. * Sets Vignette weight or intensity of the vignette effect.
  97338. */
  97339. vignetteWeight: number;
  97340. /**
  97341. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97342. * if vignetteEnabled is set to true.
  97343. */
  97344. /**
  97345. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97346. * if vignetteEnabled is set to true.
  97347. */
  97348. vignetteColor: Color4;
  97349. /**
  97350. * Gets Camera field of view used by the Vignette effect.
  97351. */
  97352. /**
  97353. * Sets Camera field of view used by the Vignette effect.
  97354. */
  97355. vignetteCameraFov: number;
  97356. /**
  97357. * Gets the vignette blend mode allowing different kind of effect.
  97358. */
  97359. /**
  97360. * Sets the vignette blend mode allowing different kind of effect.
  97361. */
  97362. vignetteBlendMode: number;
  97363. /**
  97364. * Gets wether the vignette effect is enabled.
  97365. */
  97366. /**
  97367. * Sets wether the vignette effect is enabled.
  97368. */
  97369. vignetteEnabled: boolean;
  97370. private _fromLinearSpace;
  97371. /**
  97372. * Gets wether the input of the processing is in Gamma or Linear Space.
  97373. */
  97374. /**
  97375. * Sets wether the input of the processing is in Gamma or Linear Space.
  97376. */
  97377. fromLinearSpace: boolean;
  97378. /**
  97379. * Defines cache preventing GC.
  97380. */
  97381. private _defines;
  97382. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97383. /**
  97384. * "ImageProcessingPostProcess"
  97385. * @returns "ImageProcessingPostProcess"
  97386. */
  97387. getClassName(): string;
  97388. protected _updateParameters(): void;
  97389. dispose(camera?: Camera): void;
  97390. }
  97391. }
  97392. declare module BABYLON {
  97393. /**
  97394. * Class containing static functions to help procedurally build meshes
  97395. */
  97396. export class GroundBuilder {
  97397. /**
  97398. * Creates a ground mesh
  97399. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97400. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97402. * @param name defines the name of the mesh
  97403. * @param options defines the options used to create the mesh
  97404. * @param scene defines the hosting scene
  97405. * @returns the ground mesh
  97406. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97407. */
  97408. static CreateGround(name: string, options: {
  97409. width?: number;
  97410. height?: number;
  97411. subdivisions?: number;
  97412. subdivisionsX?: number;
  97413. subdivisionsY?: number;
  97414. updatable?: boolean;
  97415. }, scene: any): Mesh;
  97416. /**
  97417. * Creates a tiled ground mesh
  97418. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97419. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97420. * * 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
  97421. * * 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
  97422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97423. * @param name defines the name of the mesh
  97424. * @param options defines the options used to create the mesh
  97425. * @param scene defines the hosting scene
  97426. * @returns the tiled ground mesh
  97427. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97428. */
  97429. static CreateTiledGround(name: string, options: {
  97430. xmin: number;
  97431. zmin: number;
  97432. xmax: number;
  97433. zmax: number;
  97434. subdivisions?: {
  97435. w: number;
  97436. h: number;
  97437. };
  97438. precision?: {
  97439. w: number;
  97440. h: number;
  97441. };
  97442. updatable?: boolean;
  97443. }, scene: Scene): Mesh;
  97444. /**
  97445. * Creates a ground mesh from a height map
  97446. * * The parameter `url` sets the URL of the height map image resource.
  97447. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97448. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97449. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97450. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97451. * * 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.
  97452. * * 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).
  97453. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97455. * @param name defines the name of the mesh
  97456. * @param url defines the url to the height map
  97457. * @param options defines the options used to create the mesh
  97458. * @param scene defines the hosting scene
  97459. * @returns the ground mesh
  97460. * @see https://doc.babylonjs.com/babylon101/height_map
  97461. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97462. */
  97463. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97464. width?: number;
  97465. height?: number;
  97466. subdivisions?: number;
  97467. minHeight?: number;
  97468. maxHeight?: number;
  97469. colorFilter?: Color3;
  97470. alphaFilter?: number;
  97471. updatable?: boolean;
  97472. onReady?: (mesh: GroundMesh) => void;
  97473. }, scene: Scene): GroundMesh;
  97474. }
  97475. }
  97476. declare module BABYLON {
  97477. /**
  97478. * Class containing static functions to help procedurally build meshes
  97479. */
  97480. export class TorusBuilder {
  97481. /**
  97482. * Creates a torus mesh
  97483. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97484. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97485. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97489. * @param name defines the name of the mesh
  97490. * @param options defines the options used to create the mesh
  97491. * @param scene defines the hosting scene
  97492. * @returns the torus mesh
  97493. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97494. */
  97495. static CreateTorus(name: string, options: {
  97496. diameter?: number;
  97497. thickness?: number;
  97498. tessellation?: number;
  97499. updatable?: boolean;
  97500. sideOrientation?: number;
  97501. frontUVs?: Vector4;
  97502. backUVs?: Vector4;
  97503. }, scene: any): Mesh;
  97504. }
  97505. }
  97506. declare module BABYLON {
  97507. /**
  97508. * Class containing static functions to help procedurally build meshes
  97509. */
  97510. export class CylinderBuilder {
  97511. /**
  97512. * Creates a cylinder or a cone mesh
  97513. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97514. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97515. * * 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.
  97516. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97517. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97518. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97519. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97520. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97521. * * 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).
  97522. * * 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
  97523. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97524. * * 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
  97525. * * 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.
  97526. * * If `enclose` is false, a ring surface is one element.
  97527. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97528. * * 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
  97529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97532. * @param name defines the name of the mesh
  97533. * @param options defines the options used to create the mesh
  97534. * @param scene defines the hosting scene
  97535. * @returns the cylinder mesh
  97536. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97537. */
  97538. static CreateCylinder(name: string, options: {
  97539. height?: number;
  97540. diameterTop?: number;
  97541. diameterBottom?: number;
  97542. diameter?: number;
  97543. tessellation?: number;
  97544. subdivisions?: number;
  97545. arc?: number;
  97546. faceColors?: Color4[];
  97547. faceUV?: Vector4[];
  97548. updatable?: boolean;
  97549. hasRings?: boolean;
  97550. enclose?: boolean;
  97551. sideOrientation?: number;
  97552. frontUVs?: Vector4;
  97553. backUVs?: Vector4;
  97554. }, scene: any): Mesh;
  97555. }
  97556. }
  97557. declare module BABYLON {
  97558. /**
  97559. * Manager for handling gamepads
  97560. */
  97561. export class GamepadManager {
  97562. private _scene?;
  97563. private _babylonGamepads;
  97564. private _oneGamepadConnected;
  97565. /** @hidden */
  97566. _isMonitoring: boolean;
  97567. private _gamepadEventSupported;
  97568. private _gamepadSupport;
  97569. /**
  97570. * observable to be triggered when the gamepad controller has been connected
  97571. */
  97572. onGamepadConnectedObservable: Observable<Gamepad>;
  97573. /**
  97574. * observable to be triggered when the gamepad controller has been disconnected
  97575. */
  97576. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97577. private _onGamepadConnectedEvent;
  97578. private _onGamepadDisconnectedEvent;
  97579. /**
  97580. * Initializes the gamepad manager
  97581. * @param _scene BabylonJS scene
  97582. */
  97583. constructor(_scene?: Scene | undefined);
  97584. /**
  97585. * The gamepads in the game pad manager
  97586. */
  97587. readonly gamepads: Gamepad[];
  97588. /**
  97589. * Get the gamepad controllers based on type
  97590. * @param type The type of gamepad controller
  97591. * @returns Nullable gamepad
  97592. */
  97593. getGamepadByType(type?: number): Nullable<Gamepad>;
  97594. /**
  97595. * Disposes the gamepad manager
  97596. */
  97597. dispose(): void;
  97598. private _addNewGamepad;
  97599. private _startMonitoringGamepads;
  97600. private _stopMonitoringGamepads;
  97601. /** @hidden */
  97602. _checkGamepadsStatus(): void;
  97603. private _updateGamepadObjects;
  97604. }
  97605. }
  97606. declare module BABYLON {
  97607. interface Scene {
  97608. /** @hidden */
  97609. _gamepadManager: Nullable<GamepadManager>;
  97610. /**
  97611. * Gets the gamepad manager associated with the scene
  97612. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97613. */
  97614. gamepadManager: GamepadManager;
  97615. }
  97616. /**
  97617. * Interface representing a free camera inputs manager
  97618. */
  97619. interface FreeCameraInputsManager {
  97620. /**
  97621. * Adds gamepad input support to the FreeCameraInputsManager.
  97622. * @returns the FreeCameraInputsManager
  97623. */
  97624. addGamepad(): FreeCameraInputsManager;
  97625. }
  97626. /**
  97627. * Interface representing an arc rotate camera inputs manager
  97628. */
  97629. interface ArcRotateCameraInputsManager {
  97630. /**
  97631. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97632. * @returns the camera inputs manager
  97633. */
  97634. addGamepad(): ArcRotateCameraInputsManager;
  97635. }
  97636. /**
  97637. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97638. */
  97639. export class GamepadSystemSceneComponent implements ISceneComponent {
  97640. /**
  97641. * The component name helpfull to identify the component in the list of scene components.
  97642. */
  97643. readonly name: string;
  97644. /**
  97645. * The scene the component belongs to.
  97646. */
  97647. scene: Scene;
  97648. /**
  97649. * Creates a new instance of the component for the given scene
  97650. * @param scene Defines the scene to register the component in
  97651. */
  97652. constructor(scene: Scene);
  97653. /**
  97654. * Registers the component in a given scene
  97655. */
  97656. register(): void;
  97657. /**
  97658. * Rebuilds the elements related to this component in case of
  97659. * context lost for instance.
  97660. */
  97661. rebuild(): void;
  97662. /**
  97663. * Disposes the component and the associated ressources
  97664. */
  97665. dispose(): void;
  97666. private _beforeCameraUpdate;
  97667. }
  97668. }
  97669. declare module BABYLON {
  97670. /**
  97671. * Options to modify the vr teleportation behavior.
  97672. */
  97673. export interface VRTeleportationOptions {
  97674. /**
  97675. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97676. */
  97677. floorMeshName?: string;
  97678. /**
  97679. * A list of meshes to be used as the teleportation floor. (default: empty)
  97680. */
  97681. floorMeshes?: Mesh[];
  97682. }
  97683. /**
  97684. * Options to modify the vr experience helper's behavior.
  97685. */
  97686. export interface VRExperienceHelperOptions extends WebVROptions {
  97687. /**
  97688. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97689. */
  97690. createDeviceOrientationCamera?: boolean;
  97691. /**
  97692. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97693. */
  97694. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97695. /**
  97696. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97697. */
  97698. laserToggle?: boolean;
  97699. /**
  97700. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97701. */
  97702. floorMeshes?: Mesh[];
  97703. /**
  97704. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97705. */
  97706. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97707. }
  97708. /**
  97709. * Event containing information after VR has been entered
  97710. */
  97711. export class OnAfterEnteringVRObservableEvent {
  97712. /**
  97713. * If entering vr was successful
  97714. */
  97715. success: boolean;
  97716. }
  97717. /**
  97718. * Helps to quickly add VR support to an existing scene.
  97719. * See http://doc.babylonjs.com/how_to/webvr_helper
  97720. */
  97721. export class VRExperienceHelper {
  97722. /** Options to modify the vr experience helper's behavior. */
  97723. webVROptions: VRExperienceHelperOptions;
  97724. private _scene;
  97725. private _position;
  97726. private _btnVR;
  97727. private _btnVRDisplayed;
  97728. private _webVRsupported;
  97729. private _webVRready;
  97730. private _webVRrequesting;
  97731. private _webVRpresenting;
  97732. private _hasEnteredVR;
  97733. private _fullscreenVRpresenting;
  97734. private _canvas;
  97735. private _webVRCamera;
  97736. private _vrDeviceOrientationCamera;
  97737. private _deviceOrientationCamera;
  97738. private _existingCamera;
  97739. private _onKeyDown;
  97740. private _onVrDisplayPresentChange;
  97741. private _onVRDisplayChanged;
  97742. private _onVRRequestPresentStart;
  97743. private _onVRRequestPresentComplete;
  97744. /**
  97745. * Observable raised right before entering VR.
  97746. */
  97747. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97748. /**
  97749. * Observable raised when entering VR has completed.
  97750. */
  97751. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97752. /**
  97753. * Observable raised when exiting VR.
  97754. */
  97755. onExitingVRObservable: Observable<VRExperienceHelper>;
  97756. /**
  97757. * Observable raised when controller mesh is loaded.
  97758. */
  97759. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97760. /** Return this.onEnteringVRObservable
  97761. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  97762. */
  97763. readonly onEnteringVR: Observable<VRExperienceHelper>;
  97764. /** Return this.onExitingVRObservable
  97765. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  97766. */
  97767. readonly onExitingVR: Observable<VRExperienceHelper>;
  97768. /** Return this.onControllerMeshLoadedObservable
  97769. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  97770. */
  97771. readonly onControllerMeshLoaded: Observable<WebVRController>;
  97772. private _rayLength;
  97773. private _useCustomVRButton;
  97774. private _teleportationRequested;
  97775. private _teleportActive;
  97776. private _floorMeshName;
  97777. private _floorMeshesCollection;
  97778. private _rotationAllowed;
  97779. private _teleportBackwardsVector;
  97780. private _teleportationTarget;
  97781. private _isDefaultTeleportationTarget;
  97782. private _postProcessMove;
  97783. private _teleportationFillColor;
  97784. private _teleportationBorderColor;
  97785. private _rotationAngle;
  97786. private _haloCenter;
  97787. private _cameraGazer;
  97788. private _padSensibilityUp;
  97789. private _padSensibilityDown;
  97790. private _leftController;
  97791. private _rightController;
  97792. /**
  97793. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  97794. */
  97795. onNewMeshSelected: Observable<AbstractMesh>;
  97796. /**
  97797. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  97798. */
  97799. onNewMeshPicked: Observable<PickingInfo>;
  97800. private _circleEase;
  97801. /**
  97802. * Observable raised before camera teleportation
  97803. */
  97804. onBeforeCameraTeleport: Observable<Vector3>;
  97805. /**
  97806. * Observable raised after camera teleportation
  97807. */
  97808. onAfterCameraTeleport: Observable<Vector3>;
  97809. /**
  97810. * Observable raised when current selected mesh gets unselected
  97811. */
  97812. onSelectedMeshUnselected: Observable<AbstractMesh>;
  97813. private _raySelectionPredicate;
  97814. /**
  97815. * To be optionaly changed by user to define custom ray selection
  97816. */
  97817. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  97818. /**
  97819. * To be optionaly changed by user to define custom selection logic (after ray selection)
  97820. */
  97821. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  97822. /**
  97823. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  97824. */
  97825. teleportationEnabled: boolean;
  97826. private _defaultHeight;
  97827. private _teleportationInitialized;
  97828. private _interactionsEnabled;
  97829. private _interactionsRequested;
  97830. private _displayGaze;
  97831. private _displayLaserPointer;
  97832. /**
  97833. * The mesh used to display where the user is going to teleport.
  97834. */
  97835. /**
  97836. * Sets the mesh to be used to display where the user is going to teleport.
  97837. */
  97838. teleportationTarget: Mesh;
  97839. /**
  97840. * 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
  97841. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  97842. * See http://doc.babylonjs.com/resources/baking_transformations
  97843. */
  97844. gazeTrackerMesh: Mesh;
  97845. /**
  97846. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  97847. */
  97848. updateGazeTrackerScale: boolean;
  97849. /**
  97850. * If the gaze trackers color should be updated when selecting meshes
  97851. */
  97852. updateGazeTrackerColor: boolean;
  97853. /**
  97854. * The gaze tracking mesh corresponding to the left controller
  97855. */
  97856. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  97857. /**
  97858. * The gaze tracking mesh corresponding to the right controller
  97859. */
  97860. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  97861. /**
  97862. * If the ray of the gaze should be displayed.
  97863. */
  97864. /**
  97865. * Sets if the ray of the gaze should be displayed.
  97866. */
  97867. displayGaze: boolean;
  97868. /**
  97869. * If the ray of the LaserPointer should be displayed.
  97870. */
  97871. /**
  97872. * Sets if the ray of the LaserPointer should be displayed.
  97873. */
  97874. displayLaserPointer: boolean;
  97875. /**
  97876. * The deviceOrientationCamera used as the camera when not in VR.
  97877. */
  97878. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  97879. /**
  97880. * Based on the current WebVR support, returns the current VR camera used.
  97881. */
  97882. readonly currentVRCamera: Nullable<Camera>;
  97883. /**
  97884. * The webVRCamera which is used when in VR.
  97885. */
  97886. readonly webVRCamera: WebVRFreeCamera;
  97887. /**
  97888. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  97889. */
  97890. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  97891. private readonly _teleportationRequestInitiated;
  97892. /**
  97893. * Defines wether or not Pointer lock should be requested when switching to
  97894. * full screen.
  97895. */
  97896. requestPointerLockOnFullScreen: boolean;
  97897. /**
  97898. * Instantiates a VRExperienceHelper.
  97899. * Helps to quickly add VR support to an existing scene.
  97900. * @param scene The scene the VRExperienceHelper belongs to.
  97901. * @param webVROptions Options to modify the vr experience helper's behavior.
  97902. */
  97903. constructor(scene: Scene,
  97904. /** Options to modify the vr experience helper's behavior. */
  97905. webVROptions?: VRExperienceHelperOptions);
  97906. private _onDefaultMeshLoaded;
  97907. private _onResize;
  97908. private _onFullscreenChange;
  97909. /**
  97910. * Gets a value indicating if we are currently in VR mode.
  97911. */
  97912. readonly isInVRMode: boolean;
  97913. private onVrDisplayPresentChange;
  97914. private onVRDisplayChanged;
  97915. private moveButtonToBottomRight;
  97916. private displayVRButton;
  97917. private updateButtonVisibility;
  97918. private _cachedAngularSensibility;
  97919. /**
  97920. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  97921. * Otherwise, will use the fullscreen API.
  97922. */
  97923. enterVR(): void;
  97924. /**
  97925. * Attempt to exit VR, or fullscreen.
  97926. */
  97927. exitVR(): void;
  97928. /**
  97929. * The position of the vr experience helper.
  97930. */
  97931. /**
  97932. * Sets the position of the vr experience helper.
  97933. */
  97934. position: Vector3;
  97935. /**
  97936. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  97937. */
  97938. enableInteractions(): void;
  97939. private readonly _noControllerIsActive;
  97940. private beforeRender;
  97941. private _isTeleportationFloor;
  97942. /**
  97943. * Adds a floor mesh to be used for teleportation.
  97944. * @param floorMesh the mesh to be used for teleportation.
  97945. */
  97946. addFloorMesh(floorMesh: Mesh): void;
  97947. /**
  97948. * Removes a floor mesh from being used for teleportation.
  97949. * @param floorMesh the mesh to be removed.
  97950. */
  97951. removeFloorMesh(floorMesh: Mesh): void;
  97952. /**
  97953. * Enables interactions and teleportation using the VR controllers and gaze.
  97954. * @param vrTeleportationOptions options to modify teleportation behavior.
  97955. */
  97956. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  97957. private _onNewGamepadConnected;
  97958. private _tryEnableInteractionOnController;
  97959. private _onNewGamepadDisconnected;
  97960. private _enableInteractionOnController;
  97961. private _checkTeleportWithRay;
  97962. private _checkRotate;
  97963. private _checkTeleportBackwards;
  97964. private _enableTeleportationOnController;
  97965. private _createTeleportationCircles;
  97966. private _displayTeleportationTarget;
  97967. private _hideTeleportationTarget;
  97968. private _rotateCamera;
  97969. private _moveTeleportationSelectorTo;
  97970. private _workingVector;
  97971. private _workingQuaternion;
  97972. private _workingMatrix;
  97973. /**
  97974. * Teleports the users feet to the desired location
  97975. * @param location The location where the user's feet should be placed
  97976. */
  97977. teleportCamera(location: Vector3): void;
  97978. private _convertNormalToDirectionOfRay;
  97979. private _castRayAndSelectObject;
  97980. private _notifySelectedMeshUnselected;
  97981. /**
  97982. * Sets the color of the laser ray from the vr controllers.
  97983. * @param color new color for the ray.
  97984. */
  97985. changeLaserColor(color: Color3): void;
  97986. /**
  97987. * Sets the color of the ray from the vr headsets gaze.
  97988. * @param color new color for the ray.
  97989. */
  97990. changeGazeColor(color: Color3): void;
  97991. /**
  97992. * Exits VR and disposes of the vr experience helper
  97993. */
  97994. dispose(): void;
  97995. /**
  97996. * Gets the name of the VRExperienceHelper class
  97997. * @returns "VRExperienceHelper"
  97998. */
  97999. getClassName(): string;
  98000. }
  98001. }
  98002. declare module BABYLON {
  98003. /**
  98004. * Manages an XRSession
  98005. * @see https://doc.babylonjs.com/how_to/webxr
  98006. */
  98007. export class WebXRSessionManager implements IDisposable {
  98008. private scene;
  98009. /**
  98010. * Fires every time a new xrFrame arrives which can be used to update the camera
  98011. */
  98012. onXRFrameObservable: Observable<any>;
  98013. /**
  98014. * Fires when the xr session is ended either by the device or manually done
  98015. */
  98016. onXRSessionEnded: Observable<any>;
  98017. /** @hidden */
  98018. _xrSession: XRSession;
  98019. /** @hidden */
  98020. _frameOfReference: XRFrameOfReference;
  98021. /** @hidden */
  98022. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  98023. /** @hidden */
  98024. _currentXRFrame: Nullable<XRFrame>;
  98025. private _xrNavigator;
  98026. private _xrDevice;
  98027. private _tmpMatrix;
  98028. /**
  98029. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  98030. * @param scene The scene which the session should be created for
  98031. */
  98032. constructor(scene: Scene);
  98033. /**
  98034. * Initializes the manager
  98035. * After initialization enterXR can be called to start an XR session
  98036. * @returns Promise which resolves after it is initialized
  98037. */
  98038. initializeAsync(): Promise<void>;
  98039. /**
  98040. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  98041. * @param sessionCreationOptions xr options to create the session with
  98042. * @param frameOfReferenceType option to configure how the xr pose is expressed
  98043. * @returns Promise which resolves after it enters XR
  98044. */
  98045. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  98046. /**
  98047. * Stops the xrSession and restores the renderloop
  98048. * @returns Promise which resolves after it exits XR
  98049. */
  98050. exitXRAsync(): Promise<void>;
  98051. /**
  98052. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98053. * @param ray ray to cast into the environment
  98054. * @returns Promise which resolves with a collision point in the environment if it exists
  98055. */
  98056. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98057. /**
  98058. * Checks if a session would be supported for the creation options specified
  98059. * @param options creation options to check if they are supported
  98060. * @returns true if supported
  98061. */
  98062. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98063. /**
  98064. * @hidden
  98065. * Converts the render layer of xrSession to a render target
  98066. * @param session session to create render target for
  98067. * @param scene scene the new render target should be created for
  98068. */
  98069. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98070. /**
  98071. * Disposes of the session manager
  98072. */
  98073. dispose(): void;
  98074. }
  98075. }
  98076. declare module BABYLON {
  98077. /**
  98078. * WebXR Camera which holds the views for the xrSession
  98079. * @see https://doc.babylonjs.com/how_to/webxr
  98080. */
  98081. export class WebXRCamera extends FreeCamera {
  98082. private static _TmpMatrix;
  98083. /**
  98084. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98085. * @param name the name of the camera
  98086. * @param scene the scene to add the camera to
  98087. */
  98088. constructor(name: string, scene: Scene);
  98089. private _updateNumberOfRigCameras;
  98090. /** @hidden */
  98091. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98092. /**
  98093. * Updates the cameras position from the current pose information of the XR session
  98094. * @param xrSessionManager the session containing pose information
  98095. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98096. */
  98097. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98098. }
  98099. }
  98100. declare module BABYLON {
  98101. /**
  98102. * States of the webXR experience
  98103. */
  98104. export enum WebXRState {
  98105. /**
  98106. * Transitioning to being in XR mode
  98107. */
  98108. ENTERING_XR = 0,
  98109. /**
  98110. * Transitioning to non XR mode
  98111. */
  98112. EXITING_XR = 1,
  98113. /**
  98114. * In XR mode and presenting
  98115. */
  98116. IN_XR = 2,
  98117. /**
  98118. * Not entered XR mode
  98119. */
  98120. NOT_IN_XR = 3
  98121. }
  98122. /**
  98123. * Helper class used to enable XR
  98124. * @see https://doc.babylonjs.com/how_to/webxr
  98125. */
  98126. export class WebXRExperienceHelper implements IDisposable {
  98127. private scene;
  98128. /**
  98129. * 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
  98130. */
  98131. container: AbstractMesh;
  98132. /**
  98133. * Camera used to render xr content
  98134. */
  98135. camera: WebXRCamera;
  98136. /**
  98137. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98138. */
  98139. state: WebXRState;
  98140. private _setState;
  98141. private static _TmpVector;
  98142. /**
  98143. * Fires when the state of the experience helper has changed
  98144. */
  98145. onStateChangedObservable: Observable<WebXRState>;
  98146. /** @hidden */
  98147. _sessionManager: WebXRSessionManager;
  98148. private _nonVRCamera;
  98149. private _originalSceneAutoClear;
  98150. private _supported;
  98151. /**
  98152. * Creates the experience helper
  98153. * @param scene the scene to attach the experience helper to
  98154. * @returns a promise for the experience helper
  98155. */
  98156. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98157. /**
  98158. * Creates a WebXRExperienceHelper
  98159. * @param scene The scene the helper should be created in
  98160. */
  98161. private constructor();
  98162. /**
  98163. * Exits XR mode and returns the scene to its original state
  98164. * @returns promise that resolves after xr mode has exited
  98165. */
  98166. exitXRAsync(): Promise<void>;
  98167. /**
  98168. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98169. * @param sessionCreationOptions options for the XR session
  98170. * @param frameOfReference frame of reference of the XR session
  98171. * @returns promise that resolves after xr mode has entered
  98172. */
  98173. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98174. /**
  98175. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98176. * @param ray ray to cast into the environment
  98177. * @returns Promise which resolves with a collision point in the environment if it exists
  98178. */
  98179. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98180. /**
  98181. * Updates the global position of the camera by moving the camera's container
  98182. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98183. * @param position The desired global position of the camera
  98184. */
  98185. setPositionOfCameraUsingContainer(position: Vector3): void;
  98186. /**
  98187. * Rotates the xr camera by rotating the camera's container around the camera's position
  98188. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  98189. * @param rotation the desired quaternion rotation to apply to the camera
  98190. */
  98191. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  98192. /**
  98193. * Checks if the creation options are supported by the xr session
  98194. * @param options creation options
  98195. * @returns true if supported
  98196. */
  98197. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98198. /**
  98199. * Disposes of the experience helper
  98200. */
  98201. dispose(): void;
  98202. }
  98203. }
  98204. declare module BABYLON {
  98205. /**
  98206. * Button which can be used to enter a different mode of XR
  98207. */
  98208. export class WebXREnterExitUIButton {
  98209. /** button element */
  98210. element: HTMLElement;
  98211. /** XR initialization options for the button */
  98212. initializationOptions: XRSessionCreationOptions;
  98213. /**
  98214. * Creates a WebXREnterExitUIButton
  98215. * @param element button element
  98216. * @param initializationOptions XR initialization options for the button
  98217. */
  98218. constructor(
  98219. /** button element */
  98220. element: HTMLElement,
  98221. /** XR initialization options for the button */
  98222. initializationOptions: XRSessionCreationOptions);
  98223. /**
  98224. * Overwritable function which can be used to update the button's visuals when the state changes
  98225. * @param activeButton the current active button in the UI
  98226. */
  98227. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98228. }
  98229. /**
  98230. * Options to create the webXR UI
  98231. */
  98232. export class WebXREnterExitUIOptions {
  98233. /**
  98234. * Context to enter xr with
  98235. */
  98236. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98237. /**
  98238. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98239. */
  98240. customButtons?: Array<WebXREnterExitUIButton>;
  98241. }
  98242. /**
  98243. * UI to allow the user to enter/exit XR mode
  98244. */
  98245. export class WebXREnterExitUI implements IDisposable {
  98246. private scene;
  98247. private _overlay;
  98248. private _buttons;
  98249. private _activeButton;
  98250. /**
  98251. * Fired every time the active button is changed.
  98252. *
  98253. * When xr is entered via a button that launches xr that button will be the callback parameter
  98254. *
  98255. * When exiting xr the callback parameter will be null)
  98256. */
  98257. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98258. /**
  98259. * Creates UI to allow the user to enter/exit XR mode
  98260. * @param scene the scene to add the ui to
  98261. * @param helper the xr experience helper to enter/exit xr with
  98262. * @param options options to configure the UI
  98263. * @returns the created ui
  98264. */
  98265. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98266. private constructor();
  98267. private _updateButtons;
  98268. /**
  98269. * Disposes of the object
  98270. */
  98271. dispose(): void;
  98272. }
  98273. }
  98274. declare module BABYLON {
  98275. /**
  98276. * Represents an XR input
  98277. */
  98278. export class WebXRController {
  98279. /**
  98280. * 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
  98281. */
  98282. grip?: AbstractMesh;
  98283. /**
  98284. * Pointer which can be used to select objects or attach a visible laser to
  98285. */
  98286. pointer: AbstractMesh;
  98287. /**
  98288. * Creates the controller
  98289. * @see https://doc.babylonjs.com/how_to/webxr
  98290. * @param scene the scene which the controller should be associated to
  98291. */
  98292. constructor(scene: Scene);
  98293. /**
  98294. * Disposes of the object
  98295. */
  98296. dispose(): void;
  98297. }
  98298. /**
  98299. * XR input used to track XR inputs such as controllers/rays
  98300. */
  98301. export class WebXRInput implements IDisposable {
  98302. private helper;
  98303. /**
  98304. * XR controllers being tracked
  98305. */
  98306. controllers: Array<WebXRController>;
  98307. private _tmpMatrix;
  98308. private _frameObserver;
  98309. /**
  98310. * Initializes the WebXRInput
  98311. * @param helper experience helper which the input should be created for
  98312. */
  98313. constructor(helper: WebXRExperienceHelper);
  98314. /**
  98315. * Disposes of the object
  98316. */
  98317. dispose(): void;
  98318. }
  98319. }
  98320. declare module BABYLON {
  98321. /**
  98322. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98323. */
  98324. export class WebXRManagedOutputCanvas implements IDisposable {
  98325. private _canvas;
  98326. /**
  98327. * xrpresent context of the canvas which can be used to display/mirror xr content
  98328. */
  98329. canvasContext: Nullable<WebGLRenderingContext>;
  98330. /**
  98331. * Initializes the canvas to be added/removed upon entering/exiting xr
  98332. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98333. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98334. */
  98335. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98336. /**
  98337. * Disposes of the object
  98338. */
  98339. dispose(): void;
  98340. private _setManagedOutputCanvas;
  98341. private _addCanvas;
  98342. private _removeCanvas;
  98343. }
  98344. }
  98345. declare module BABYLON {
  98346. /**
  98347. * Contains an array of blocks representing the octree
  98348. */
  98349. export interface IOctreeContainer<T> {
  98350. /**
  98351. * Blocks within the octree
  98352. */
  98353. blocks: Array<OctreeBlock<T>>;
  98354. }
  98355. /**
  98356. * Class used to store a cell in an octree
  98357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98358. */
  98359. export class OctreeBlock<T> {
  98360. /**
  98361. * Gets the content of the current block
  98362. */
  98363. entries: T[];
  98364. /**
  98365. * Gets the list of block children
  98366. */
  98367. blocks: Array<OctreeBlock<T>>;
  98368. private _depth;
  98369. private _maxDepth;
  98370. private _capacity;
  98371. private _minPoint;
  98372. private _maxPoint;
  98373. private _boundingVectors;
  98374. private _creationFunc;
  98375. /**
  98376. * Creates a new block
  98377. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98378. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98379. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98380. * @param depth defines the current depth of this block in the octree
  98381. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98382. * @param creationFunc defines a callback to call when an element is added to the block
  98383. */
  98384. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98385. /**
  98386. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98387. */
  98388. readonly capacity: number;
  98389. /**
  98390. * Gets the minimum vector (in world space) of the block's bounding box
  98391. */
  98392. readonly minPoint: Vector3;
  98393. /**
  98394. * Gets the maximum vector (in world space) of the block's bounding box
  98395. */
  98396. readonly maxPoint: Vector3;
  98397. /**
  98398. * Add a new element to this block
  98399. * @param entry defines the element to add
  98400. */
  98401. addEntry(entry: T): void;
  98402. /**
  98403. * Remove an element from this block
  98404. * @param entry defines the element to remove
  98405. */
  98406. removeEntry(entry: T): void;
  98407. /**
  98408. * Add an array of elements to this block
  98409. * @param entries defines the array of elements to add
  98410. */
  98411. addEntries(entries: T[]): void;
  98412. /**
  98413. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98414. * @param frustumPlanes defines the frustum planes to test
  98415. * @param selection defines the array to store current content if selection is positive
  98416. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98417. */
  98418. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98419. /**
  98420. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98421. * @param sphereCenter defines the bounding sphere center
  98422. * @param sphereRadius defines the bounding sphere radius
  98423. * @param selection defines the array to store current content if selection is positive
  98424. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98425. */
  98426. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98427. /**
  98428. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98429. * @param ray defines the ray to test with
  98430. * @param selection defines the array to store current content if selection is positive
  98431. */
  98432. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98433. /**
  98434. * Subdivide the content into child blocks (this block will then be empty)
  98435. */
  98436. createInnerBlocks(): void;
  98437. /**
  98438. * @hidden
  98439. */
  98440. 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;
  98441. }
  98442. }
  98443. declare module BABYLON {
  98444. /**
  98445. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98446. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98447. */
  98448. export class Octree<T> {
  98449. /** 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.) */
  98450. maxDepth: number;
  98451. /**
  98452. * Blocks within the octree containing objects
  98453. */
  98454. blocks: Array<OctreeBlock<T>>;
  98455. /**
  98456. * Content stored in the octree
  98457. */
  98458. dynamicContent: T[];
  98459. private _maxBlockCapacity;
  98460. private _selectionContent;
  98461. private _creationFunc;
  98462. /**
  98463. * Creates a octree
  98464. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98465. * @param creationFunc function to be used to instatiate the octree
  98466. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98467. * @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.)
  98468. */
  98469. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98470. /** 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.) */
  98471. maxDepth?: number);
  98472. /**
  98473. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98474. * @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);
  98475. * @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);
  98476. * @param entries meshes to be added to the octree blocks
  98477. */
  98478. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98479. /**
  98480. * Adds a mesh to the octree
  98481. * @param entry Mesh to add to the octree
  98482. */
  98483. addMesh(entry: T): void;
  98484. /**
  98485. * Remove an element from the octree
  98486. * @param entry defines the element to remove
  98487. */
  98488. removeMesh(entry: T): void;
  98489. /**
  98490. * Selects an array of meshes within the frustum
  98491. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98492. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98493. * @returns array of meshes within the frustum
  98494. */
  98495. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98496. /**
  98497. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98498. * @param sphereCenter defines the bounding sphere center
  98499. * @param sphereRadius defines the bounding sphere radius
  98500. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98501. * @returns an array of objects that intersect the sphere
  98502. */
  98503. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98504. /**
  98505. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98506. * @param ray defines the ray to test with
  98507. * @returns array of intersected objects
  98508. */
  98509. intersectsRay(ray: Ray): SmartArray<T>;
  98510. /**
  98511. * Adds a mesh into the octree block if it intersects the block
  98512. */
  98513. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98514. /**
  98515. * Adds a submesh into the octree block if it intersects the block
  98516. */
  98517. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98518. }
  98519. }
  98520. declare module BABYLON {
  98521. interface Scene {
  98522. /**
  98523. * @hidden
  98524. * Backing Filed
  98525. */
  98526. _selectionOctree: Octree<AbstractMesh>;
  98527. /**
  98528. * Gets the octree used to boost mesh selection (picking)
  98529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98530. */
  98531. selectionOctree: Octree<AbstractMesh>;
  98532. /**
  98533. * Creates or updates the octree used to boost selection (picking)
  98534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98535. * @param maxCapacity defines the maximum capacity per leaf
  98536. * @param maxDepth defines the maximum depth of the octree
  98537. * @returns an octree of AbstractMesh
  98538. */
  98539. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98540. }
  98541. interface AbstractMesh {
  98542. /**
  98543. * @hidden
  98544. * Backing Field
  98545. */
  98546. _submeshesOctree: Octree<SubMesh>;
  98547. /**
  98548. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98549. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98550. * @param maxCapacity defines the maximum size of each block (64 by default)
  98551. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98552. * @returns the new octree
  98553. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98554. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98555. */
  98556. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98557. }
  98558. /**
  98559. * Defines the octree scene component responsible to manage any octrees
  98560. * in a given scene.
  98561. */
  98562. export class OctreeSceneComponent {
  98563. /**
  98564. * The component name helpfull to identify the component in the list of scene components.
  98565. */
  98566. readonly name: string;
  98567. /**
  98568. * The scene the component belongs to.
  98569. */
  98570. scene: Scene;
  98571. /**
  98572. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98573. */
  98574. readonly checksIsEnabled: boolean;
  98575. /**
  98576. * Creates a new instance of the component for the given scene
  98577. * @param scene Defines the scene to register the component in
  98578. */
  98579. constructor(scene: Scene);
  98580. /**
  98581. * Registers the component in a given scene
  98582. */
  98583. register(): void;
  98584. /**
  98585. * Return the list of active meshes
  98586. * @returns the list of active meshes
  98587. */
  98588. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98589. /**
  98590. * Return the list of active sub meshes
  98591. * @param mesh The mesh to get the candidates sub meshes from
  98592. * @returns the list of active sub meshes
  98593. */
  98594. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98595. private _tempRay;
  98596. /**
  98597. * Return the list of sub meshes intersecting with a given local ray
  98598. * @param mesh defines the mesh to find the submesh for
  98599. * @param localRay defines the ray in local space
  98600. * @returns the list of intersecting sub meshes
  98601. */
  98602. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98603. /**
  98604. * Return the list of sub meshes colliding with a collider
  98605. * @param mesh defines the mesh to find the submesh for
  98606. * @param collider defines the collider to evaluate the collision against
  98607. * @returns the list of colliding sub meshes
  98608. */
  98609. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98610. /**
  98611. * Rebuilds the elements related to this component in case of
  98612. * context lost for instance.
  98613. */
  98614. rebuild(): void;
  98615. /**
  98616. * Disposes the component and the associated ressources.
  98617. */
  98618. dispose(): void;
  98619. }
  98620. }
  98621. declare module BABYLON {
  98622. /**
  98623. * Class containing static functions to help procedurally build meshes
  98624. */
  98625. export class LinesBuilder {
  98626. /**
  98627. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98628. * * 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
  98629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98630. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98631. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98632. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98633. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98634. * * 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
  98635. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98638. * @param name defines the name of the new line system
  98639. * @param options defines the options used to create the line system
  98640. * @param scene defines the hosting scene
  98641. * @returns a new line system mesh
  98642. */
  98643. static CreateLineSystem(name: string, options: {
  98644. lines: Vector3[][];
  98645. updatable?: boolean;
  98646. instance?: Nullable<LinesMesh>;
  98647. colors?: Nullable<Color4[][]>;
  98648. useVertexAlpha?: boolean;
  98649. }, scene: Nullable<Scene>): LinesMesh;
  98650. /**
  98651. * Creates a line mesh
  98652. * 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
  98653. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98654. * * The parameter `points` is an array successive Vector3
  98655. * * 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
  98656. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98657. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98658. * * When updating an instance, remember that only point positions can change, not the number of points
  98659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98661. * @param name defines the name of the new line system
  98662. * @param options defines the options used to create the line system
  98663. * @param scene defines the hosting scene
  98664. * @returns a new line mesh
  98665. */
  98666. static CreateLines(name: string, options: {
  98667. points: Vector3[];
  98668. updatable?: boolean;
  98669. instance?: Nullable<LinesMesh>;
  98670. colors?: Color4[];
  98671. useVertexAlpha?: boolean;
  98672. }, scene?: Nullable<Scene>): LinesMesh;
  98673. /**
  98674. * Creates a dashed line mesh
  98675. * * 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
  98676. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98677. * * The parameter `points` is an array successive Vector3
  98678. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98679. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98680. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98681. * * 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
  98682. * * When updating an instance, remember that only point positions can change, not the number of points
  98683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98684. * @param name defines the name of the mesh
  98685. * @param options defines the options used to create the mesh
  98686. * @param scene defines the hosting scene
  98687. * @returns the dashed line mesh
  98688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98689. */
  98690. static CreateDashedLines(name: string, options: {
  98691. points: Vector3[];
  98692. dashSize?: number;
  98693. gapSize?: number;
  98694. dashNb?: number;
  98695. updatable?: boolean;
  98696. instance?: LinesMesh;
  98697. }, scene?: Nullable<Scene>): LinesMesh;
  98698. }
  98699. }
  98700. declare module BABYLON {
  98701. /**
  98702. * Renders a layer on top of an existing scene
  98703. */
  98704. export class UtilityLayerRenderer implements IDisposable {
  98705. /** the original scene that will be rendered on top of */
  98706. originalScene: Scene;
  98707. private _pointerCaptures;
  98708. private _lastPointerEvents;
  98709. private static _DefaultUtilityLayer;
  98710. private static _DefaultKeepDepthUtilityLayer;
  98711. /**
  98712. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98713. */
  98714. pickUtilitySceneFirst: boolean;
  98715. /**
  98716. * 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)
  98717. */
  98718. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98719. /**
  98720. * 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)
  98721. */
  98722. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98723. /**
  98724. * The scene that is rendered on top of the original scene
  98725. */
  98726. utilityLayerScene: Scene;
  98727. /**
  98728. * If the utility layer should automatically be rendered on top of existing scene
  98729. */
  98730. shouldRender: boolean;
  98731. /**
  98732. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98733. */
  98734. onlyCheckPointerDownEvents: boolean;
  98735. /**
  98736. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98737. */
  98738. processAllEvents: boolean;
  98739. /**
  98740. * Observable raised when the pointer move from the utility layer scene to the main scene
  98741. */
  98742. onPointerOutObservable: Observable<number>;
  98743. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98744. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98745. private _afterRenderObserver;
  98746. private _sceneDisposeObserver;
  98747. private _originalPointerObserver;
  98748. /**
  98749. * Instantiates a UtilityLayerRenderer
  98750. * @param originalScene the original scene that will be rendered on top of
  98751. * @param handleEvents boolean indicating if the utility layer should handle events
  98752. */
  98753. constructor(
  98754. /** the original scene that will be rendered on top of */
  98755. originalScene: Scene, handleEvents?: boolean);
  98756. private _notifyObservers;
  98757. /**
  98758. * Renders the utility layers scene on top of the original scene
  98759. */
  98760. render(): void;
  98761. /**
  98762. * Disposes of the renderer
  98763. */
  98764. dispose(): void;
  98765. private _updateCamera;
  98766. }
  98767. }
  98768. declare module BABYLON {
  98769. /**
  98770. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  98771. */
  98772. export class Gizmo implements IDisposable {
  98773. /** The utility layer the gizmo will be added to */
  98774. gizmoLayer: UtilityLayerRenderer;
  98775. /**
  98776. * The root mesh of the gizmo
  98777. */
  98778. _rootMesh: Mesh;
  98779. private _attachedMesh;
  98780. /**
  98781. * Ratio for the scale of the gizmo (Default: 1)
  98782. */
  98783. scaleRatio: number;
  98784. private _tmpMatrix;
  98785. /**
  98786. * If a custom mesh has been set (Default: false)
  98787. */
  98788. protected _customMeshSet: boolean;
  98789. /**
  98790. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  98791. * * When set, interactions will be enabled
  98792. */
  98793. attachedMesh: Nullable<AbstractMesh>;
  98794. /**
  98795. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98796. * @param mesh The mesh to replace the default mesh of the gizmo
  98797. */
  98798. setCustomMesh(mesh: Mesh): void;
  98799. /**
  98800. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  98801. */
  98802. updateGizmoRotationToMatchAttachedMesh: boolean;
  98803. /**
  98804. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  98805. */
  98806. updateGizmoPositionToMatchAttachedMesh: boolean;
  98807. /**
  98808. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  98809. */
  98810. protected _updateScale: boolean;
  98811. protected _interactionsEnabled: boolean;
  98812. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98813. private _beforeRenderObserver;
  98814. /**
  98815. * Creates a gizmo
  98816. * @param gizmoLayer The utility layer the gizmo will be added to
  98817. */
  98818. constructor(
  98819. /** The utility layer the gizmo will be added to */
  98820. gizmoLayer?: UtilityLayerRenderer);
  98821. private _tempVector;
  98822. /**
  98823. * @hidden
  98824. * Updates the gizmo to match the attached mesh's position/rotation
  98825. */
  98826. protected _update(): void;
  98827. /**
  98828. * Disposes of the gizmo
  98829. */
  98830. dispose(): void;
  98831. }
  98832. }
  98833. declare module BABYLON {
  98834. /**
  98835. * Single axis drag gizmo
  98836. */
  98837. export class AxisDragGizmo extends Gizmo {
  98838. /**
  98839. * Drag behavior responsible for the gizmos dragging interactions
  98840. */
  98841. dragBehavior: PointerDragBehavior;
  98842. private _pointerObserver;
  98843. /**
  98844. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98845. */
  98846. snapDistance: number;
  98847. /**
  98848. * Event that fires each time the gizmo snaps to a new location.
  98849. * * snapDistance is the the change in distance
  98850. */
  98851. onSnapObservable: Observable<{
  98852. snapDistance: number;
  98853. }>;
  98854. /** @hidden */
  98855. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  98856. /** @hidden */
  98857. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  98858. /**
  98859. * Creates an AxisDragGizmo
  98860. * @param gizmoLayer The utility layer the gizmo will be added to
  98861. * @param dragAxis The axis which the gizmo will be able to drag on
  98862. * @param color The color of the gizmo
  98863. */
  98864. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98865. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98866. /**
  98867. * Disposes of the gizmo
  98868. */
  98869. dispose(): void;
  98870. }
  98871. }
  98872. declare module BABYLON.Debug {
  98873. /**
  98874. * The Axes viewer will show 3 axes in a specific point in space
  98875. */
  98876. export class AxesViewer {
  98877. private _xAxis;
  98878. private _yAxis;
  98879. private _zAxis;
  98880. private _scaleLinesFactor;
  98881. private _instanced;
  98882. /**
  98883. * Gets the hosting scene
  98884. */
  98885. scene: Scene;
  98886. /**
  98887. * Gets or sets a number used to scale line length
  98888. */
  98889. scaleLines: number;
  98890. /** Gets the node hierarchy used to render x-axis */
  98891. readonly xAxis: TransformNode;
  98892. /** Gets the node hierarchy used to render y-axis */
  98893. readonly yAxis: TransformNode;
  98894. /** Gets the node hierarchy used to render z-axis */
  98895. readonly zAxis: TransformNode;
  98896. /**
  98897. * Creates a new AxesViewer
  98898. * @param scene defines the hosting scene
  98899. * @param scaleLines defines a number used to scale line length (1 by default)
  98900. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  98901. * @param xAxis defines the node hierarchy used to render the x-axis
  98902. * @param yAxis defines the node hierarchy used to render the y-axis
  98903. * @param zAxis defines the node hierarchy used to render the z-axis
  98904. */
  98905. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  98906. /**
  98907. * Force the viewer to update
  98908. * @param position defines the position of the viewer
  98909. * @param xaxis defines the x axis of the viewer
  98910. * @param yaxis defines the y axis of the viewer
  98911. * @param zaxis defines the z axis of the viewer
  98912. */
  98913. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  98914. /**
  98915. * Creates an instance of this axes viewer.
  98916. * @returns a new axes viewer with instanced meshes
  98917. */
  98918. createInstance(): AxesViewer;
  98919. /** Releases resources */
  98920. dispose(): void;
  98921. private static _SetRenderingGroupId;
  98922. }
  98923. }
  98924. declare module BABYLON.Debug {
  98925. /**
  98926. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  98927. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  98928. */
  98929. export class BoneAxesViewer extends AxesViewer {
  98930. /**
  98931. * Gets or sets the target mesh where to display the axes viewer
  98932. */
  98933. mesh: Nullable<Mesh>;
  98934. /**
  98935. * Gets or sets the target bone where to display the axes viewer
  98936. */
  98937. bone: Nullable<Bone>;
  98938. /** Gets current position */
  98939. pos: Vector3;
  98940. /** Gets direction of X axis */
  98941. xaxis: Vector3;
  98942. /** Gets direction of Y axis */
  98943. yaxis: Vector3;
  98944. /** Gets direction of Z axis */
  98945. zaxis: Vector3;
  98946. /**
  98947. * Creates a new BoneAxesViewer
  98948. * @param scene defines the hosting scene
  98949. * @param bone defines the target bone
  98950. * @param mesh defines the target mesh
  98951. * @param scaleLines defines a scaling factor for line length (1 by default)
  98952. */
  98953. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  98954. /**
  98955. * Force the viewer to update
  98956. */
  98957. update(): void;
  98958. /** Releases resources */
  98959. dispose(): void;
  98960. }
  98961. }
  98962. declare module BABYLON {
  98963. /**
  98964. * Interface used to define scene explorer extensibility option
  98965. */
  98966. export interface IExplorerExtensibilityOption {
  98967. /**
  98968. * Define the option label
  98969. */
  98970. label: string;
  98971. /**
  98972. * Defines the action to execute on click
  98973. */
  98974. action: (entity: any) => void;
  98975. }
  98976. /**
  98977. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98978. */
  98979. export interface IExplorerExtensibilityGroup {
  98980. /**
  98981. * Defines a predicate to test if a given type mut be extended
  98982. */
  98983. predicate: (entity: any) => boolean;
  98984. /**
  98985. * Gets the list of options added to a type
  98986. */
  98987. entries: IExplorerExtensibilityOption[];
  98988. }
  98989. /**
  98990. * Interface used to define the options to use to create the Inspector
  98991. */
  98992. export interface IInspectorOptions {
  98993. /**
  98994. * Display in overlay mode (default: false)
  98995. */
  98996. overlay?: boolean;
  98997. /**
  98998. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  98999. */
  99000. globalRoot?: HTMLElement;
  99001. /**
  99002. * Display the Scene explorer
  99003. */
  99004. showExplorer?: boolean;
  99005. /**
  99006. * Display the property inspector
  99007. */
  99008. showInspector?: boolean;
  99009. /**
  99010. * Display in embed mode (both panes on the right)
  99011. */
  99012. embedMode?: boolean;
  99013. /**
  99014. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  99015. */
  99016. handleResize?: boolean;
  99017. /**
  99018. * Allow the panes to popup (default: true)
  99019. */
  99020. enablePopup?: boolean;
  99021. /**
  99022. * Allow the panes to be closed by users (default: true)
  99023. */
  99024. enableClose?: boolean;
  99025. /**
  99026. * Optional list of extensibility entries
  99027. */
  99028. explorerExtensibility?: IExplorerExtensibilityGroup[];
  99029. /**
  99030. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  99031. */
  99032. inspectorURL?: string;
  99033. }
  99034. interface Scene {
  99035. /**
  99036. * @hidden
  99037. * Backing field
  99038. */
  99039. _debugLayer: DebugLayer;
  99040. /**
  99041. * Gets the debug layer (aka Inspector) associated with the scene
  99042. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99043. */
  99044. debugLayer: DebugLayer;
  99045. }
  99046. /**
  99047. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99048. * what is happening in your scene
  99049. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99050. */
  99051. export class DebugLayer {
  99052. /**
  99053. * Define the url to get the inspector script from.
  99054. * By default it uses the babylonjs CDN.
  99055. * @ignoreNaming
  99056. */
  99057. static InspectorURL: string;
  99058. private _scene;
  99059. private BJSINSPECTOR;
  99060. /**
  99061. * Observable triggered when a property is changed through the inspector.
  99062. */
  99063. onPropertyChangedObservable: Observable<{
  99064. object: any;
  99065. property: string;
  99066. value: any;
  99067. initialValue: any;
  99068. }>;
  99069. /**
  99070. * Instantiates a new debug layer.
  99071. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99072. * what is happening in your scene
  99073. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99074. * @param scene Defines the scene to inspect
  99075. */
  99076. constructor(scene: Scene);
  99077. /** Creates the inspector window. */
  99078. private _createInspector;
  99079. /**
  99080. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99081. * @param entity defines the entity to select
  99082. * @param lineContainerTitle defines the specific block to highlight
  99083. */
  99084. select(entity: any, lineContainerTitle?: string): void;
  99085. /** Get the inspector from bundle or global */
  99086. private _getGlobalInspector;
  99087. /**
  99088. * Get if the inspector is visible or not.
  99089. * @returns true if visible otherwise, false
  99090. */
  99091. isVisible(): boolean;
  99092. /**
  99093. * Hide the inspector and close its window.
  99094. */
  99095. hide(): void;
  99096. /**
  99097. * Launch the debugLayer.
  99098. * @param config Define the configuration of the inspector
  99099. * @return a promise fulfilled when the debug layer is visible
  99100. */
  99101. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99102. }
  99103. }
  99104. declare module BABYLON {
  99105. /**
  99106. * Class containing static functions to help procedurally build meshes
  99107. */
  99108. export class BoxBuilder {
  99109. /**
  99110. * Creates a box mesh
  99111. * * The parameter `size` sets the size (float) of each box side (default 1)
  99112. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99113. * * 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)
  99114. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99118. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99119. * @param name defines the name of the mesh
  99120. * @param options defines the options used to create the mesh
  99121. * @param scene defines the hosting scene
  99122. * @returns the box mesh
  99123. */
  99124. static CreateBox(name: string, options: {
  99125. size?: number;
  99126. width?: number;
  99127. height?: number;
  99128. depth?: number;
  99129. faceUV?: Vector4[];
  99130. faceColors?: Color4[];
  99131. sideOrientation?: number;
  99132. frontUVs?: Vector4;
  99133. backUVs?: Vector4;
  99134. updatable?: boolean;
  99135. }, scene?: Nullable<Scene>): Mesh;
  99136. }
  99137. }
  99138. declare module BABYLON {
  99139. /**
  99140. * Class containing static functions to help procedurally build meshes
  99141. */
  99142. export class SphereBuilder {
  99143. /**
  99144. * Creates a sphere mesh
  99145. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99146. * * 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`)
  99147. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99148. * * 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
  99149. * * 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)
  99150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99153. * @param name defines the name of the mesh
  99154. * @param options defines the options used to create the mesh
  99155. * @param scene defines the hosting scene
  99156. * @returns the sphere mesh
  99157. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99158. */
  99159. static CreateSphere(name: string, options: {
  99160. segments?: number;
  99161. diameter?: number;
  99162. diameterX?: number;
  99163. diameterY?: number;
  99164. diameterZ?: number;
  99165. arc?: number;
  99166. slice?: number;
  99167. sideOrientation?: number;
  99168. frontUVs?: Vector4;
  99169. backUVs?: Vector4;
  99170. updatable?: boolean;
  99171. }, scene: any): Mesh;
  99172. }
  99173. }
  99174. declare module BABYLON.Debug {
  99175. /**
  99176. * Used to show the physics impostor around the specific mesh
  99177. */
  99178. export class PhysicsViewer {
  99179. /** @hidden */
  99180. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99181. /** @hidden */
  99182. protected _meshes: Array<Nullable<AbstractMesh>>;
  99183. /** @hidden */
  99184. protected _scene: Nullable<Scene>;
  99185. /** @hidden */
  99186. protected _numMeshes: number;
  99187. /** @hidden */
  99188. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99189. private _renderFunction;
  99190. private _utilityLayer;
  99191. private _debugBoxMesh;
  99192. private _debugSphereMesh;
  99193. private _debugMaterial;
  99194. /**
  99195. * Creates a new PhysicsViewer
  99196. * @param scene defines the hosting scene
  99197. */
  99198. constructor(scene: Scene);
  99199. /** @hidden */
  99200. protected _updateDebugMeshes(): void;
  99201. /**
  99202. * Renders a specified physic impostor
  99203. * @param impostor defines the impostor to render
  99204. * @returns the new debug mesh used to render the impostor
  99205. */
  99206. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  99207. /**
  99208. * Hides a specified physic impostor
  99209. * @param impostor defines the impostor to hide
  99210. */
  99211. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99212. private _getDebugMaterial;
  99213. private _getDebugBoxMesh;
  99214. private _getDebugSphereMesh;
  99215. private _getDebugMesh;
  99216. /** Releases all resources */
  99217. dispose(): void;
  99218. }
  99219. }
  99220. declare module BABYLON {
  99221. /**
  99222. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99223. * in order to better appreciate the issue one might have.
  99224. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99225. */
  99226. export class RayHelper {
  99227. /**
  99228. * Defines the ray we are currently tryin to visualize.
  99229. */
  99230. ray: Nullable<Ray>;
  99231. private _renderPoints;
  99232. private _renderLine;
  99233. private _renderFunction;
  99234. private _scene;
  99235. private _updateToMeshFunction;
  99236. private _attachedToMesh;
  99237. private _meshSpaceDirection;
  99238. private _meshSpaceOrigin;
  99239. /**
  99240. * Helper function to create a colored helper in a scene in one line.
  99241. * @param ray Defines the ray we are currently tryin to visualize
  99242. * @param scene Defines the scene the ray is used in
  99243. * @param color Defines the color we want to see the ray in
  99244. * @returns The newly created ray helper.
  99245. */
  99246. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99247. /**
  99248. * Instantiate a new ray helper.
  99249. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99250. * in order to better appreciate the issue one might have.
  99251. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99252. * @param ray Defines the ray we are currently tryin to visualize
  99253. */
  99254. constructor(ray: Ray);
  99255. /**
  99256. * Shows the ray we are willing to debug.
  99257. * @param scene Defines the scene the ray needs to be rendered in
  99258. * @param color Defines the color the ray needs to be rendered in
  99259. */
  99260. show(scene: Scene, color?: Color3): void;
  99261. /**
  99262. * Hides the ray we are debugging.
  99263. */
  99264. hide(): void;
  99265. private _render;
  99266. /**
  99267. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99268. * @param mesh Defines the mesh we want the helper attached to
  99269. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99270. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99271. * @param length Defines the length of the ray
  99272. */
  99273. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99274. /**
  99275. * Detach the ray helper from the mesh it has previously been attached to.
  99276. */
  99277. detachFromMesh(): void;
  99278. private _updateToMesh;
  99279. /**
  99280. * Dispose the helper and release its associated resources.
  99281. */
  99282. dispose(): void;
  99283. }
  99284. }
  99285. declare module BABYLON.Debug {
  99286. /**
  99287. * Class used to render a debug view of a given skeleton
  99288. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99289. */
  99290. export class SkeletonViewer {
  99291. /** defines the skeleton to render */
  99292. skeleton: Skeleton;
  99293. /** defines the mesh attached to the skeleton */
  99294. mesh: AbstractMesh;
  99295. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99296. autoUpdateBonesMatrices: boolean;
  99297. /** defines the rendering group id to use with the viewer */
  99298. renderingGroupId: number;
  99299. /** Gets or sets the color used to render the skeleton */
  99300. color: Color3;
  99301. private _scene;
  99302. private _debugLines;
  99303. private _debugMesh;
  99304. private _isEnabled;
  99305. private _renderFunction;
  99306. private _utilityLayer;
  99307. /**
  99308. * Returns the mesh used to render the bones
  99309. */
  99310. readonly debugMesh: Nullable<LinesMesh>;
  99311. /**
  99312. * Creates a new SkeletonViewer
  99313. * @param skeleton defines the skeleton to render
  99314. * @param mesh defines the mesh attached to the skeleton
  99315. * @param scene defines the hosting scene
  99316. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99317. * @param renderingGroupId defines the rendering group id to use with the viewer
  99318. */
  99319. constructor(
  99320. /** defines the skeleton to render */
  99321. skeleton: Skeleton,
  99322. /** defines the mesh attached to the skeleton */
  99323. mesh: AbstractMesh, scene: Scene,
  99324. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99325. autoUpdateBonesMatrices?: boolean,
  99326. /** defines the rendering group id to use with the viewer */
  99327. renderingGroupId?: number);
  99328. /** Gets or sets a boolean indicating if the viewer is enabled */
  99329. isEnabled: boolean;
  99330. private _getBonePosition;
  99331. private _getLinesForBonesWithLength;
  99332. private _getLinesForBonesNoLength;
  99333. /** Update the viewer to sync with current skeleton state */
  99334. update(): void;
  99335. /** Release associated resources */
  99336. dispose(): void;
  99337. }
  99338. }
  99339. declare module BABYLON {
  99340. /**
  99341. * Options to create the null engine
  99342. */
  99343. export class NullEngineOptions {
  99344. /**
  99345. * Render width (Default: 512)
  99346. */
  99347. renderWidth: number;
  99348. /**
  99349. * Render height (Default: 256)
  99350. */
  99351. renderHeight: number;
  99352. /**
  99353. * Texture size (Default: 512)
  99354. */
  99355. textureSize: number;
  99356. /**
  99357. * If delta time between frames should be constant
  99358. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99359. */
  99360. deterministicLockstep: boolean;
  99361. /**
  99362. * Maximum about of steps between frames (Default: 4)
  99363. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99364. */
  99365. lockstepMaxSteps: number;
  99366. }
  99367. /**
  99368. * The null engine class provides support for headless version of babylon.js.
  99369. * This can be used in server side scenario or for testing purposes
  99370. */
  99371. export class NullEngine extends Engine {
  99372. private _options;
  99373. /**
  99374. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99375. */
  99376. isDeterministicLockStep(): boolean;
  99377. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99378. getLockstepMaxSteps(): number;
  99379. /**
  99380. * Sets hardware scaling, used to save performance if needed
  99381. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99382. */
  99383. getHardwareScalingLevel(): number;
  99384. constructor(options?: NullEngineOptions);
  99385. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99386. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99387. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99388. getRenderWidth(useScreen?: boolean): number;
  99389. getRenderHeight(useScreen?: boolean): number;
  99390. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99391. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99392. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99393. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99394. bindSamplers(effect: Effect): void;
  99395. enableEffect(effect: Effect): void;
  99396. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99397. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99398. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99399. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99400. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99401. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99402. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99403. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99404. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99405. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99406. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99407. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99408. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99409. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99410. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99411. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99412. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99413. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99414. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99415. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99416. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99417. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99418. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99419. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99420. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99421. bindBuffers(vertexBuffers: {
  99422. [key: string]: VertexBuffer;
  99423. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99424. wipeCaches(bruteForce?: boolean): void;
  99425. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99426. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99427. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99428. /** @hidden */
  99429. _createTexture(): WebGLTexture;
  99430. /** @hidden */
  99431. _releaseTexture(texture: InternalTexture): void;
  99432. 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;
  99433. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99434. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99435. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99436. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99437. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99438. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99439. areAllEffectsReady(): boolean;
  99440. /**
  99441. * @hidden
  99442. * Get the current error code of the webGL context
  99443. * @returns the error code
  99444. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99445. */
  99446. getError(): number;
  99447. /** @hidden */
  99448. _getUnpackAlignement(): number;
  99449. /** @hidden */
  99450. _unpackFlipY(value: boolean): void;
  99451. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99452. /**
  99453. * Updates a dynamic vertex buffer.
  99454. * @param vertexBuffer the vertex buffer to update
  99455. * @param data the data used to update the vertex buffer
  99456. * @param byteOffset the byte offset of the data (optional)
  99457. * @param byteLength the byte length of the data (optional)
  99458. */
  99459. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99460. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99461. /** @hidden */
  99462. _bindTexture(channel: number, texture: InternalTexture): void;
  99463. /** @hidden */
  99464. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99465. releaseEffects(): void;
  99466. displayLoadingUI(): void;
  99467. hideLoadingUI(): void;
  99468. /** @hidden */
  99469. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99470. /** @hidden */
  99471. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99472. /** @hidden */
  99473. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99474. /** @hidden */
  99475. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99476. }
  99477. }
  99478. declare module BABYLON {
  99479. /** @hidden */
  99480. export class _OcclusionDataStorage {
  99481. /** @hidden */
  99482. occlusionInternalRetryCounter: number;
  99483. /** @hidden */
  99484. isOcclusionQueryInProgress: boolean;
  99485. /** @hidden */
  99486. isOccluded: boolean;
  99487. /** @hidden */
  99488. occlusionRetryCount: number;
  99489. /** @hidden */
  99490. occlusionType: number;
  99491. /** @hidden */
  99492. occlusionQueryAlgorithmType: number;
  99493. }
  99494. interface Engine {
  99495. /**
  99496. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99497. * @return the new query
  99498. */
  99499. createQuery(): WebGLQuery;
  99500. /**
  99501. * Delete and release a webGL query
  99502. * @param query defines the query to delete
  99503. * @return the current engine
  99504. */
  99505. deleteQuery(query: WebGLQuery): Engine;
  99506. /**
  99507. * Check if a given query has resolved and got its value
  99508. * @param query defines the query to check
  99509. * @returns true if the query got its value
  99510. */
  99511. isQueryResultAvailable(query: WebGLQuery): boolean;
  99512. /**
  99513. * Gets the value of a given query
  99514. * @param query defines the query to check
  99515. * @returns the value of the query
  99516. */
  99517. getQueryResult(query: WebGLQuery): number;
  99518. /**
  99519. * Initiates an occlusion query
  99520. * @param algorithmType defines the algorithm to use
  99521. * @param query defines the query to use
  99522. * @returns the current engine
  99523. * @see http://doc.babylonjs.com/features/occlusionquery
  99524. */
  99525. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99526. /**
  99527. * Ends an occlusion query
  99528. * @see http://doc.babylonjs.com/features/occlusionquery
  99529. * @param algorithmType defines the algorithm to use
  99530. * @returns the current engine
  99531. */
  99532. endOcclusionQuery(algorithmType: number): Engine;
  99533. /**
  99534. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99535. * Please note that only one query can be issued at a time
  99536. * @returns a time token used to track the time span
  99537. */
  99538. startTimeQuery(): Nullable<_TimeToken>;
  99539. /**
  99540. * Ends a time query
  99541. * @param token defines the token used to measure the time span
  99542. * @returns the time spent (in ns)
  99543. */
  99544. endTimeQuery(token: _TimeToken): int;
  99545. /** @hidden */
  99546. _currentNonTimestampToken: Nullable<_TimeToken>;
  99547. /** @hidden */
  99548. _createTimeQuery(): WebGLQuery;
  99549. /** @hidden */
  99550. _deleteTimeQuery(query: WebGLQuery): void;
  99551. /** @hidden */
  99552. _getGlAlgorithmType(algorithmType: number): number;
  99553. /** @hidden */
  99554. _getTimeQueryResult(query: WebGLQuery): any;
  99555. /** @hidden */
  99556. _getTimeQueryAvailability(query: WebGLQuery): any;
  99557. }
  99558. interface AbstractMesh {
  99559. /**
  99560. * Backing filed
  99561. * @hidden
  99562. */
  99563. __occlusionDataStorage: _OcclusionDataStorage;
  99564. /**
  99565. * Access property
  99566. * @hidden
  99567. */
  99568. _occlusionDataStorage: _OcclusionDataStorage;
  99569. /**
  99570. * 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.
  99571. * The default value is -1 which means don't break the query and wait till the result
  99572. * @see http://doc.babylonjs.com/features/occlusionquery
  99573. */
  99574. occlusionRetryCount: number;
  99575. /**
  99576. * 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:
  99577. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99578. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99579. * * 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.
  99580. * @see http://doc.babylonjs.com/features/occlusionquery
  99581. */
  99582. occlusionType: number;
  99583. /**
  99584. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99585. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99586. * * 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.
  99587. * @see http://doc.babylonjs.com/features/occlusionquery
  99588. */
  99589. occlusionQueryAlgorithmType: number;
  99590. /**
  99591. * 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
  99592. * @see http://doc.babylonjs.com/features/occlusionquery
  99593. */
  99594. isOccluded: boolean;
  99595. /**
  99596. * Flag to check the progress status of the query
  99597. * @see http://doc.babylonjs.com/features/occlusionquery
  99598. */
  99599. isOcclusionQueryInProgress: boolean;
  99600. }
  99601. }
  99602. declare module BABYLON {
  99603. /** @hidden */
  99604. export var _forceTransformFeedbackToBundle: boolean;
  99605. interface Engine {
  99606. /**
  99607. * Creates a webGL transform feedback object
  99608. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99609. * @returns the webGL transform feedback object
  99610. */
  99611. createTransformFeedback(): WebGLTransformFeedback;
  99612. /**
  99613. * Delete a webGL transform feedback object
  99614. * @param value defines the webGL transform feedback object to delete
  99615. */
  99616. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99617. /**
  99618. * Bind a webGL transform feedback object to the webgl context
  99619. * @param value defines the webGL transform feedback object to bind
  99620. */
  99621. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99622. /**
  99623. * Begins a transform feedback operation
  99624. * @param usePoints defines if points or triangles must be used
  99625. */
  99626. beginTransformFeedback(usePoints: boolean): void;
  99627. /**
  99628. * Ends a transform feedback operation
  99629. */
  99630. endTransformFeedback(): void;
  99631. /**
  99632. * Specify the varyings to use with transform feedback
  99633. * @param program defines the associated webGL program
  99634. * @param value defines the list of strings representing the varying names
  99635. */
  99636. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99637. /**
  99638. * Bind a webGL buffer for a transform feedback operation
  99639. * @param value defines the webGL buffer to bind
  99640. */
  99641. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99642. }
  99643. }
  99644. declare module BABYLON {
  99645. /**
  99646. * Gather the list of clipboard event types as constants.
  99647. */
  99648. export class ClipboardEventTypes {
  99649. /**
  99650. * The clipboard event is fired when a copy command is active (pressed).
  99651. */
  99652. static readonly COPY: number;
  99653. /**
  99654. * The clipboard event is fired when a cut command is active (pressed).
  99655. */
  99656. static readonly CUT: number;
  99657. /**
  99658. * The clipboard event is fired when a paste command is active (pressed).
  99659. */
  99660. static readonly PASTE: number;
  99661. }
  99662. /**
  99663. * This class is used to store clipboard related info for the onClipboardObservable event.
  99664. */
  99665. export class ClipboardInfo {
  99666. /**
  99667. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99668. */
  99669. type: number;
  99670. /**
  99671. * Defines the related dom event
  99672. */
  99673. event: ClipboardEvent;
  99674. /**
  99675. *Creates an instance of ClipboardInfo.
  99676. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99677. * @param event Defines the related dom event
  99678. */
  99679. constructor(
  99680. /**
  99681. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99682. */
  99683. type: number,
  99684. /**
  99685. * Defines the related dom event
  99686. */
  99687. event: ClipboardEvent);
  99688. /**
  99689. * Get the clipboard event's type from the keycode.
  99690. * @param keyCode Defines the keyCode for the current keyboard event.
  99691. * @return {number}
  99692. */
  99693. static GetTypeFromCharacter(keyCode: number): number;
  99694. }
  99695. }
  99696. declare module BABYLON {
  99697. /**
  99698. * Class used to represent data loading progression
  99699. */
  99700. export class SceneLoaderProgressEvent {
  99701. /** defines if data length to load can be evaluated */
  99702. readonly lengthComputable: boolean;
  99703. /** defines the loaded data length */
  99704. readonly loaded: number;
  99705. /** defines the data length to load */
  99706. readonly total: number;
  99707. /**
  99708. * Create a new progress event
  99709. * @param lengthComputable defines if data length to load can be evaluated
  99710. * @param loaded defines the loaded data length
  99711. * @param total defines the data length to load
  99712. */
  99713. constructor(
  99714. /** defines if data length to load can be evaluated */
  99715. lengthComputable: boolean,
  99716. /** defines the loaded data length */
  99717. loaded: number,
  99718. /** defines the data length to load */
  99719. total: number);
  99720. /**
  99721. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99722. * @param event defines the source event
  99723. * @returns a new SceneLoaderProgressEvent
  99724. */
  99725. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99726. }
  99727. /**
  99728. * Interface used by SceneLoader plugins to define supported file extensions
  99729. */
  99730. export interface ISceneLoaderPluginExtensions {
  99731. /**
  99732. * Defines the list of supported extensions
  99733. */
  99734. [extension: string]: {
  99735. isBinary: boolean;
  99736. };
  99737. }
  99738. /**
  99739. * Interface used by SceneLoader plugin factory
  99740. */
  99741. export interface ISceneLoaderPluginFactory {
  99742. /**
  99743. * Defines the name of the factory
  99744. */
  99745. name: string;
  99746. /**
  99747. * Function called to create a new plugin
  99748. * @return the new plugin
  99749. */
  99750. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99751. /**
  99752. * Boolean indicating if the plugin can direct load specific data
  99753. */
  99754. canDirectLoad?: (data: string) => boolean;
  99755. }
  99756. /**
  99757. * Interface used to define a SceneLoader plugin
  99758. */
  99759. export interface ISceneLoaderPlugin {
  99760. /**
  99761. * The friendly name of this plugin.
  99762. */
  99763. name: string;
  99764. /**
  99765. * The file extensions supported by this plugin.
  99766. */
  99767. extensions: string | ISceneLoaderPluginExtensions;
  99768. /**
  99769. * Import meshes into a scene.
  99770. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99771. * @param scene The scene to import into
  99772. * @param data The data to import
  99773. * @param rootUrl The root url for scene and resources
  99774. * @param meshes The meshes array to import into
  99775. * @param particleSystems The particle systems array to import into
  99776. * @param skeletons The skeletons array to import into
  99777. * @param onError The callback when import fails
  99778. * @returns True if successful or false otherwise
  99779. */
  99780. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  99781. /**
  99782. * Load into a scene.
  99783. * @param scene The scene to load into
  99784. * @param data The data to import
  99785. * @param rootUrl The root url for scene and resources
  99786. * @param onError The callback when import fails
  99787. * @returns true if successful or false otherwise
  99788. */
  99789. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  99790. /**
  99791. * The callback that returns true if the data can be directly loaded.
  99792. */
  99793. canDirectLoad?: (data: string) => boolean;
  99794. /**
  99795. * The callback that allows custom handling of the root url based on the response url.
  99796. */
  99797. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99798. /**
  99799. * Load into an asset container.
  99800. * @param scene The scene to load into
  99801. * @param data The data to import
  99802. * @param rootUrl The root url for scene and resources
  99803. * @param onError The callback when import fails
  99804. * @returns The loaded asset container
  99805. */
  99806. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  99807. }
  99808. /**
  99809. * Interface used to define an async SceneLoader plugin
  99810. */
  99811. export interface ISceneLoaderPluginAsync {
  99812. /**
  99813. * The friendly name of this plugin.
  99814. */
  99815. name: string;
  99816. /**
  99817. * The file extensions supported by this plugin.
  99818. */
  99819. extensions: string | ISceneLoaderPluginExtensions;
  99820. /**
  99821. * Import meshes into a scene.
  99822. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99823. * @param scene The scene to import into
  99824. * @param data The data to import
  99825. * @param rootUrl The root url for scene and resources
  99826. * @param onProgress The callback when the load progresses
  99827. * @param fileName Defines the name of the file to load
  99828. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  99829. */
  99830. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  99831. meshes: AbstractMesh[];
  99832. particleSystems: IParticleSystem[];
  99833. skeletons: Skeleton[];
  99834. animationGroups: AnimationGroup[];
  99835. }>;
  99836. /**
  99837. * Load into a scene.
  99838. * @param scene The scene to load into
  99839. * @param data The data to import
  99840. * @param rootUrl The root url for scene and resources
  99841. * @param onProgress The callback when the load progresses
  99842. * @param fileName Defines the name of the file to load
  99843. * @returns Nothing
  99844. */
  99845. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  99846. /**
  99847. * The callback that returns true if the data can be directly loaded.
  99848. */
  99849. canDirectLoad?: (data: string) => boolean;
  99850. /**
  99851. * The callback that allows custom handling of the root url based on the response url.
  99852. */
  99853. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99854. /**
  99855. * Load into an asset container.
  99856. * @param scene The scene to load into
  99857. * @param data The data to import
  99858. * @param rootUrl The root url for scene and resources
  99859. * @param onProgress The callback when the load progresses
  99860. * @param fileName Defines the name of the file to load
  99861. * @returns The loaded asset container
  99862. */
  99863. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  99864. }
  99865. /**
  99866. * Class used to load scene from various file formats using registered plugins
  99867. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  99868. */
  99869. export class SceneLoader {
  99870. /**
  99871. * No logging while loading
  99872. */
  99873. static readonly NO_LOGGING: number;
  99874. /**
  99875. * Minimal logging while loading
  99876. */
  99877. static readonly MINIMAL_LOGGING: number;
  99878. /**
  99879. * Summary logging while loading
  99880. */
  99881. static readonly SUMMARY_LOGGING: number;
  99882. /**
  99883. * Detailled logging while loading
  99884. */
  99885. static readonly DETAILED_LOGGING: number;
  99886. /**
  99887. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  99888. */
  99889. static ForceFullSceneLoadingForIncremental: boolean;
  99890. /**
  99891. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  99892. */
  99893. static ShowLoadingScreen: boolean;
  99894. /**
  99895. * Defines the current logging level (while loading the scene)
  99896. * @ignorenaming
  99897. */
  99898. static loggingLevel: number;
  99899. /**
  99900. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  99901. */
  99902. static CleanBoneMatrixWeights: boolean;
  99903. /**
  99904. * Event raised when a plugin is used to load a scene
  99905. */
  99906. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  99907. private static _registeredPlugins;
  99908. private static _getDefaultPlugin;
  99909. private static _getPluginForExtension;
  99910. private static _getPluginForDirectLoad;
  99911. private static _getPluginForFilename;
  99912. private static _getDirectLoad;
  99913. private static _loadData;
  99914. private static _getFileInfo;
  99915. /**
  99916. * Gets a plugin that can load the given extension
  99917. * @param extension defines the extension to load
  99918. * @returns a plugin or null if none works
  99919. */
  99920. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  99921. /**
  99922. * Gets a boolean indicating that the given extension can be loaded
  99923. * @param extension defines the extension to load
  99924. * @returns true if the extension is supported
  99925. */
  99926. static IsPluginForExtensionAvailable(extension: string): boolean;
  99927. /**
  99928. * Adds a new plugin to the list of registered plugins
  99929. * @param plugin defines the plugin to add
  99930. */
  99931. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  99932. /**
  99933. * Import meshes into a scene
  99934. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99935. * @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)
  99936. * @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)
  99937. * @param scene the instance of BABYLON.Scene to append to
  99938. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  99939. * @param onProgress a callback with a progress event for each file being loaded
  99940. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99941. * @param pluginExtension the extension used to determine the plugin
  99942. * @returns The loaded plugin
  99943. */
  99944. 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>;
  99945. /**
  99946. * Import meshes into a scene
  99947. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99948. * @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)
  99949. * @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)
  99950. * @param scene the instance of BABYLON.Scene to append to
  99951. * @param onProgress a callback with a progress event for each file being loaded
  99952. * @param pluginExtension the extension used to determine the plugin
  99953. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  99954. */
  99955. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  99956. meshes: AbstractMesh[];
  99957. particleSystems: IParticleSystem[];
  99958. skeletons: Skeleton[];
  99959. animationGroups: AnimationGroup[];
  99960. }>;
  99961. /**
  99962. * Load a scene
  99963. * @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)
  99964. * @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)
  99965. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99966. * @param onSuccess a callback with the scene when import succeeds
  99967. * @param onProgress a callback with a progress event for each file being loaded
  99968. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99969. * @param pluginExtension the extension used to determine the plugin
  99970. * @returns The loaded plugin
  99971. */
  99972. 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>;
  99973. /**
  99974. * Load a scene
  99975. * @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)
  99976. * @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)
  99977. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99978. * @param onProgress a callback with a progress event for each file being loaded
  99979. * @param pluginExtension the extension used to determine the plugin
  99980. * @returns The loaded scene
  99981. */
  99982. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99983. /**
  99984. * Append a scene
  99985. * @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)
  99986. * @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)
  99987. * @param scene is the instance of BABYLON.Scene to append to
  99988. * @param onSuccess a callback with the scene when import succeeds
  99989. * @param onProgress a callback with a progress event for each file being loaded
  99990. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99991. * @param pluginExtension the extension used to determine the plugin
  99992. * @returns The loaded plugin
  99993. */
  99994. 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>;
  99995. /**
  99996. * Append a scene
  99997. * @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)
  99998. * @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)
  99999. * @param scene is the instance of BABYLON.Scene to append to
  100000. * @param onProgress a callback with a progress event for each file being loaded
  100001. * @param pluginExtension the extension used to determine the plugin
  100002. * @returns The given scene
  100003. */
  100004. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  100005. /**
  100006. * Load a scene into an asset container
  100007. * @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)
  100008. * @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)
  100009. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  100010. * @param onSuccess a callback with the scene when import succeeds
  100011. * @param onProgress a callback with a progress event for each file being loaded
  100012. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  100013. * @param pluginExtension the extension used to determine the plugin
  100014. * @returns The loaded plugin
  100015. */
  100016. 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>;
  100017. /**
  100018. * Load a scene into an asset container
  100019. * @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)
  100020. * @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)
  100021. * @param scene is the instance of Scene to append to
  100022. * @param onProgress a callback with a progress event for each file being loaded
  100023. * @param pluginExtension the extension used to determine the plugin
  100024. * @returns The loaded asset container
  100025. */
  100026. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  100027. }
  100028. }
  100029. declare module BABYLON {
  100030. /**
  100031. * Google Daydream controller
  100032. */
  100033. export class DaydreamController extends WebVRController {
  100034. /**
  100035. * Base Url for the controller model.
  100036. */
  100037. static MODEL_BASE_URL: string;
  100038. /**
  100039. * File name for the controller model.
  100040. */
  100041. static MODEL_FILENAME: string;
  100042. /**
  100043. * Gamepad Id prefix used to identify Daydream Controller.
  100044. */
  100045. static readonly GAMEPAD_ID_PREFIX: string;
  100046. /**
  100047. * Creates a new DaydreamController from a gamepad
  100048. * @param vrGamepad the gamepad that the controller should be created from
  100049. */
  100050. constructor(vrGamepad: any);
  100051. /**
  100052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100053. * @param scene scene in which to add meshes
  100054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100055. */
  100056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100057. /**
  100058. * Called once for each button that changed state since the last frame
  100059. * @param buttonIdx Which button index changed
  100060. * @param state New state of the button
  100061. * @param changes Which properties on the state changed since last frame
  100062. */
  100063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100064. }
  100065. }
  100066. declare module BABYLON {
  100067. /**
  100068. * Gear VR Controller
  100069. */
  100070. export class GearVRController extends WebVRController {
  100071. /**
  100072. * Base Url for the controller model.
  100073. */
  100074. static MODEL_BASE_URL: string;
  100075. /**
  100076. * File name for the controller model.
  100077. */
  100078. static MODEL_FILENAME: string;
  100079. /**
  100080. * Gamepad Id prefix used to identify this controller.
  100081. */
  100082. static readonly GAMEPAD_ID_PREFIX: string;
  100083. private readonly _buttonIndexToObservableNameMap;
  100084. /**
  100085. * Creates a new GearVRController from a gamepad
  100086. * @param vrGamepad the gamepad that the controller should be created from
  100087. */
  100088. constructor(vrGamepad: any);
  100089. /**
  100090. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100091. * @param scene scene in which to add meshes
  100092. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100093. */
  100094. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100095. /**
  100096. * Called once for each button that changed state since the last frame
  100097. * @param buttonIdx Which button index changed
  100098. * @param state New state of the button
  100099. * @param changes Which properties on the state changed since last frame
  100100. */
  100101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100102. }
  100103. }
  100104. declare module BABYLON {
  100105. /**
  100106. * Generic Controller
  100107. */
  100108. export class GenericController extends WebVRController {
  100109. /**
  100110. * Base Url for the controller model.
  100111. */
  100112. static readonly MODEL_BASE_URL: string;
  100113. /**
  100114. * File name for the controller model.
  100115. */
  100116. static readonly MODEL_FILENAME: string;
  100117. /**
  100118. * Creates a new GenericController from a gamepad
  100119. * @param vrGamepad the gamepad that the controller should be created from
  100120. */
  100121. constructor(vrGamepad: any);
  100122. /**
  100123. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100124. * @param scene scene in which to add meshes
  100125. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100126. */
  100127. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100128. /**
  100129. * Called once for each button that changed state since the last frame
  100130. * @param buttonIdx Which button index changed
  100131. * @param state New state of the button
  100132. * @param changes Which properties on the state changed since last frame
  100133. */
  100134. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100135. }
  100136. }
  100137. declare module BABYLON {
  100138. /**
  100139. * Oculus Touch Controller
  100140. */
  100141. export class OculusTouchController extends WebVRController {
  100142. /**
  100143. * Base Url for the controller model.
  100144. */
  100145. static MODEL_BASE_URL: string;
  100146. /**
  100147. * File name for the left controller model.
  100148. */
  100149. static MODEL_LEFT_FILENAME: string;
  100150. /**
  100151. * File name for the right controller model.
  100152. */
  100153. static MODEL_RIGHT_FILENAME: string;
  100154. /**
  100155. * Fired when the secondary trigger on this controller is modified
  100156. */
  100157. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100158. /**
  100159. * Fired when the thumb rest on this controller is modified
  100160. */
  100161. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100162. /**
  100163. * Creates a new OculusTouchController from a gamepad
  100164. * @param vrGamepad the gamepad that the controller should be created from
  100165. */
  100166. constructor(vrGamepad: any);
  100167. /**
  100168. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100169. * @param scene scene in which to add meshes
  100170. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100171. */
  100172. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100173. /**
  100174. * Fired when the A button on this controller is modified
  100175. */
  100176. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100177. /**
  100178. * Fired when the B button on this controller is modified
  100179. */
  100180. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100181. /**
  100182. * Fired when the X button on this controller is modified
  100183. */
  100184. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100185. /**
  100186. * Fired when the Y button on this controller is modified
  100187. */
  100188. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100189. /**
  100190. * Called once for each button that changed state since the last frame
  100191. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  100192. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  100193. * 2) secondary trigger (same)
  100194. * 3) A (right) X (left), touch, pressed = value
  100195. * 4) B / Y
  100196. * 5) thumb rest
  100197. * @param buttonIdx Which button index changed
  100198. * @param state New state of the button
  100199. * @param changes Which properties on the state changed since last frame
  100200. */
  100201. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100202. }
  100203. }
  100204. declare module BABYLON {
  100205. /**
  100206. * Vive Controller
  100207. */
  100208. export class ViveController extends WebVRController {
  100209. /**
  100210. * Base Url for the controller model.
  100211. */
  100212. static MODEL_BASE_URL: string;
  100213. /**
  100214. * File name for the controller model.
  100215. */
  100216. static MODEL_FILENAME: string;
  100217. /**
  100218. * Creates a new ViveController from a gamepad
  100219. * @param vrGamepad the gamepad that the controller should be created from
  100220. */
  100221. constructor(vrGamepad: any);
  100222. /**
  100223. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100224. * @param scene scene in which to add meshes
  100225. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100226. */
  100227. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100228. /**
  100229. * Fired when the left button on this controller is modified
  100230. */
  100231. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100232. /**
  100233. * Fired when the right button on this controller is modified
  100234. */
  100235. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100236. /**
  100237. * Fired when the menu button on this controller is modified
  100238. */
  100239. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100240. /**
  100241. * Called once for each button that changed state since the last frame
  100242. * Vive mapping:
  100243. * 0: touchpad
  100244. * 1: trigger
  100245. * 2: left AND right buttons
  100246. * 3: menu button
  100247. * @param buttonIdx Which button index changed
  100248. * @param state New state of the button
  100249. * @param changes Which properties on the state changed since last frame
  100250. */
  100251. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100252. }
  100253. }
  100254. declare module BABYLON {
  100255. /**
  100256. * Defines the WindowsMotionController object that the state of the windows motion controller
  100257. */
  100258. export class WindowsMotionController extends WebVRController {
  100259. /**
  100260. * The base url used to load the left and right controller models
  100261. */
  100262. static MODEL_BASE_URL: string;
  100263. /**
  100264. * The name of the left controller model file
  100265. */
  100266. static MODEL_LEFT_FILENAME: string;
  100267. /**
  100268. * The name of the right controller model file
  100269. */
  100270. static MODEL_RIGHT_FILENAME: string;
  100271. /**
  100272. * The controller name prefix for this controller type
  100273. */
  100274. static readonly GAMEPAD_ID_PREFIX: string;
  100275. /**
  100276. * The controller id pattern for this controller type
  100277. */
  100278. private static readonly GAMEPAD_ID_PATTERN;
  100279. private _loadedMeshInfo;
  100280. private readonly _mapping;
  100281. /**
  100282. * Fired when the trackpad on this controller is clicked
  100283. */
  100284. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100285. /**
  100286. * Fired when the trackpad on this controller is modified
  100287. */
  100288. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100289. /**
  100290. * The current x and y values of this controller's trackpad
  100291. */
  100292. trackpad: StickValues;
  100293. /**
  100294. * Creates a new WindowsMotionController from a gamepad
  100295. * @param vrGamepad the gamepad that the controller should be created from
  100296. */
  100297. constructor(vrGamepad: any);
  100298. /**
  100299. * Fired when the trigger on this controller is modified
  100300. */
  100301. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100302. /**
  100303. * Fired when the menu button on this controller is modified
  100304. */
  100305. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100306. /**
  100307. * Fired when the grip button on this controller is modified
  100308. */
  100309. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100310. /**
  100311. * Fired when the thumbstick button on this controller is modified
  100312. */
  100313. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100314. /**
  100315. * Fired when the touchpad button on this controller is modified
  100316. */
  100317. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100318. /**
  100319. * Fired when the touchpad values on this controller are modified
  100320. */
  100321. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100322. private _updateTrackpad;
  100323. /**
  100324. * Called once per frame by the engine.
  100325. */
  100326. update(): void;
  100327. /**
  100328. * Called once for each button that changed state since the last frame
  100329. * @param buttonIdx Which button index changed
  100330. * @param state New state of the button
  100331. * @param changes Which properties on the state changed since last frame
  100332. */
  100333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100334. /**
  100335. * Moves the buttons on the controller mesh based on their current state
  100336. * @param buttonName the name of the button to move
  100337. * @param buttonValue the value of the button which determines the buttons new position
  100338. */
  100339. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100340. /**
  100341. * Moves the axis on the controller mesh based on its current state
  100342. * @param axis the index of the axis
  100343. * @param axisValue the value of the axis which determines the meshes new position
  100344. * @hidden
  100345. */
  100346. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100347. /**
  100348. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100349. * @param scene scene in which to add meshes
  100350. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100351. */
  100352. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100353. /**
  100354. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100355. * can be transformed by button presses and axes values, based on this._mapping.
  100356. *
  100357. * @param scene scene in which the meshes exist
  100358. * @param meshes list of meshes that make up the controller model to process
  100359. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100360. */
  100361. private processModel;
  100362. private createMeshInfo;
  100363. /**
  100364. * Gets the ray of the controller in the direction the controller is pointing
  100365. * @param length the length the resulting ray should be
  100366. * @returns a ray in the direction the controller is pointing
  100367. */
  100368. getForwardRay(length?: number): Ray;
  100369. /**
  100370. * Disposes of the controller
  100371. */
  100372. dispose(): void;
  100373. }
  100374. }
  100375. declare module BABYLON {
  100376. /**
  100377. * Single axis scale gizmo
  100378. */
  100379. export class AxisScaleGizmo extends Gizmo {
  100380. private _coloredMaterial;
  100381. /**
  100382. * Drag behavior responsible for the gizmos dragging interactions
  100383. */
  100384. dragBehavior: PointerDragBehavior;
  100385. private _pointerObserver;
  100386. /**
  100387. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100388. */
  100389. snapDistance: number;
  100390. /**
  100391. * Event that fires each time the gizmo snaps to a new location.
  100392. * * snapDistance is the the change in distance
  100393. */
  100394. onSnapObservable: Observable<{
  100395. snapDistance: number;
  100396. }>;
  100397. /**
  100398. * If the scaling operation should be done on all axis (default: false)
  100399. */
  100400. uniformScaling: boolean;
  100401. /**
  100402. * Creates an AxisScaleGizmo
  100403. * @param gizmoLayer The utility layer the gizmo will be added to
  100404. * @param dragAxis The axis which the gizmo will be able to scale on
  100405. * @param color The color of the gizmo
  100406. */
  100407. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100408. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100409. /**
  100410. * Disposes of the gizmo
  100411. */
  100412. dispose(): void;
  100413. /**
  100414. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100415. * @param mesh The mesh to replace the default mesh of the gizmo
  100416. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100417. */
  100418. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100419. }
  100420. }
  100421. declare module BABYLON {
  100422. /**
  100423. * Bounding box gizmo
  100424. */
  100425. export class BoundingBoxGizmo extends Gizmo {
  100426. private _lineBoundingBox;
  100427. private _rotateSpheresParent;
  100428. private _scaleBoxesParent;
  100429. private _boundingDimensions;
  100430. private _renderObserver;
  100431. private _pointerObserver;
  100432. private _scaleDragSpeed;
  100433. private _tmpQuaternion;
  100434. private _tmpVector;
  100435. private _tmpRotationMatrix;
  100436. /**
  100437. * 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)
  100438. */
  100439. ignoreChildren: boolean;
  100440. /**
  100441. * 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)
  100442. */
  100443. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100444. /**
  100445. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100446. */
  100447. rotationSphereSize: number;
  100448. /**
  100449. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100450. */
  100451. scaleBoxSize: number;
  100452. /**
  100453. * 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)
  100454. */
  100455. fixedDragMeshScreenSize: boolean;
  100456. /**
  100457. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100458. */
  100459. fixedDragMeshScreenSizeDistanceFactor: number;
  100460. /**
  100461. * Fired when a rotation sphere or scale box is dragged
  100462. */
  100463. onDragStartObservable: Observable<{}>;
  100464. /**
  100465. * Fired when a scale box is dragged
  100466. */
  100467. onScaleBoxDragObservable: Observable<{}>;
  100468. /**
  100469. * Fired when a scale box drag is ended
  100470. */
  100471. onScaleBoxDragEndObservable: Observable<{}>;
  100472. /**
  100473. * Fired when a rotation sphere is dragged
  100474. */
  100475. onRotationSphereDragObservable: Observable<{}>;
  100476. /**
  100477. * Fired when a rotation sphere drag is ended
  100478. */
  100479. onRotationSphereDragEndObservable: Observable<{}>;
  100480. /**
  100481. * 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)
  100482. */
  100483. scalePivot: Nullable<Vector3>;
  100484. private _anchorMesh;
  100485. private _existingMeshScale;
  100486. private _dragMesh;
  100487. private pointerDragBehavior;
  100488. private coloredMaterial;
  100489. private hoverColoredMaterial;
  100490. /**
  100491. * Sets the color of the bounding box gizmo
  100492. * @param color the color to set
  100493. */
  100494. setColor(color: Color3): void;
  100495. /**
  100496. * Creates an BoundingBoxGizmo
  100497. * @param gizmoLayer The utility layer the gizmo will be added to
  100498. * @param color The color of the gizmo
  100499. */
  100500. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100501. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100502. private _selectNode;
  100503. /**
  100504. * Updates the bounding box information for the Gizmo
  100505. */
  100506. updateBoundingBox(): void;
  100507. private _updateRotationSpheres;
  100508. private _updateScaleBoxes;
  100509. /**
  100510. * Enables rotation on the specified axis and disables rotation on the others
  100511. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100512. */
  100513. setEnabledRotationAxis(axis: string): void;
  100514. /**
  100515. * Enables/disables scaling
  100516. * @param enable if scaling should be enabled
  100517. */
  100518. setEnabledScaling(enable: boolean): void;
  100519. private _updateDummy;
  100520. /**
  100521. * Enables a pointer drag behavior on the bounding box of the gizmo
  100522. */
  100523. enableDragBehavior(): void;
  100524. /**
  100525. * Disposes of the gizmo
  100526. */
  100527. dispose(): void;
  100528. /**
  100529. * 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)
  100530. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100531. * @returns the bounding box mesh with the passed in mesh as a child
  100532. */
  100533. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100534. /**
  100535. * CustomMeshes are not supported by this gizmo
  100536. * @param mesh The mesh to replace the default mesh of the gizmo
  100537. */
  100538. setCustomMesh(mesh: Mesh): void;
  100539. }
  100540. }
  100541. declare module BABYLON {
  100542. /**
  100543. * Single plane rotation gizmo
  100544. */
  100545. export class PlaneRotationGizmo extends Gizmo {
  100546. /**
  100547. * Drag behavior responsible for the gizmos dragging interactions
  100548. */
  100549. dragBehavior: PointerDragBehavior;
  100550. private _pointerObserver;
  100551. /**
  100552. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100553. */
  100554. snapDistance: number;
  100555. /**
  100556. * Event that fires each time the gizmo snaps to a new location.
  100557. * * snapDistance is the the change in distance
  100558. */
  100559. onSnapObservable: Observable<{
  100560. snapDistance: number;
  100561. }>;
  100562. /**
  100563. * Creates a PlaneRotationGizmo
  100564. * @param gizmoLayer The utility layer the gizmo will be added to
  100565. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100566. * @param color The color of the gizmo
  100567. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100568. */
  100569. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100570. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100571. /**
  100572. * Disposes of the gizmo
  100573. */
  100574. dispose(): void;
  100575. }
  100576. }
  100577. declare module BABYLON {
  100578. /**
  100579. * Gizmo that enables rotating a mesh along 3 axis
  100580. */
  100581. export class RotationGizmo extends Gizmo {
  100582. /**
  100583. * Internal gizmo used for interactions on the x axis
  100584. */
  100585. xGizmo: PlaneRotationGizmo;
  100586. /**
  100587. * Internal gizmo used for interactions on the y axis
  100588. */
  100589. yGizmo: PlaneRotationGizmo;
  100590. /**
  100591. * Internal gizmo used for interactions on the z axis
  100592. */
  100593. zGizmo: PlaneRotationGizmo;
  100594. /** Fires an event when any of it's sub gizmos are dragged */
  100595. onDragStartObservable: Observable<{}>;
  100596. /** Fires an event when any of it's sub gizmos are released from dragging */
  100597. onDragEndObservable: Observable<{}>;
  100598. attachedMesh: Nullable<AbstractMesh>;
  100599. /**
  100600. * Creates a RotationGizmo
  100601. * @param gizmoLayer The utility layer the gizmo will be added to
  100602. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100603. */
  100604. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100605. updateGizmoRotationToMatchAttachedMesh: boolean;
  100606. /**
  100607. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100608. */
  100609. snapDistance: number;
  100610. /**
  100611. * Ratio for the scale of the gizmo (Default: 1)
  100612. */
  100613. scaleRatio: number;
  100614. /**
  100615. * Disposes of the gizmo
  100616. */
  100617. dispose(): void;
  100618. /**
  100619. * CustomMeshes are not supported by this gizmo
  100620. * @param mesh The mesh to replace the default mesh of the gizmo
  100621. */
  100622. setCustomMesh(mesh: Mesh): void;
  100623. }
  100624. }
  100625. declare module BABYLON {
  100626. /**
  100627. * Gizmo that enables dragging a mesh along 3 axis
  100628. */
  100629. export class PositionGizmo extends Gizmo {
  100630. /**
  100631. * Internal gizmo used for interactions on the x axis
  100632. */
  100633. xGizmo: AxisDragGizmo;
  100634. /**
  100635. * Internal gizmo used for interactions on the y axis
  100636. */
  100637. yGizmo: AxisDragGizmo;
  100638. /**
  100639. * Internal gizmo used for interactions on the z axis
  100640. */
  100641. zGizmo: AxisDragGizmo;
  100642. /** Fires an event when any of it's sub gizmos are dragged */
  100643. onDragStartObservable: Observable<{}>;
  100644. /** Fires an event when any of it's sub gizmos are released from dragging */
  100645. onDragEndObservable: Observable<{}>;
  100646. attachedMesh: Nullable<AbstractMesh>;
  100647. /**
  100648. * Creates a PositionGizmo
  100649. * @param gizmoLayer The utility layer the gizmo will be added to
  100650. */
  100651. constructor(gizmoLayer?: UtilityLayerRenderer);
  100652. updateGizmoRotationToMatchAttachedMesh: boolean;
  100653. /**
  100654. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100655. */
  100656. snapDistance: number;
  100657. /**
  100658. * Ratio for the scale of the gizmo (Default: 1)
  100659. */
  100660. scaleRatio: number;
  100661. /**
  100662. * Disposes of the gizmo
  100663. */
  100664. dispose(): void;
  100665. /**
  100666. * CustomMeshes are not supported by this gizmo
  100667. * @param mesh The mesh to replace the default mesh of the gizmo
  100668. */
  100669. setCustomMesh(mesh: Mesh): void;
  100670. }
  100671. }
  100672. declare module BABYLON {
  100673. /**
  100674. * Class containing static functions to help procedurally build meshes
  100675. */
  100676. export class PolyhedronBuilder {
  100677. /**
  100678. * Creates a polyhedron mesh
  100679. * * 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
  100680. * * The parameter `size` (positive float, default 1) sets the polygon size
  100681. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100682. * * 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`
  100683. * * 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
  100684. * * 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)`)
  100685. * * 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
  100686. * * 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
  100687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100690. * @param name defines the name of the mesh
  100691. * @param options defines the options used to create the mesh
  100692. * @param scene defines the hosting scene
  100693. * @returns the polyhedron mesh
  100694. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100695. */
  100696. static CreatePolyhedron(name: string, options: {
  100697. type?: number;
  100698. size?: number;
  100699. sizeX?: number;
  100700. sizeY?: number;
  100701. sizeZ?: number;
  100702. custom?: any;
  100703. faceUV?: Vector4[];
  100704. faceColors?: Color4[];
  100705. flat?: boolean;
  100706. updatable?: boolean;
  100707. sideOrientation?: number;
  100708. frontUVs?: Vector4;
  100709. backUVs?: Vector4;
  100710. }, scene: Scene): Mesh;
  100711. }
  100712. }
  100713. declare module BABYLON {
  100714. /**
  100715. * Gizmo that enables scaling a mesh along 3 axis
  100716. */
  100717. export class ScaleGizmo extends Gizmo {
  100718. /**
  100719. * Internal gizmo used for interactions on the x axis
  100720. */
  100721. xGizmo: AxisScaleGizmo;
  100722. /**
  100723. * Internal gizmo used for interactions on the y axis
  100724. */
  100725. yGizmo: AxisScaleGizmo;
  100726. /**
  100727. * Internal gizmo used for interactions on the z axis
  100728. */
  100729. zGizmo: AxisScaleGizmo;
  100730. /**
  100731. * Internal gizmo used to scale all axis equally
  100732. */
  100733. uniformScaleGizmo: AxisScaleGizmo;
  100734. /** Fires an event when any of it's sub gizmos are dragged */
  100735. onDragStartObservable: Observable<{}>;
  100736. /** Fires an event when any of it's sub gizmos are released from dragging */
  100737. onDragEndObservable: Observable<{}>;
  100738. attachedMesh: Nullable<AbstractMesh>;
  100739. /**
  100740. * Creates a ScaleGizmo
  100741. * @param gizmoLayer The utility layer the gizmo will be added to
  100742. */
  100743. constructor(gizmoLayer?: UtilityLayerRenderer);
  100744. updateGizmoRotationToMatchAttachedMesh: boolean;
  100745. /**
  100746. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100747. */
  100748. snapDistance: number;
  100749. /**
  100750. * Ratio for the scale of the gizmo (Default: 1)
  100751. */
  100752. scaleRatio: number;
  100753. /**
  100754. * Disposes of the gizmo
  100755. */
  100756. dispose(): void;
  100757. }
  100758. }
  100759. declare module BABYLON {
  100760. /**
  100761. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  100762. */
  100763. export class GizmoManager implements IDisposable {
  100764. private scene;
  100765. /**
  100766. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  100767. */
  100768. gizmos: {
  100769. positionGizmo: Nullable<PositionGizmo>;
  100770. rotationGizmo: Nullable<RotationGizmo>;
  100771. scaleGizmo: Nullable<ScaleGizmo>;
  100772. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  100773. };
  100774. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  100775. clearGizmoOnEmptyPointerEvent: boolean;
  100776. /** Fires an event when the manager is attached to a mesh */
  100777. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  100778. private _gizmosEnabled;
  100779. private _pointerObserver;
  100780. private _attachedMesh;
  100781. private _boundingBoxColor;
  100782. private _defaultUtilityLayer;
  100783. private _defaultKeepDepthUtilityLayer;
  100784. /**
  100785. * When bounding box gizmo is enabled, this can be used to track drag/end events
  100786. */
  100787. boundingBoxDragBehavior: SixDofDragBehavior;
  100788. /**
  100789. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  100790. */
  100791. attachableMeshes: Nullable<Array<AbstractMesh>>;
  100792. /**
  100793. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  100794. */
  100795. usePointerToAttachGizmos: boolean;
  100796. /**
  100797. * Instatiates a gizmo manager
  100798. * @param scene the scene to overlay the gizmos on top of
  100799. */
  100800. constructor(scene: Scene);
  100801. /**
  100802. * Attaches a set of gizmos to the specified mesh
  100803. * @param mesh The mesh the gizmo's should be attached to
  100804. */
  100805. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  100806. /**
  100807. * If the position gizmo is enabled
  100808. */
  100809. positionGizmoEnabled: boolean;
  100810. /**
  100811. * If the rotation gizmo is enabled
  100812. */
  100813. rotationGizmoEnabled: boolean;
  100814. /**
  100815. * If the scale gizmo is enabled
  100816. */
  100817. scaleGizmoEnabled: boolean;
  100818. /**
  100819. * If the boundingBox gizmo is enabled
  100820. */
  100821. boundingBoxGizmoEnabled: boolean;
  100822. /**
  100823. * Disposes of the gizmo manager
  100824. */
  100825. dispose(): void;
  100826. }
  100827. }
  100828. declare module BABYLON {
  100829. /**
  100830. * Gizmo that enables viewing a light
  100831. */
  100832. export class LightGizmo extends Gizmo {
  100833. private _box;
  100834. /**
  100835. * Creates a LightGizmo
  100836. * @param gizmoLayer The utility layer the gizmo will be added to
  100837. */
  100838. constructor(gizmoLayer?: UtilityLayerRenderer);
  100839. private _light;
  100840. /**
  100841. * The light that the gizmo is attached to
  100842. */
  100843. light: Nullable<Light>;
  100844. /**
  100845. * @hidden
  100846. * Updates the gizmo to match the attached mesh's position/rotation
  100847. */
  100848. protected _update(): void;
  100849. }
  100850. }
  100851. declare module BABYLON {
  100852. /** @hidden */
  100853. export var backgroundFragmentDeclaration: {
  100854. name: string;
  100855. shader: string;
  100856. };
  100857. }
  100858. declare module BABYLON {
  100859. /** @hidden */
  100860. export var backgroundUboDeclaration: {
  100861. name: string;
  100862. shader: string;
  100863. };
  100864. }
  100865. declare module BABYLON {
  100866. /** @hidden */
  100867. export var backgroundPixelShader: {
  100868. name: string;
  100869. shader: string;
  100870. };
  100871. }
  100872. declare module BABYLON {
  100873. /** @hidden */
  100874. export var backgroundVertexDeclaration: {
  100875. name: string;
  100876. shader: string;
  100877. };
  100878. }
  100879. declare module BABYLON {
  100880. /** @hidden */
  100881. export var backgroundVertexShader: {
  100882. name: string;
  100883. shader: string;
  100884. };
  100885. }
  100886. declare module BABYLON {
  100887. /**
  100888. * Background material used to create an efficient environement around your scene.
  100889. */
  100890. export class BackgroundMaterial extends PushMaterial {
  100891. /**
  100892. * Standard reflectance value at parallel view angle.
  100893. */
  100894. static StandardReflectance0: number;
  100895. /**
  100896. * Standard reflectance value at grazing angle.
  100897. */
  100898. static StandardReflectance90: number;
  100899. protected _primaryColor: Color3;
  100900. /**
  100901. * Key light Color (multiply against the environement texture)
  100902. */
  100903. primaryColor: Color3;
  100904. protected __perceptualColor: Nullable<Color3>;
  100905. /**
  100906. * Experimental Internal Use Only.
  100907. *
  100908. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  100909. * This acts as a helper to set the primary color to a more "human friendly" value.
  100910. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  100911. * output color as close as possible from the chosen value.
  100912. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  100913. * part of lighting setup.)
  100914. */
  100915. _perceptualColor: Nullable<Color3>;
  100916. protected _primaryColorShadowLevel: float;
  100917. /**
  100918. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  100919. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  100920. */
  100921. primaryColorShadowLevel: float;
  100922. protected _primaryColorHighlightLevel: float;
  100923. /**
  100924. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  100925. * The primary color is used at the level chosen to define what the white area would look.
  100926. */
  100927. primaryColorHighlightLevel: float;
  100928. protected _reflectionTexture: Nullable<BaseTexture>;
  100929. /**
  100930. * Reflection Texture used in the material.
  100931. * Should be author in a specific way for the best result (refer to the documentation).
  100932. */
  100933. reflectionTexture: Nullable<BaseTexture>;
  100934. protected _reflectionBlur: float;
  100935. /**
  100936. * Reflection Texture level of blur.
  100937. *
  100938. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  100939. * texture twice.
  100940. */
  100941. reflectionBlur: float;
  100942. protected _diffuseTexture: Nullable<BaseTexture>;
  100943. /**
  100944. * Diffuse Texture used in the material.
  100945. * Should be author in a specific way for the best result (refer to the documentation).
  100946. */
  100947. diffuseTexture: Nullable<BaseTexture>;
  100948. protected _shadowLights: Nullable<IShadowLight[]>;
  100949. /**
  100950. * Specify the list of lights casting shadow on the material.
  100951. * All scene shadow lights will be included if null.
  100952. */
  100953. shadowLights: Nullable<IShadowLight[]>;
  100954. protected _shadowLevel: float;
  100955. /**
  100956. * Helps adjusting the shadow to a softer level if required.
  100957. * 0 means black shadows and 1 means no shadows.
  100958. */
  100959. shadowLevel: float;
  100960. protected _sceneCenter: Vector3;
  100961. /**
  100962. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100963. * It is usually zero but might be interesting to modify according to your setup.
  100964. */
  100965. sceneCenter: Vector3;
  100966. protected _opacityFresnel: boolean;
  100967. /**
  100968. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100969. * This helps ensuring a nice transition when the camera goes under the ground.
  100970. */
  100971. opacityFresnel: boolean;
  100972. protected _reflectionFresnel: boolean;
  100973. /**
  100974. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100975. * This helps adding a mirror texture on the ground.
  100976. */
  100977. reflectionFresnel: boolean;
  100978. protected _reflectionFalloffDistance: number;
  100979. /**
  100980. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100981. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100982. */
  100983. reflectionFalloffDistance: number;
  100984. protected _reflectionAmount: number;
  100985. /**
  100986. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100987. */
  100988. reflectionAmount: number;
  100989. protected _reflectionReflectance0: number;
  100990. /**
  100991. * This specifies the weight of the reflection at grazing angle.
  100992. */
  100993. reflectionReflectance0: number;
  100994. protected _reflectionReflectance90: number;
  100995. /**
  100996. * This specifies the weight of the reflection at a perpendicular point of view.
  100997. */
  100998. reflectionReflectance90: number;
  100999. /**
  101000. * Sets the reflection reflectance fresnel values according to the default standard
  101001. * empirically know to work well :-)
  101002. */
  101003. reflectionStandardFresnelWeight: number;
  101004. protected _useRGBColor: boolean;
  101005. /**
  101006. * Helps to directly use the maps channels instead of their level.
  101007. */
  101008. useRGBColor: boolean;
  101009. protected _enableNoise: boolean;
  101010. /**
  101011. * This helps reducing the banding effect that could occur on the background.
  101012. */
  101013. enableNoise: boolean;
  101014. /**
  101015. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101016. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  101017. * Recommended to be keep at 1.0 except for special cases.
  101018. */
  101019. fovMultiplier: number;
  101020. private _fovMultiplier;
  101021. /**
  101022. * Enable the FOV adjustment feature controlled by fovMultiplier.
  101023. */
  101024. useEquirectangularFOV: boolean;
  101025. private _maxSimultaneousLights;
  101026. /**
  101027. * Number of Simultaneous lights allowed on the material.
  101028. */
  101029. maxSimultaneousLights: int;
  101030. /**
  101031. * Default configuration related to image processing available in the Background Material.
  101032. */
  101033. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101034. /**
  101035. * Keep track of the image processing observer to allow dispose and replace.
  101036. */
  101037. private _imageProcessingObserver;
  101038. /**
  101039. * Attaches a new image processing configuration to the PBR Material.
  101040. * @param configuration (if null the scene configuration will be use)
  101041. */
  101042. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101043. /**
  101044. * Gets the image processing configuration used either in this material.
  101045. */
  101046. /**
  101047. * Sets the Default image processing configuration used either in the this material.
  101048. *
  101049. * If sets to null, the scene one is in use.
  101050. */
  101051. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  101052. /**
  101053. * Gets wether the color curves effect is enabled.
  101054. */
  101055. /**
  101056. * Sets wether the color curves effect is enabled.
  101057. */
  101058. cameraColorCurvesEnabled: boolean;
  101059. /**
  101060. * Gets wether the color grading effect is enabled.
  101061. */
  101062. /**
  101063. * Gets wether the color grading effect is enabled.
  101064. */
  101065. cameraColorGradingEnabled: boolean;
  101066. /**
  101067. * Gets wether tonemapping is enabled or not.
  101068. */
  101069. /**
  101070. * Sets wether tonemapping is enabled or not
  101071. */
  101072. cameraToneMappingEnabled: boolean;
  101073. /**
  101074. * The camera exposure used on this material.
  101075. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101076. * This corresponds to a photographic exposure.
  101077. */
  101078. /**
  101079. * The camera exposure used on this material.
  101080. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101081. * This corresponds to a photographic exposure.
  101082. */
  101083. cameraExposure: float;
  101084. /**
  101085. * Gets The camera contrast used on this material.
  101086. */
  101087. /**
  101088. * Sets The camera contrast used on this material.
  101089. */
  101090. cameraContrast: float;
  101091. /**
  101092. * Gets the Color Grading 2D Lookup Texture.
  101093. */
  101094. /**
  101095. * Sets the Color Grading 2D Lookup Texture.
  101096. */
  101097. cameraColorGradingTexture: Nullable<BaseTexture>;
  101098. /**
  101099. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101100. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101101. * 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;
  101102. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101103. */
  101104. /**
  101105. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101106. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101107. * 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;
  101108. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101109. */
  101110. cameraColorCurves: Nullable<ColorCurves>;
  101111. /**
  101112. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  101113. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  101114. */
  101115. switchToBGR: boolean;
  101116. private _renderTargets;
  101117. private _reflectionControls;
  101118. private _white;
  101119. private _primaryShadowColor;
  101120. private _primaryHighlightColor;
  101121. /**
  101122. * Instantiates a Background Material in the given scene
  101123. * @param name The friendly name of the material
  101124. * @param scene The scene to add the material to
  101125. */
  101126. constructor(name: string, scene: Scene);
  101127. /**
  101128. * Gets a boolean indicating that current material needs to register RTT
  101129. */
  101130. readonly hasRenderTargetTextures: boolean;
  101131. /**
  101132. * The entire material has been created in order to prevent overdraw.
  101133. * @returns false
  101134. */
  101135. needAlphaTesting(): boolean;
  101136. /**
  101137. * The entire material has been created in order to prevent overdraw.
  101138. * @returns true if blending is enable
  101139. */
  101140. needAlphaBlending(): boolean;
  101141. /**
  101142. * Checks wether the material is ready to be rendered for a given mesh.
  101143. * @param mesh The mesh to render
  101144. * @param subMesh The submesh to check against
  101145. * @param useInstances Specify wether or not the material is used with instances
  101146. * @returns true if all the dependencies are ready (Textures, Effects...)
  101147. */
  101148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101149. /**
  101150. * Compute the primary color according to the chosen perceptual color.
  101151. */
  101152. private _computePrimaryColorFromPerceptualColor;
  101153. /**
  101154. * Compute the highlights and shadow colors according to their chosen levels.
  101155. */
  101156. private _computePrimaryColors;
  101157. /**
  101158. * Build the uniform buffer used in the material.
  101159. */
  101160. buildUniformLayout(): void;
  101161. /**
  101162. * Unbind the material.
  101163. */
  101164. unbind(): void;
  101165. /**
  101166. * Bind only the world matrix to the material.
  101167. * @param world The world matrix to bind.
  101168. */
  101169. bindOnlyWorldMatrix(world: Matrix): void;
  101170. /**
  101171. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  101172. * @param world The world matrix to bind.
  101173. * @param subMesh The submesh to bind for.
  101174. */
  101175. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101176. /**
  101177. * Dispose the material.
  101178. * @param forceDisposeEffect Force disposal of the associated effect.
  101179. * @param forceDisposeTextures Force disposal of the associated textures.
  101180. */
  101181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101182. /**
  101183. * Clones the material.
  101184. * @param name The cloned name.
  101185. * @returns The cloned material.
  101186. */
  101187. clone(name: string): BackgroundMaterial;
  101188. /**
  101189. * Serializes the current material to its JSON representation.
  101190. * @returns The JSON representation.
  101191. */
  101192. serialize(): any;
  101193. /**
  101194. * Gets the class name of the material
  101195. * @returns "BackgroundMaterial"
  101196. */
  101197. getClassName(): string;
  101198. /**
  101199. * Parse a JSON input to create back a background material.
  101200. * @param source The JSON data to parse
  101201. * @param scene The scene to create the parsed material in
  101202. * @param rootUrl The root url of the assets the material depends upon
  101203. * @returns the instantiated BackgroundMaterial.
  101204. */
  101205. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  101206. }
  101207. }
  101208. declare module BABYLON {
  101209. /**
  101210. * Represents the different options available during the creation of
  101211. * a Environment helper.
  101212. *
  101213. * This can control the default ground, skybox and image processing setup of your scene.
  101214. */
  101215. export interface IEnvironmentHelperOptions {
  101216. /**
  101217. * Specifies wether or not to create a ground.
  101218. * True by default.
  101219. */
  101220. createGround: boolean;
  101221. /**
  101222. * Specifies the ground size.
  101223. * 15 by default.
  101224. */
  101225. groundSize: number;
  101226. /**
  101227. * The texture used on the ground for the main color.
  101228. * Comes from the BabylonJS CDN by default.
  101229. *
  101230. * Remarks: Can be either a texture or a url.
  101231. */
  101232. groundTexture: string | BaseTexture;
  101233. /**
  101234. * The color mixed in the ground texture by default.
  101235. * BabylonJS clearColor by default.
  101236. */
  101237. groundColor: Color3;
  101238. /**
  101239. * Specifies the ground opacity.
  101240. * 1 by default.
  101241. */
  101242. groundOpacity: number;
  101243. /**
  101244. * Enables the ground to receive shadows.
  101245. * True by default.
  101246. */
  101247. enableGroundShadow: boolean;
  101248. /**
  101249. * Helps preventing the shadow to be fully black on the ground.
  101250. * 0.5 by default.
  101251. */
  101252. groundShadowLevel: number;
  101253. /**
  101254. * Creates a mirror texture attach to the ground.
  101255. * false by default.
  101256. */
  101257. enableGroundMirror: boolean;
  101258. /**
  101259. * Specifies the ground mirror size ratio.
  101260. * 0.3 by default as the default kernel is 64.
  101261. */
  101262. groundMirrorSizeRatio: number;
  101263. /**
  101264. * Specifies the ground mirror blur kernel size.
  101265. * 64 by default.
  101266. */
  101267. groundMirrorBlurKernel: number;
  101268. /**
  101269. * Specifies the ground mirror visibility amount.
  101270. * 1 by default
  101271. */
  101272. groundMirrorAmount: number;
  101273. /**
  101274. * Specifies the ground mirror reflectance weight.
  101275. * This uses the standard weight of the background material to setup the fresnel effect
  101276. * of the mirror.
  101277. * 1 by default.
  101278. */
  101279. groundMirrorFresnelWeight: number;
  101280. /**
  101281. * Specifies the ground mirror Falloff distance.
  101282. * This can helps reducing the size of the reflection.
  101283. * 0 by Default.
  101284. */
  101285. groundMirrorFallOffDistance: number;
  101286. /**
  101287. * Specifies the ground mirror texture type.
  101288. * Unsigned Int by Default.
  101289. */
  101290. groundMirrorTextureType: number;
  101291. /**
  101292. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101293. * the shown objects.
  101294. */
  101295. groundYBias: number;
  101296. /**
  101297. * Specifies wether or not to create a skybox.
  101298. * True by default.
  101299. */
  101300. createSkybox: boolean;
  101301. /**
  101302. * Specifies the skybox size.
  101303. * 20 by default.
  101304. */
  101305. skyboxSize: number;
  101306. /**
  101307. * The texture used on the skybox for the main color.
  101308. * Comes from the BabylonJS CDN by default.
  101309. *
  101310. * Remarks: Can be either a texture or a url.
  101311. */
  101312. skyboxTexture: string | BaseTexture;
  101313. /**
  101314. * The color mixed in the skybox texture by default.
  101315. * BabylonJS clearColor by default.
  101316. */
  101317. skyboxColor: Color3;
  101318. /**
  101319. * The background rotation around the Y axis of the scene.
  101320. * This helps aligning the key lights of your scene with the background.
  101321. * 0 by default.
  101322. */
  101323. backgroundYRotation: number;
  101324. /**
  101325. * Compute automatically the size of the elements to best fit with the scene.
  101326. */
  101327. sizeAuto: boolean;
  101328. /**
  101329. * Default position of the rootMesh if autoSize is not true.
  101330. */
  101331. rootPosition: Vector3;
  101332. /**
  101333. * Sets up the image processing in the scene.
  101334. * true by default.
  101335. */
  101336. setupImageProcessing: boolean;
  101337. /**
  101338. * The texture used as your environment texture in the scene.
  101339. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101340. *
  101341. * Remarks: Can be either a texture or a url.
  101342. */
  101343. environmentTexture: string | BaseTexture;
  101344. /**
  101345. * The value of the exposure to apply to the scene.
  101346. * 0.6 by default if setupImageProcessing is true.
  101347. */
  101348. cameraExposure: number;
  101349. /**
  101350. * The value of the contrast to apply to the scene.
  101351. * 1.6 by default if setupImageProcessing is true.
  101352. */
  101353. cameraContrast: number;
  101354. /**
  101355. * Specifies wether or not tonemapping should be enabled in the scene.
  101356. * true by default if setupImageProcessing is true.
  101357. */
  101358. toneMappingEnabled: boolean;
  101359. }
  101360. /**
  101361. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101362. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101363. * It also helps with the default setup of your imageProcessing configuration.
  101364. */
  101365. export class EnvironmentHelper {
  101366. /**
  101367. * Default ground texture URL.
  101368. */
  101369. private static _groundTextureCDNUrl;
  101370. /**
  101371. * Default skybox texture URL.
  101372. */
  101373. private static _skyboxTextureCDNUrl;
  101374. /**
  101375. * Default environment texture URL.
  101376. */
  101377. private static _environmentTextureCDNUrl;
  101378. /**
  101379. * Creates the default options for the helper.
  101380. */
  101381. private static _getDefaultOptions;
  101382. private _rootMesh;
  101383. /**
  101384. * Gets the root mesh created by the helper.
  101385. */
  101386. readonly rootMesh: Mesh;
  101387. private _skybox;
  101388. /**
  101389. * Gets the skybox created by the helper.
  101390. */
  101391. readonly skybox: Nullable<Mesh>;
  101392. private _skyboxTexture;
  101393. /**
  101394. * Gets the skybox texture created by the helper.
  101395. */
  101396. readonly skyboxTexture: Nullable<BaseTexture>;
  101397. private _skyboxMaterial;
  101398. /**
  101399. * Gets the skybox material created by the helper.
  101400. */
  101401. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101402. private _ground;
  101403. /**
  101404. * Gets the ground mesh created by the helper.
  101405. */
  101406. readonly ground: Nullable<Mesh>;
  101407. private _groundTexture;
  101408. /**
  101409. * Gets the ground texture created by the helper.
  101410. */
  101411. readonly groundTexture: Nullable<BaseTexture>;
  101412. private _groundMirror;
  101413. /**
  101414. * Gets the ground mirror created by the helper.
  101415. */
  101416. readonly groundMirror: Nullable<MirrorTexture>;
  101417. /**
  101418. * Gets the ground mirror render list to helps pushing the meshes
  101419. * you wish in the ground reflection.
  101420. */
  101421. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101422. private _groundMaterial;
  101423. /**
  101424. * Gets the ground material created by the helper.
  101425. */
  101426. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101427. /**
  101428. * Stores the creation options.
  101429. */
  101430. private readonly _scene;
  101431. private _options;
  101432. /**
  101433. * This observable will be notified with any error during the creation of the environment,
  101434. * mainly texture creation errors.
  101435. */
  101436. onErrorObservable: Observable<{
  101437. message?: string;
  101438. exception?: any;
  101439. }>;
  101440. /**
  101441. * constructor
  101442. * @param options Defines the options we want to customize the helper
  101443. * @param scene The scene to add the material to
  101444. */
  101445. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101446. /**
  101447. * Updates the background according to the new options
  101448. * @param options
  101449. */
  101450. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101451. /**
  101452. * Sets the primary color of all the available elements.
  101453. * @param color the main color to affect to the ground and the background
  101454. */
  101455. setMainColor(color: Color3): void;
  101456. /**
  101457. * Setup the image processing according to the specified options.
  101458. */
  101459. private _setupImageProcessing;
  101460. /**
  101461. * Setup the environment texture according to the specified options.
  101462. */
  101463. private _setupEnvironmentTexture;
  101464. /**
  101465. * Setup the background according to the specified options.
  101466. */
  101467. private _setupBackground;
  101468. /**
  101469. * Get the scene sizes according to the setup.
  101470. */
  101471. private _getSceneSize;
  101472. /**
  101473. * Setup the ground according to the specified options.
  101474. */
  101475. private _setupGround;
  101476. /**
  101477. * Setup the ground material according to the specified options.
  101478. */
  101479. private _setupGroundMaterial;
  101480. /**
  101481. * Setup the ground diffuse texture according to the specified options.
  101482. */
  101483. private _setupGroundDiffuseTexture;
  101484. /**
  101485. * Setup the ground mirror texture according to the specified options.
  101486. */
  101487. private _setupGroundMirrorTexture;
  101488. /**
  101489. * Setup the ground to receive the mirror texture.
  101490. */
  101491. private _setupMirrorInGroundMaterial;
  101492. /**
  101493. * Setup the skybox according to the specified options.
  101494. */
  101495. private _setupSkybox;
  101496. /**
  101497. * Setup the skybox material according to the specified options.
  101498. */
  101499. private _setupSkyboxMaterial;
  101500. /**
  101501. * Setup the skybox reflection texture according to the specified options.
  101502. */
  101503. private _setupSkyboxReflectionTexture;
  101504. private _errorHandler;
  101505. /**
  101506. * Dispose all the elements created by the Helper.
  101507. */
  101508. dispose(): void;
  101509. }
  101510. }
  101511. declare module BABYLON {
  101512. /**
  101513. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101514. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101515. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101516. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101517. */
  101518. export class PhotoDome extends TransformNode {
  101519. private _useDirectMapping;
  101520. /**
  101521. * The texture being displayed on the sphere
  101522. */
  101523. protected _photoTexture: Texture;
  101524. /**
  101525. * Gets or sets the texture being displayed on the sphere
  101526. */
  101527. photoTexture: Texture;
  101528. /**
  101529. * Observable raised when an error occured while loading the 360 image
  101530. */
  101531. onLoadErrorObservable: Observable<string>;
  101532. /**
  101533. * The skybox material
  101534. */
  101535. protected _material: BackgroundMaterial;
  101536. /**
  101537. * The surface used for the skybox
  101538. */
  101539. protected _mesh: Mesh;
  101540. /**
  101541. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101542. * Also see the options.resolution property.
  101543. */
  101544. fovMultiplier: number;
  101545. /**
  101546. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101547. * @param name Element's name, child elements will append suffixes for their own names.
  101548. * @param urlsOfPhoto defines the url of the photo to display
  101549. * @param options defines an object containing optional or exposed sub element properties
  101550. * @param onError defines a callback called when an error occured while loading the texture
  101551. */
  101552. constructor(name: string, urlOfPhoto: string, options: {
  101553. resolution?: number;
  101554. size?: number;
  101555. useDirectMapping?: boolean;
  101556. faceForward?: boolean;
  101557. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101558. /**
  101559. * Releases resources associated with this node.
  101560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101562. */
  101563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101564. }
  101565. }
  101566. declare module BABYLON {
  101567. /**
  101568. * Class used to host texture specific utilities
  101569. */
  101570. export class TextureTools {
  101571. /**
  101572. * Uses the GPU to create a copy texture rescaled at a given size
  101573. * @param texture Texture to copy from
  101574. * @param width defines the desired width
  101575. * @param height defines the desired height
  101576. * @param useBilinearMode defines if bilinear mode has to be used
  101577. * @return the generated texture
  101578. */
  101579. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  101580. /**
  101581. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101582. * @param scene defines the hosting scene
  101583. * @returns the environment BRDF texture
  101584. */
  101585. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101586. private static _environmentBRDFBase64Texture;
  101587. }
  101588. }
  101589. declare module BABYLON {
  101590. /**
  101591. * @hidden
  101592. */
  101593. export interface IMaterialClearCoatDefines {
  101594. CLEARCOAT: boolean;
  101595. CLEARCOAT_DEFAULTIOR: boolean;
  101596. CLEARCOAT_TEXTURE: boolean;
  101597. CLEARCOAT_TEXTUREDIRECTUV: number;
  101598. CLEARCOAT_BUMP: boolean;
  101599. CLEARCOAT_BUMPDIRECTUV: number;
  101600. CLEARCOAT_TINT: boolean;
  101601. CLEARCOAT_TINT_TEXTURE: boolean;
  101602. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101603. /** @hidden */
  101604. _areTexturesDirty: boolean;
  101605. }
  101606. /**
  101607. * Define the code related to the clear coat parameters of the pbr material.
  101608. */
  101609. export class PBRClearCoatConfiguration {
  101610. /**
  101611. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101612. * The default fits with a polyurethane material.
  101613. */
  101614. private static readonly _DefaultIndiceOfRefraction;
  101615. private _isEnabled;
  101616. /**
  101617. * Defines if the clear coat is enabled in the material.
  101618. */
  101619. isEnabled: boolean;
  101620. /**
  101621. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101622. */
  101623. intensity: number;
  101624. /**
  101625. * Defines the clear coat layer roughness.
  101626. */
  101627. roughness: number;
  101628. private _indiceOfRefraction;
  101629. /**
  101630. * Defines the indice of refraction of the clear coat.
  101631. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101632. * The default fits with a polyurethane material.
  101633. * Changing the default value is more performance intensive.
  101634. */
  101635. indiceOfRefraction: number;
  101636. private _texture;
  101637. /**
  101638. * Stores the clear coat values in a texture.
  101639. */
  101640. texture: Nullable<BaseTexture>;
  101641. private _bumpTexture;
  101642. /**
  101643. * Define the clear coat specific bump texture.
  101644. */
  101645. bumpTexture: Nullable<BaseTexture>;
  101646. private _isTintEnabled;
  101647. /**
  101648. * Defines if the clear coat tint is enabled in the material.
  101649. */
  101650. isTintEnabled: boolean;
  101651. /**
  101652. * Defines if the clear coat tint is enabled in the material.
  101653. * This is only use if tint is enabled
  101654. */
  101655. tintColor: Color3;
  101656. /**
  101657. * Defines if the distance at which the tint color should be found in the
  101658. * clear coat media.
  101659. * This is only use if tint is enabled
  101660. */
  101661. tintColorAtDistance: number;
  101662. /**
  101663. * Defines the clear coat layer thickness.
  101664. * This is only use if tint is enabled
  101665. */
  101666. tintThickness: number;
  101667. private _tintTexture;
  101668. /**
  101669. * Stores the clear tint values in a texture.
  101670. * rgb is tint
  101671. * a is a thickness factor
  101672. */
  101673. tintTexture: Nullable<BaseTexture>;
  101674. /** @hidden */
  101675. private _internalMarkAllSubMeshesAsTexturesDirty;
  101676. /** @hidden */
  101677. _markAllSubMeshesAsTexturesDirty(): void;
  101678. /**
  101679. * Instantiate a new istance of clear coat configuration.
  101680. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101681. */
  101682. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101683. /**
  101684. * Specifies that the submesh is ready to be used.
  101685. * @param defines the list of "defines" to update.
  101686. * @param scene defines the scene the material belongs to.
  101687. * @param engine defines the engine the material belongs to.
  101688. * @param disableBumpMap defines wether the material disables bump or not.
  101689. * @returns - boolean indicating that the submesh is ready or not.
  101690. */
  101691. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101692. /**
  101693. * Checks to see if a texture is used in the material.
  101694. * @param defines the list of "defines" to update.
  101695. * @param scene defines the scene to the material belongs to.
  101696. */
  101697. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101698. /**
  101699. * Binds the material data.
  101700. * @param uniformBuffer defines the Uniform buffer to fill in.
  101701. * @param scene defines the scene the material belongs to.
  101702. * @param engine defines the engine the material belongs to.
  101703. * @param disableBumpMap defines wether the material disables bump or not.
  101704. * @param isFrozen defines wether the material is frozen or not.
  101705. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101706. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101707. */
  101708. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101709. /**
  101710. * Checks to see if a texture is used in the material.
  101711. * @param texture - Base texture to use.
  101712. * @returns - Boolean specifying if a texture is used in the material.
  101713. */
  101714. hasTexture(texture: BaseTexture): boolean;
  101715. /**
  101716. * Returns an array of the actively used textures.
  101717. * @param activeTextures Array of BaseTextures
  101718. */
  101719. getActiveTextures(activeTextures: BaseTexture[]): void;
  101720. /**
  101721. * Returns the animatable textures.
  101722. * @param animatables Array of animatable textures.
  101723. */
  101724. getAnimatables(animatables: IAnimatable[]): void;
  101725. /**
  101726. * Disposes the resources of the material.
  101727. * @param forceDisposeTextures - Forces the disposal of all textures.
  101728. */
  101729. dispose(forceDisposeTextures?: boolean): void;
  101730. /**
  101731. * Get the current class name of the texture useful for serialization or dynamic coding.
  101732. * @returns "PBRClearCoatConfiguration"
  101733. */
  101734. getClassName(): string;
  101735. /**
  101736. * Add fallbacks to the effect fallbacks list.
  101737. * @param defines defines the Base texture to use.
  101738. * @param fallbacks defines the current fallback list.
  101739. * @param currentRank defines the current fallback rank.
  101740. * @returns the new fallback rank.
  101741. */
  101742. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101743. /**
  101744. * Add the required uniforms to the current list.
  101745. * @param uniforms defines the current uniform list.
  101746. */
  101747. static AddUniforms(uniforms: string[]): void;
  101748. /**
  101749. * Add the required samplers to the current list.
  101750. * @param samplers defines the current sampler list.
  101751. */
  101752. static AddSamplers(samplers: string[]): void;
  101753. /**
  101754. * Add the required uniforms to the current buffer.
  101755. * @param uniformBuffer defines the current uniform buffer.
  101756. */
  101757. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101758. /**
  101759. * Makes a duplicate of the current configuration into another one.
  101760. * @param clearCoatConfiguration define the config where to copy the info
  101761. */
  101762. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101763. /**
  101764. * Serializes this clear coat configuration.
  101765. * @returns - An object with the serialized config.
  101766. */
  101767. serialize(): any;
  101768. /**
  101769. * Parses a Clear Coat Configuration from a serialized object.
  101770. * @param source - Serialized object.
  101771. */
  101772. parse(source: any): void;
  101773. }
  101774. }
  101775. declare module BABYLON {
  101776. /**
  101777. * @hidden
  101778. */
  101779. export interface IMaterialAnisotropicDefines {
  101780. ANISOTROPIC: boolean;
  101781. ANISOTROPIC_TEXTURE: boolean;
  101782. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101783. MAINUV1: boolean;
  101784. _areTexturesDirty: boolean;
  101785. _needUVs: boolean;
  101786. }
  101787. /**
  101788. * Define the code related to the anisotropic parameters of the pbr material.
  101789. */
  101790. export class PBRAnisotropicConfiguration {
  101791. private _isEnabled;
  101792. /**
  101793. * Defines if the anisotropy is enabled in the material.
  101794. */
  101795. isEnabled: boolean;
  101796. /**
  101797. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101798. */
  101799. intensity: number;
  101800. /**
  101801. * Defines if the effect is along the tangents, bitangents or in between.
  101802. * By default, the effect is "strectching" the highlights along the tangents.
  101803. */
  101804. direction: Vector2;
  101805. private _texture;
  101806. /**
  101807. * Stores the anisotropy values in a texture.
  101808. * rg is direction (like normal from -1 to 1)
  101809. * b is a intensity
  101810. */
  101811. texture: Nullable<BaseTexture>;
  101812. /** @hidden */
  101813. private _internalMarkAllSubMeshesAsTexturesDirty;
  101814. /** @hidden */
  101815. _markAllSubMeshesAsTexturesDirty(): void;
  101816. /**
  101817. * Instantiate a new istance of anisotropy configuration.
  101818. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101819. */
  101820. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101821. /**
  101822. * Specifies that the submesh is ready to be used.
  101823. * @param defines the list of "defines" to update.
  101824. * @param scene defines the scene the material belongs to.
  101825. * @returns - boolean indicating that the submesh is ready or not.
  101826. */
  101827. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101828. /**
  101829. * Checks to see if a texture is used in the material.
  101830. * @param defines the list of "defines" to update.
  101831. * @param mesh the mesh we are preparing the defines for.
  101832. * @param scene defines the scene the material belongs to.
  101833. */
  101834. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101835. /**
  101836. * Binds the material data.
  101837. * @param uniformBuffer defines the Uniform buffer to fill in.
  101838. * @param scene defines the scene the material belongs to.
  101839. * @param isFrozen defines wether the material is frozen or not.
  101840. */
  101841. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101842. /**
  101843. * Checks to see if a texture is used in the material.
  101844. * @param texture - Base texture to use.
  101845. * @returns - Boolean specifying if a texture is used in the material.
  101846. */
  101847. hasTexture(texture: BaseTexture): boolean;
  101848. /**
  101849. * Returns an array of the actively used textures.
  101850. * @param activeTextures Array of BaseTextures
  101851. */
  101852. getActiveTextures(activeTextures: BaseTexture[]): void;
  101853. /**
  101854. * Returns the animatable textures.
  101855. * @param animatables Array of animatable textures.
  101856. */
  101857. getAnimatables(animatables: IAnimatable[]): void;
  101858. /**
  101859. * Disposes the resources of the material.
  101860. * @param forceDisposeTextures - Forces the disposal of all textures.
  101861. */
  101862. dispose(forceDisposeTextures?: boolean): void;
  101863. /**
  101864. * Get the current class name of the texture useful for serialization or dynamic coding.
  101865. * @returns "PBRAnisotropicConfiguration"
  101866. */
  101867. getClassName(): string;
  101868. /**
  101869. * Add fallbacks to the effect fallbacks list.
  101870. * @param defines defines the Base texture to use.
  101871. * @param fallbacks defines the current fallback list.
  101872. * @param currentRank defines the current fallback rank.
  101873. * @returns the new fallback rank.
  101874. */
  101875. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101876. /**
  101877. * Add the required uniforms to the current list.
  101878. * @param uniforms defines the current uniform list.
  101879. */
  101880. static AddUniforms(uniforms: string[]): void;
  101881. /**
  101882. * Add the required uniforms to the current buffer.
  101883. * @param uniformBuffer defines the current uniform buffer.
  101884. */
  101885. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101886. /**
  101887. * Add the required samplers to the current list.
  101888. * @param samplers defines the current sampler list.
  101889. */
  101890. static AddSamplers(samplers: string[]): void;
  101891. /**
  101892. * Makes a duplicate of the current configuration into another one.
  101893. * @param anisotropicConfiguration define the config where to copy the info
  101894. */
  101895. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101896. /**
  101897. * Serializes this anisotropy configuration.
  101898. * @returns - An object with the serialized config.
  101899. */
  101900. serialize(): any;
  101901. /**
  101902. * Parses a anisotropy Configuration from a serialized object.
  101903. * @param source - Serialized object.
  101904. */
  101905. parse(source: any): void;
  101906. }
  101907. }
  101908. declare module BABYLON {
  101909. /**
  101910. * @hidden
  101911. */
  101912. export interface IMaterialBRDFDefines {
  101913. BRDF_V_HEIGHT_CORRELATED: boolean;
  101914. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101915. /** @hidden */
  101916. _areMiscDirty: boolean;
  101917. }
  101918. /**
  101919. * Define the code related to the BRDF parameters of the pbr material.
  101920. */
  101921. export class PBRBRDFConfiguration {
  101922. private _useEnergyConservation;
  101923. /**
  101924. * Defines if the material uses energy conservation.
  101925. */
  101926. useEnergyConservation: boolean;
  101927. private _useSmithVisibilityHeightCorrelated;
  101928. /**
  101929. * LEGACY Mode set to false
  101930. * Defines if the material uses height smith correlated visibility term.
  101931. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101932. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101933. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101934. * Not relying on height correlated will also disable energy conservation.
  101935. */
  101936. useSmithVisibilityHeightCorrelated: boolean;
  101937. /** @hidden */
  101938. private _internalMarkAllSubMeshesAsMiscDirty;
  101939. /** @hidden */
  101940. _markAllSubMeshesAsMiscDirty(): void;
  101941. /**
  101942. * Instantiate a new istance of clear coat configuration.
  101943. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101944. */
  101945. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101946. /**
  101947. * Checks to see if a texture is used in the material.
  101948. * @param defines the list of "defines" to update.
  101949. */
  101950. prepareDefines(defines: IMaterialBRDFDefines): void;
  101951. /**
  101952. * Get the current class name of the texture useful for serialization or dynamic coding.
  101953. * @returns "PBRClearCoatConfiguration"
  101954. */
  101955. getClassName(): string;
  101956. /**
  101957. * Makes a duplicate of the current configuration into another one.
  101958. * @param brdfConfiguration define the config where to copy the info
  101959. */
  101960. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101961. /**
  101962. * Serializes this BRDF configuration.
  101963. * @returns - An object with the serialized config.
  101964. */
  101965. serialize(): any;
  101966. /**
  101967. * Parses a BRDF Configuration from a serialized object.
  101968. * @param source - Serialized object.
  101969. */
  101970. parse(source: any): void;
  101971. }
  101972. }
  101973. declare module BABYLON {
  101974. /**
  101975. * @hidden
  101976. */
  101977. export interface IMaterialSheenDefines {
  101978. SHEEN: boolean;
  101979. SHEEN_TEXTURE: boolean;
  101980. SHEEN_TEXTUREDIRECTUV: number;
  101981. SHEEN_LINKWITHALBEDO: boolean;
  101982. /** @hidden */
  101983. _areTexturesDirty: boolean;
  101984. }
  101985. /**
  101986. * Define the code related to the Sheen parameters of the pbr material.
  101987. */
  101988. export class PBRSheenConfiguration {
  101989. private _isEnabled;
  101990. /**
  101991. * Defines if the material uses sheen.
  101992. */
  101993. isEnabled: boolean;
  101994. private _linkSheenWithAlbedo;
  101995. /**
  101996. * Defines if the sheen is linked to the sheen color.
  101997. */
  101998. linkSheenWithAlbedo: boolean;
  101999. /**
  102000. * Defines the sheen intensity.
  102001. */
  102002. intensity: number;
  102003. /**
  102004. * Defines the sheen color.
  102005. */
  102006. color: Color3;
  102007. private _texture;
  102008. /**
  102009. * Stores the sheen tint values in a texture.
  102010. * rgb is tint
  102011. * a is a intensity
  102012. */
  102013. texture: Nullable<BaseTexture>;
  102014. /** @hidden */
  102015. private _internalMarkAllSubMeshesAsTexturesDirty;
  102016. /** @hidden */
  102017. _markAllSubMeshesAsTexturesDirty(): void;
  102018. /**
  102019. * Instantiate a new istance of clear coat configuration.
  102020. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  102021. */
  102022. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  102023. /**
  102024. * Specifies that the submesh is ready to be used.
  102025. * @param defines the list of "defines" to update.
  102026. * @param scene defines the scene the material belongs to.
  102027. * @returns - boolean indicating that the submesh is ready or not.
  102028. */
  102029. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  102030. /**
  102031. * Checks to see if a texture is used in the material.
  102032. * @param defines the list of "defines" to update.
  102033. * @param scene defines the scene the material belongs to.
  102034. */
  102035. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  102036. /**
  102037. * Binds the material data.
  102038. * @param uniformBuffer defines the Uniform buffer to fill in.
  102039. * @param scene defines the scene the material belongs to.
  102040. * @param isFrozen defines wether the material is frozen or not.
  102041. */
  102042. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  102043. /**
  102044. * Checks to see if a texture is used in the material.
  102045. * @param texture - Base texture to use.
  102046. * @returns - Boolean specifying if a texture is used in the material.
  102047. */
  102048. hasTexture(texture: BaseTexture): boolean;
  102049. /**
  102050. * Returns an array of the actively used textures.
  102051. * @param activeTextures Array of BaseTextures
  102052. */
  102053. getActiveTextures(activeTextures: BaseTexture[]): void;
  102054. /**
  102055. * Returns the animatable textures.
  102056. * @param animatables Array of animatable textures.
  102057. */
  102058. getAnimatables(animatables: IAnimatable[]): void;
  102059. /**
  102060. * Disposes the resources of the material.
  102061. * @param forceDisposeTextures - Forces the disposal of all textures.
  102062. */
  102063. dispose(forceDisposeTextures?: boolean): void;
  102064. /**
  102065. * Get the current class name of the texture useful for serialization or dynamic coding.
  102066. * @returns "PBRSheenConfiguration"
  102067. */
  102068. getClassName(): string;
  102069. /**
  102070. * Add fallbacks to the effect fallbacks list.
  102071. * @param defines defines the Base texture to use.
  102072. * @param fallbacks defines the current fallback list.
  102073. * @param currentRank defines the current fallback rank.
  102074. * @returns the new fallback rank.
  102075. */
  102076. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102077. /**
  102078. * Add the required uniforms to the current list.
  102079. * @param uniforms defines the current uniform list.
  102080. */
  102081. static AddUniforms(uniforms: string[]): void;
  102082. /**
  102083. * Add the required uniforms to the current buffer.
  102084. * @param uniformBuffer defines the current uniform buffer.
  102085. */
  102086. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102087. /**
  102088. * Add the required samplers to the current list.
  102089. * @param samplers defines the current sampler list.
  102090. */
  102091. static AddSamplers(samplers: string[]): void;
  102092. /**
  102093. * Makes a duplicate of the current configuration into another one.
  102094. * @param sheenConfiguration define the config where to copy the info
  102095. */
  102096. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  102097. /**
  102098. * Serializes this BRDF configuration.
  102099. * @returns - An object with the serialized config.
  102100. */
  102101. serialize(): any;
  102102. /**
  102103. * Parses a Sheen Configuration from a serialized object.
  102104. * @param source - Serialized object.
  102105. */
  102106. parse(source: any): void;
  102107. }
  102108. }
  102109. declare module BABYLON {
  102110. /** @hidden */
  102111. export var pbrFragmentDeclaration: {
  102112. name: string;
  102113. shader: string;
  102114. };
  102115. }
  102116. declare module BABYLON {
  102117. /** @hidden */
  102118. export var pbrUboDeclaration: {
  102119. name: string;
  102120. shader: string;
  102121. };
  102122. }
  102123. declare module BABYLON {
  102124. /** @hidden */
  102125. export var pbrFragmentExtraDeclaration: {
  102126. name: string;
  102127. shader: string;
  102128. };
  102129. }
  102130. declare module BABYLON {
  102131. /** @hidden */
  102132. export var pbrFragmentSamplersDeclaration: {
  102133. name: string;
  102134. shader: string;
  102135. };
  102136. }
  102137. declare module BABYLON {
  102138. /** @hidden */
  102139. export var pbrHelperFunctions: {
  102140. name: string;
  102141. shader: string;
  102142. };
  102143. }
  102144. declare module BABYLON {
  102145. /** @hidden */
  102146. export var harmonicsFunctions: {
  102147. name: string;
  102148. shader: string;
  102149. };
  102150. }
  102151. declare module BABYLON {
  102152. /** @hidden */
  102153. export var pbrDirectLightingSetupFunctions: {
  102154. name: string;
  102155. shader: string;
  102156. };
  102157. }
  102158. declare module BABYLON {
  102159. /** @hidden */
  102160. export var pbrDirectLightingFalloffFunctions: {
  102161. name: string;
  102162. shader: string;
  102163. };
  102164. }
  102165. declare module BABYLON {
  102166. /** @hidden */
  102167. export var pbrBRDFFunctions: {
  102168. name: string;
  102169. shader: string;
  102170. };
  102171. }
  102172. declare module BABYLON {
  102173. /** @hidden */
  102174. export var pbrDirectLightingFunctions: {
  102175. name: string;
  102176. shader: string;
  102177. };
  102178. }
  102179. declare module BABYLON {
  102180. /** @hidden */
  102181. export var pbrIBLFunctions: {
  102182. name: string;
  102183. shader: string;
  102184. };
  102185. }
  102186. declare module BABYLON {
  102187. /** @hidden */
  102188. export var pbrDebug: {
  102189. name: string;
  102190. shader: string;
  102191. };
  102192. }
  102193. declare module BABYLON {
  102194. /** @hidden */
  102195. export var pbrPixelShader: {
  102196. name: string;
  102197. shader: string;
  102198. };
  102199. }
  102200. declare module BABYLON {
  102201. /** @hidden */
  102202. export var pbrVertexDeclaration: {
  102203. name: string;
  102204. shader: string;
  102205. };
  102206. }
  102207. declare module BABYLON {
  102208. /** @hidden */
  102209. export var pbrVertexShader: {
  102210. name: string;
  102211. shader: string;
  102212. };
  102213. }
  102214. declare module BABYLON {
  102215. /**
  102216. * The Physically based material base class of BJS.
  102217. *
  102218. * This offers the main features of a standard PBR material.
  102219. * For more information, please refer to the documentation :
  102220. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102221. */
  102222. export abstract class PBRBaseMaterial extends PushMaterial {
  102223. /**
  102224. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102225. */
  102226. static readonly PBRMATERIAL_OPAQUE: number;
  102227. /**
  102228. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102229. */
  102230. static readonly PBRMATERIAL_ALPHATEST: number;
  102231. /**
  102232. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102233. */
  102234. static readonly PBRMATERIAL_ALPHABLEND: number;
  102235. /**
  102236. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102237. * They are also discarded below the alpha cutoff threshold to improve performances.
  102238. */
  102239. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102240. /**
  102241. * Defines the default value of how much AO map is occluding the analytical lights
  102242. * (point spot...).
  102243. */
  102244. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102245. /**
  102246. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102247. */
  102248. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102249. /**
  102250. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102251. * to enhance interoperability with other engines.
  102252. */
  102253. static readonly LIGHTFALLOFF_GLTF: number;
  102254. /**
  102255. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102256. * to enhance interoperability with other materials.
  102257. */
  102258. static readonly LIGHTFALLOFF_STANDARD: number;
  102259. /**
  102260. * Intensity of the direct lights e.g. the four lights available in your scene.
  102261. * This impacts both the direct diffuse and specular highlights.
  102262. */
  102263. protected _directIntensity: number;
  102264. /**
  102265. * Intensity of the emissive part of the material.
  102266. * This helps controlling the emissive effect without modifying the emissive color.
  102267. */
  102268. protected _emissiveIntensity: number;
  102269. /**
  102270. * Intensity of the environment e.g. how much the environment will light the object
  102271. * either through harmonics for rough material or through the refelction for shiny ones.
  102272. */
  102273. protected _environmentIntensity: number;
  102274. /**
  102275. * This is a special control allowing the reduction of the specular highlights coming from the
  102276. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102277. */
  102278. protected _specularIntensity: number;
  102279. /**
  102280. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102281. */
  102282. private _lightingInfos;
  102283. /**
  102284. * Debug Control allowing disabling the bump map on this material.
  102285. */
  102286. protected _disableBumpMap: boolean;
  102287. /**
  102288. * AKA Diffuse Texture in standard nomenclature.
  102289. */
  102290. protected _albedoTexture: BaseTexture;
  102291. /**
  102292. * AKA Occlusion Texture in other nomenclature.
  102293. */
  102294. protected _ambientTexture: BaseTexture;
  102295. /**
  102296. * AKA Occlusion Texture Intensity in other nomenclature.
  102297. */
  102298. protected _ambientTextureStrength: number;
  102299. /**
  102300. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102301. * 1 means it completely occludes it
  102302. * 0 mean it has no impact
  102303. */
  102304. protected _ambientTextureImpactOnAnalyticalLights: number;
  102305. /**
  102306. * Stores the alpha values in a texture.
  102307. */
  102308. protected _opacityTexture: BaseTexture;
  102309. /**
  102310. * Stores the reflection values in a texture.
  102311. */
  102312. protected _reflectionTexture: BaseTexture;
  102313. /**
  102314. * Stores the refraction values in a texture.
  102315. */
  102316. protected _refractionTexture: BaseTexture;
  102317. /**
  102318. * Stores the emissive values in a texture.
  102319. */
  102320. protected _emissiveTexture: BaseTexture;
  102321. /**
  102322. * AKA Specular texture in other nomenclature.
  102323. */
  102324. protected _reflectivityTexture: BaseTexture;
  102325. /**
  102326. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102327. */
  102328. protected _metallicTexture: BaseTexture;
  102329. /**
  102330. * Specifies the metallic scalar of the metallic/roughness workflow.
  102331. * Can also be used to scale the metalness values of the metallic texture.
  102332. */
  102333. protected _metallic: Nullable<number>;
  102334. /**
  102335. * Specifies the roughness scalar of the metallic/roughness workflow.
  102336. * Can also be used to scale the roughness values of the metallic texture.
  102337. */
  102338. protected _roughness: Nullable<number>;
  102339. /**
  102340. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102341. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102342. */
  102343. protected _microSurfaceTexture: BaseTexture;
  102344. /**
  102345. * Stores surface normal data used to displace a mesh in a texture.
  102346. */
  102347. protected _bumpTexture: BaseTexture;
  102348. /**
  102349. * Stores the pre-calculated light information of a mesh in a texture.
  102350. */
  102351. protected _lightmapTexture: BaseTexture;
  102352. /**
  102353. * The color of a material in ambient lighting.
  102354. */
  102355. protected _ambientColor: Color3;
  102356. /**
  102357. * AKA Diffuse Color in other nomenclature.
  102358. */
  102359. protected _albedoColor: Color3;
  102360. /**
  102361. * AKA Specular Color in other nomenclature.
  102362. */
  102363. protected _reflectivityColor: Color3;
  102364. /**
  102365. * The color applied when light is reflected from a material.
  102366. */
  102367. protected _reflectionColor: Color3;
  102368. /**
  102369. * The color applied when light is emitted from a material.
  102370. */
  102371. protected _emissiveColor: Color3;
  102372. /**
  102373. * AKA Glossiness in other nomenclature.
  102374. */
  102375. protected _microSurface: number;
  102376. /**
  102377. * source material index of refraction (IOR)' / 'destination material IOR.
  102378. */
  102379. protected _indexOfRefraction: number;
  102380. /**
  102381. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102382. */
  102383. protected _invertRefractionY: boolean;
  102384. /**
  102385. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102386. * Materials half opaque for instance using refraction could benefit from this control.
  102387. */
  102388. protected _linkRefractionWithTransparency: boolean;
  102389. /**
  102390. * Specifies that the material will use the light map as a show map.
  102391. */
  102392. protected _useLightmapAsShadowmap: boolean;
  102393. /**
  102394. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102395. * makes the reflect vector face the model (under horizon).
  102396. */
  102397. protected _useHorizonOcclusion: boolean;
  102398. /**
  102399. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102400. * too much the area relying on ambient texture to define their ambient occlusion.
  102401. */
  102402. protected _useRadianceOcclusion: boolean;
  102403. /**
  102404. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102405. */
  102406. protected _useAlphaFromAlbedoTexture: boolean;
  102407. /**
  102408. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102409. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102410. */
  102411. protected _useSpecularOverAlpha: boolean;
  102412. /**
  102413. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102414. */
  102415. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102416. /**
  102417. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102418. */
  102419. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102420. /**
  102421. * Specifies if the metallic texture contains the roughness information in its green channel.
  102422. */
  102423. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102424. /**
  102425. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102426. */
  102427. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102428. /**
  102429. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102430. */
  102431. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102432. /**
  102433. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102434. */
  102435. protected _useAmbientInGrayScale: boolean;
  102436. /**
  102437. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102438. * The material will try to infer what glossiness each pixel should be.
  102439. */
  102440. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102441. /**
  102442. * Defines the falloff type used in this material.
  102443. * It by default is Physical.
  102444. */
  102445. protected _lightFalloff: number;
  102446. /**
  102447. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102448. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102449. */
  102450. protected _useRadianceOverAlpha: boolean;
  102451. /**
  102452. * Allows using an object space normal map (instead of tangent space).
  102453. */
  102454. protected _useObjectSpaceNormalMap: boolean;
  102455. /**
  102456. * Allows using the bump map in parallax mode.
  102457. */
  102458. protected _useParallax: boolean;
  102459. /**
  102460. * Allows using the bump map in parallax occlusion mode.
  102461. */
  102462. protected _useParallaxOcclusion: boolean;
  102463. /**
  102464. * Controls the scale bias of the parallax mode.
  102465. */
  102466. protected _parallaxScaleBias: number;
  102467. /**
  102468. * If sets to true, disables all the lights affecting the material.
  102469. */
  102470. protected _disableLighting: boolean;
  102471. /**
  102472. * Number of Simultaneous lights allowed on the material.
  102473. */
  102474. protected _maxSimultaneousLights: number;
  102475. /**
  102476. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102477. */
  102478. protected _invertNormalMapX: boolean;
  102479. /**
  102480. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102481. */
  102482. protected _invertNormalMapY: boolean;
  102483. /**
  102484. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102485. */
  102486. protected _twoSidedLighting: boolean;
  102487. /**
  102488. * Defines the alpha limits in alpha test mode.
  102489. */
  102490. protected _alphaCutOff: number;
  102491. /**
  102492. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102493. */
  102494. protected _forceAlphaTest: boolean;
  102495. /**
  102496. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102497. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102498. */
  102499. protected _useAlphaFresnel: boolean;
  102500. /**
  102501. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102502. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102503. */
  102504. protected _useLinearAlphaFresnel: boolean;
  102505. /**
  102506. * The transparency mode of the material.
  102507. */
  102508. protected _transparencyMode: Nullable<number>;
  102509. /**
  102510. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102511. * from cos thetav and roughness:
  102512. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102513. */
  102514. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102515. /**
  102516. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102517. */
  102518. protected _forceIrradianceInFragment: boolean;
  102519. /**
  102520. * Force normal to face away from face.
  102521. */
  102522. protected _forceNormalForward: boolean;
  102523. /**
  102524. * Enables specular anti aliasing in the PBR shader.
  102525. * It will both interacts on the Geometry for analytical and IBL lighting.
  102526. * It also prefilter the roughness map based on the bump values.
  102527. */
  102528. protected _enableSpecularAntiAliasing: boolean;
  102529. /**
  102530. * Default configuration related to image processing available in the PBR Material.
  102531. */
  102532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102533. /**
  102534. * Keep track of the image processing observer to allow dispose and replace.
  102535. */
  102536. private _imageProcessingObserver;
  102537. /**
  102538. * Attaches a new image processing configuration to the PBR Material.
  102539. * @param configuration
  102540. */
  102541. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102542. /**
  102543. * Stores the available render targets.
  102544. */
  102545. private _renderTargets;
  102546. /**
  102547. * Sets the global ambient color for the material used in lighting calculations.
  102548. */
  102549. private _globalAmbientColor;
  102550. /**
  102551. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102552. */
  102553. private _useLogarithmicDepth;
  102554. /**
  102555. * If set to true, no lighting calculations will be applied.
  102556. */
  102557. private _unlit;
  102558. private _debugMode;
  102559. /**
  102560. * @hidden
  102561. * This is reserved for the inspector.
  102562. * Defines the material debug mode.
  102563. * It helps seeing only some components of the material while troubleshooting.
  102564. */
  102565. debugMode: number;
  102566. /**
  102567. * @hidden
  102568. * This is reserved for the inspector.
  102569. * Specify from where on screen the debug mode should start.
  102570. * The value goes from -1 (full screen) to 1 (not visible)
  102571. * It helps with side by side comparison against the final render
  102572. * This defaults to -1
  102573. */
  102574. private debugLimit;
  102575. /**
  102576. * @hidden
  102577. * This is reserved for the inspector.
  102578. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102579. * You can use the factor to better multiply the final value.
  102580. */
  102581. private debugFactor;
  102582. /**
  102583. * Defines the clear coat layer parameters for the material.
  102584. */
  102585. readonly clearCoat: PBRClearCoatConfiguration;
  102586. /**
  102587. * Defines the anisotropic parameters for the material.
  102588. */
  102589. readonly anisotropy: PBRAnisotropicConfiguration;
  102590. /**
  102591. * Defines the BRDF parameters for the material.
  102592. */
  102593. readonly brdf: PBRBRDFConfiguration;
  102594. /**
  102595. * Defines the Sheen parameters for the material.
  102596. */
  102597. readonly sheen: PBRSheenConfiguration;
  102598. /**
  102599. * Instantiates a new PBRMaterial instance.
  102600. *
  102601. * @param name The material name
  102602. * @param scene The scene the material will be use in.
  102603. */
  102604. constructor(name: string, scene: Scene);
  102605. /**
  102606. * Gets a boolean indicating that current material needs to register RTT
  102607. */
  102608. readonly hasRenderTargetTextures: boolean;
  102609. /**
  102610. * Gets the name of the material class.
  102611. */
  102612. getClassName(): string;
  102613. /**
  102614. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102615. */
  102616. /**
  102617. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102618. */
  102619. useLogarithmicDepth: boolean;
  102620. /**
  102621. * Gets the current transparency mode.
  102622. */
  102623. /**
  102624. * Sets the transparency mode of the material.
  102625. *
  102626. * | Value | Type | Description |
  102627. * | ----- | ----------------------------------- | ----------- |
  102628. * | 0 | OPAQUE | |
  102629. * | 1 | ALPHATEST | |
  102630. * | 2 | ALPHABLEND | |
  102631. * | 3 | ALPHATESTANDBLEND | |
  102632. *
  102633. */
  102634. transparencyMode: Nullable<number>;
  102635. /**
  102636. * Returns true if alpha blending should be disabled.
  102637. */
  102638. private readonly _disableAlphaBlending;
  102639. /**
  102640. * Specifies whether or not this material should be rendered in alpha blend mode.
  102641. */
  102642. needAlphaBlending(): boolean;
  102643. /**
  102644. * Specifies if the mesh will require alpha blending.
  102645. * @param mesh - BJS mesh.
  102646. */
  102647. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102648. /**
  102649. * Specifies whether or not this material should be rendered in alpha test mode.
  102650. */
  102651. needAlphaTesting(): boolean;
  102652. /**
  102653. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102654. */
  102655. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102656. /**
  102657. * Gets the texture used for the alpha test.
  102658. */
  102659. getAlphaTestTexture(): BaseTexture;
  102660. /**
  102661. * Specifies that the submesh is ready to be used.
  102662. * @param mesh - BJS mesh.
  102663. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102664. * @param useInstances - Specifies that instances should be used.
  102665. * @returns - boolean indicating that the submesh is ready or not.
  102666. */
  102667. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102668. /**
  102669. * Specifies if the material uses metallic roughness workflow.
  102670. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102671. */
  102672. isMetallicWorkflow(): boolean;
  102673. private _prepareEffect;
  102674. private _prepareDefines;
  102675. /**
  102676. * Force shader compilation
  102677. */
  102678. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102679. clipPlane: boolean;
  102680. }>): void;
  102681. /**
  102682. * Initializes the uniform buffer layout for the shader.
  102683. */
  102684. buildUniformLayout(): void;
  102685. /**
  102686. * Unbinds the textures.
  102687. */
  102688. unbind(): void;
  102689. /**
  102690. * Binds the submesh data.
  102691. * @param world - The world matrix.
  102692. * @param mesh - The BJS mesh.
  102693. * @param subMesh - A submesh of the BJS mesh.
  102694. */
  102695. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102696. /**
  102697. * Returns the animatable textures.
  102698. * @returns - Array of animatable textures.
  102699. */
  102700. getAnimatables(): IAnimatable[];
  102701. /**
  102702. * Returns the texture used for reflections.
  102703. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102704. */
  102705. private _getReflectionTexture;
  102706. /**
  102707. * Returns the texture used for refraction or null if none is used.
  102708. * @returns - Refection texture if present. If no refraction texture and refraction
  102709. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102710. */
  102711. private _getRefractionTexture;
  102712. /**
  102713. * Returns an array of the actively used textures.
  102714. * @returns - Array of BaseTextures
  102715. */
  102716. getActiveTextures(): BaseTexture[];
  102717. /**
  102718. * Checks to see if a texture is used in the material.
  102719. * @param texture - Base texture to use.
  102720. * @returns - Boolean specifying if a texture is used in the material.
  102721. */
  102722. hasTexture(texture: BaseTexture): boolean;
  102723. /**
  102724. * Disposes the resources of the material.
  102725. * @param forceDisposeEffect - Forces the disposal of effects.
  102726. * @param forceDisposeTextures - Forces the disposal of all textures.
  102727. */
  102728. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102729. }
  102730. }
  102731. declare module BABYLON {
  102732. /**
  102733. * The Physically based material of BJS.
  102734. *
  102735. * This offers the main features of a standard PBR material.
  102736. * For more information, please refer to the documentation :
  102737. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102738. */
  102739. export class PBRMaterial extends PBRBaseMaterial {
  102740. /**
  102741. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102742. */
  102743. static readonly PBRMATERIAL_OPAQUE: number;
  102744. /**
  102745. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102746. */
  102747. static readonly PBRMATERIAL_ALPHATEST: number;
  102748. /**
  102749. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102750. */
  102751. static readonly PBRMATERIAL_ALPHABLEND: number;
  102752. /**
  102753. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102754. * They are also discarded below the alpha cutoff threshold to improve performances.
  102755. */
  102756. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102757. /**
  102758. * Defines the default value of how much AO map is occluding the analytical lights
  102759. * (point spot...).
  102760. */
  102761. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102762. /**
  102763. * Intensity of the direct lights e.g. the four lights available in your scene.
  102764. * This impacts both the direct diffuse and specular highlights.
  102765. */
  102766. directIntensity: number;
  102767. /**
  102768. * Intensity of the emissive part of the material.
  102769. * This helps controlling the emissive effect without modifying the emissive color.
  102770. */
  102771. emissiveIntensity: number;
  102772. /**
  102773. * Intensity of the environment e.g. how much the environment will light the object
  102774. * either through harmonics for rough material or through the refelction for shiny ones.
  102775. */
  102776. environmentIntensity: number;
  102777. /**
  102778. * This is a special control allowing the reduction of the specular highlights coming from the
  102779. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102780. */
  102781. specularIntensity: number;
  102782. /**
  102783. * Debug Control allowing disabling the bump map on this material.
  102784. */
  102785. disableBumpMap: boolean;
  102786. /**
  102787. * AKA Diffuse Texture in standard nomenclature.
  102788. */
  102789. albedoTexture: BaseTexture;
  102790. /**
  102791. * AKA Occlusion Texture in other nomenclature.
  102792. */
  102793. ambientTexture: BaseTexture;
  102794. /**
  102795. * AKA Occlusion Texture Intensity in other nomenclature.
  102796. */
  102797. ambientTextureStrength: number;
  102798. /**
  102799. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102800. * 1 means it completely occludes it
  102801. * 0 mean it has no impact
  102802. */
  102803. ambientTextureImpactOnAnalyticalLights: number;
  102804. /**
  102805. * Stores the alpha values in a texture.
  102806. */
  102807. opacityTexture: BaseTexture;
  102808. /**
  102809. * Stores the reflection values in a texture.
  102810. */
  102811. reflectionTexture: Nullable<BaseTexture>;
  102812. /**
  102813. * Stores the emissive values in a texture.
  102814. */
  102815. emissiveTexture: BaseTexture;
  102816. /**
  102817. * AKA Specular texture in other nomenclature.
  102818. */
  102819. reflectivityTexture: BaseTexture;
  102820. /**
  102821. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102822. */
  102823. metallicTexture: BaseTexture;
  102824. /**
  102825. * Specifies the metallic scalar of the metallic/roughness workflow.
  102826. * Can also be used to scale the metalness values of the metallic texture.
  102827. */
  102828. metallic: Nullable<number>;
  102829. /**
  102830. * Specifies the roughness scalar of the metallic/roughness workflow.
  102831. * Can also be used to scale the roughness values of the metallic texture.
  102832. */
  102833. roughness: Nullable<number>;
  102834. /**
  102835. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102836. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102837. */
  102838. microSurfaceTexture: BaseTexture;
  102839. /**
  102840. * Stores surface normal data used to displace a mesh in a texture.
  102841. */
  102842. bumpTexture: BaseTexture;
  102843. /**
  102844. * Stores the pre-calculated light information of a mesh in a texture.
  102845. */
  102846. lightmapTexture: BaseTexture;
  102847. /**
  102848. * Stores the refracted light information in a texture.
  102849. */
  102850. refractionTexture: BaseTexture;
  102851. /**
  102852. * The color of a material in ambient lighting.
  102853. */
  102854. ambientColor: Color3;
  102855. /**
  102856. * AKA Diffuse Color in other nomenclature.
  102857. */
  102858. albedoColor: Color3;
  102859. /**
  102860. * AKA Specular Color in other nomenclature.
  102861. */
  102862. reflectivityColor: Color3;
  102863. /**
  102864. * The color reflected from the material.
  102865. */
  102866. reflectionColor: Color3;
  102867. /**
  102868. * The color emitted from the material.
  102869. */
  102870. emissiveColor: Color3;
  102871. /**
  102872. * AKA Glossiness in other nomenclature.
  102873. */
  102874. microSurface: number;
  102875. /**
  102876. * source material index of refraction (IOR)' / 'destination material IOR.
  102877. */
  102878. indexOfRefraction: number;
  102879. /**
  102880. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102881. */
  102882. invertRefractionY: boolean;
  102883. /**
  102884. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102885. * Materials half opaque for instance using refraction could benefit from this control.
  102886. */
  102887. linkRefractionWithTransparency: boolean;
  102888. /**
  102889. * If true, the light map contains occlusion information instead of lighting info.
  102890. */
  102891. useLightmapAsShadowmap: boolean;
  102892. /**
  102893. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102894. */
  102895. useAlphaFromAlbedoTexture: boolean;
  102896. /**
  102897. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102898. */
  102899. forceAlphaTest: boolean;
  102900. /**
  102901. * Defines the alpha limits in alpha test mode.
  102902. */
  102903. alphaCutOff: number;
  102904. /**
  102905. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102906. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102907. */
  102908. useSpecularOverAlpha: boolean;
  102909. /**
  102910. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102911. */
  102912. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102913. /**
  102914. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102915. */
  102916. useRoughnessFromMetallicTextureAlpha: boolean;
  102917. /**
  102918. * Specifies if the metallic texture contains the roughness information in its green channel.
  102919. */
  102920. useRoughnessFromMetallicTextureGreen: boolean;
  102921. /**
  102922. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102923. */
  102924. useMetallnessFromMetallicTextureBlue: boolean;
  102925. /**
  102926. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102927. */
  102928. useAmbientOcclusionFromMetallicTextureRed: boolean;
  102929. /**
  102930. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102931. */
  102932. useAmbientInGrayScale: boolean;
  102933. /**
  102934. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102935. * The material will try to infer what glossiness each pixel should be.
  102936. */
  102937. useAutoMicroSurfaceFromReflectivityMap: boolean;
  102938. /**
  102939. * BJS is using an harcoded light falloff based on a manually sets up range.
  102940. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102941. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102942. */
  102943. /**
  102944. * BJS is using an harcoded light falloff based on a manually sets up range.
  102945. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102946. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102947. */
  102948. usePhysicalLightFalloff: boolean;
  102949. /**
  102950. * In order to support the falloff compatibility with gltf, a special mode has been added
  102951. * to reproduce the gltf light falloff.
  102952. */
  102953. /**
  102954. * In order to support the falloff compatibility with gltf, a special mode has been added
  102955. * to reproduce the gltf light falloff.
  102956. */
  102957. useGLTFLightFalloff: boolean;
  102958. /**
  102959. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102960. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102961. */
  102962. useRadianceOverAlpha: boolean;
  102963. /**
  102964. * Allows using an object space normal map (instead of tangent space).
  102965. */
  102966. useObjectSpaceNormalMap: boolean;
  102967. /**
  102968. * Allows using the bump map in parallax mode.
  102969. */
  102970. useParallax: boolean;
  102971. /**
  102972. * Allows using the bump map in parallax occlusion mode.
  102973. */
  102974. useParallaxOcclusion: boolean;
  102975. /**
  102976. * Controls the scale bias of the parallax mode.
  102977. */
  102978. parallaxScaleBias: number;
  102979. /**
  102980. * If sets to true, disables all the lights affecting the material.
  102981. */
  102982. disableLighting: boolean;
  102983. /**
  102984. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102985. */
  102986. forceIrradianceInFragment: boolean;
  102987. /**
  102988. * Number of Simultaneous lights allowed on the material.
  102989. */
  102990. maxSimultaneousLights: number;
  102991. /**
  102992. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102993. */
  102994. invertNormalMapX: boolean;
  102995. /**
  102996. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102997. */
  102998. invertNormalMapY: boolean;
  102999. /**
  103000. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103001. */
  103002. twoSidedLighting: boolean;
  103003. /**
  103004. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103005. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103006. */
  103007. useAlphaFresnel: boolean;
  103008. /**
  103009. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103010. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103011. */
  103012. useLinearAlphaFresnel: boolean;
  103013. /**
  103014. * Let user defines the brdf lookup texture used for IBL.
  103015. * A default 8bit version is embedded but you could point at :
  103016. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  103017. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103018. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103019. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103020. */
  103021. environmentBRDFTexture: Nullable<BaseTexture>;
  103022. /**
  103023. * Force normal to face away from face.
  103024. */
  103025. forceNormalForward: boolean;
  103026. /**
  103027. * Enables specular anti aliasing in the PBR shader.
  103028. * It will both interacts on the Geometry for analytical and IBL lighting.
  103029. * It also prefilter the roughness map based on the bump values.
  103030. */
  103031. enableSpecularAntiAliasing: boolean;
  103032. /**
  103033. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103034. * makes the reflect vector face the model (under horizon).
  103035. */
  103036. useHorizonOcclusion: boolean;
  103037. /**
  103038. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103039. * too much the area relying on ambient texture to define their ambient occlusion.
  103040. */
  103041. useRadianceOcclusion: boolean;
  103042. /**
  103043. * If set to true, no lighting calculations will be applied.
  103044. */
  103045. unlit: boolean;
  103046. /**
  103047. * Gets the image processing configuration used either in this material.
  103048. */
  103049. /**
  103050. * Sets the Default image processing configuration used either in the this material.
  103051. *
  103052. * If sets to null, the scene one is in use.
  103053. */
  103054. imageProcessingConfiguration: ImageProcessingConfiguration;
  103055. /**
  103056. * Gets wether the color curves effect is enabled.
  103057. */
  103058. /**
  103059. * Sets wether the color curves effect is enabled.
  103060. */
  103061. cameraColorCurvesEnabled: boolean;
  103062. /**
  103063. * Gets wether the color grading effect is enabled.
  103064. */
  103065. /**
  103066. * Gets wether the color grading effect is enabled.
  103067. */
  103068. cameraColorGradingEnabled: boolean;
  103069. /**
  103070. * Gets wether tonemapping is enabled or not.
  103071. */
  103072. /**
  103073. * Sets wether tonemapping is enabled or not
  103074. */
  103075. cameraToneMappingEnabled: boolean;
  103076. /**
  103077. * The camera exposure used on this material.
  103078. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103079. * This corresponds to a photographic exposure.
  103080. */
  103081. /**
  103082. * The camera exposure used on this material.
  103083. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103084. * This corresponds to a photographic exposure.
  103085. */
  103086. cameraExposure: number;
  103087. /**
  103088. * Gets The camera contrast used on this material.
  103089. */
  103090. /**
  103091. * Sets The camera contrast used on this material.
  103092. */
  103093. cameraContrast: number;
  103094. /**
  103095. * Gets the Color Grading 2D Lookup Texture.
  103096. */
  103097. /**
  103098. * Sets the Color Grading 2D Lookup Texture.
  103099. */
  103100. cameraColorGradingTexture: Nullable<BaseTexture>;
  103101. /**
  103102. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103103. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103104. * 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;
  103105. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103106. */
  103107. /**
  103108. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103109. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103110. * 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;
  103111. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103112. */
  103113. cameraColorCurves: Nullable<ColorCurves>;
  103114. /**
  103115. * Instantiates a new PBRMaterial instance.
  103116. *
  103117. * @param name The material name
  103118. * @param scene The scene the material will be use in.
  103119. */
  103120. constructor(name: string, scene: Scene);
  103121. /**
  103122. * Returns the name of this material class.
  103123. */
  103124. getClassName(): string;
  103125. /**
  103126. * Makes a duplicate of the current material.
  103127. * @param name - name to use for the new material.
  103128. */
  103129. clone(name: string): PBRMaterial;
  103130. /**
  103131. * Serializes this PBR Material.
  103132. * @returns - An object with the serialized material.
  103133. */
  103134. serialize(): any;
  103135. /**
  103136. * Parses a PBR Material from a serialized object.
  103137. * @param source - Serialized object.
  103138. * @param scene - BJS scene instance.
  103139. * @param rootUrl - url for the scene object
  103140. * @returns - PBRMaterial
  103141. */
  103142. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103143. }
  103144. }
  103145. declare module BABYLON {
  103146. /**
  103147. * Direct draw surface info
  103148. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103149. */
  103150. export interface DDSInfo {
  103151. /**
  103152. * Width of the texture
  103153. */
  103154. width: number;
  103155. /**
  103156. * Width of the texture
  103157. */
  103158. height: number;
  103159. /**
  103160. * Number of Mipmaps for the texture
  103161. * @see https://en.wikipedia.org/wiki/Mipmap
  103162. */
  103163. mipmapCount: number;
  103164. /**
  103165. * If the textures format is a known fourCC format
  103166. * @see https://www.fourcc.org/
  103167. */
  103168. isFourCC: boolean;
  103169. /**
  103170. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103171. */
  103172. isRGB: boolean;
  103173. /**
  103174. * If the texture is a lumincance format
  103175. */
  103176. isLuminance: boolean;
  103177. /**
  103178. * If this is a cube texture
  103179. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103180. */
  103181. isCube: boolean;
  103182. /**
  103183. * If the texture is a compressed format eg. FOURCC_DXT1
  103184. */
  103185. isCompressed: boolean;
  103186. /**
  103187. * The dxgiFormat of the texture
  103188. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103189. */
  103190. dxgiFormat: number;
  103191. /**
  103192. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103193. */
  103194. textureType: number;
  103195. /**
  103196. * Sphericle polynomial created for the dds texture
  103197. */
  103198. sphericalPolynomial?: SphericalPolynomial;
  103199. }
  103200. /**
  103201. * Class used to provide DDS decompression tools
  103202. */
  103203. export class DDSTools {
  103204. /**
  103205. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103206. */
  103207. static StoreLODInAlphaChannel: boolean;
  103208. /**
  103209. * Gets DDS information from an array buffer
  103210. * @param arrayBuffer defines the array buffer to read data from
  103211. * @returns the DDS information
  103212. */
  103213. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103214. private static _FloatView;
  103215. private static _Int32View;
  103216. private static _ToHalfFloat;
  103217. private static _FromHalfFloat;
  103218. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103219. private static _GetHalfFloatRGBAArrayBuffer;
  103220. private static _GetFloatRGBAArrayBuffer;
  103221. private static _GetFloatAsUIntRGBAArrayBuffer;
  103222. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103223. private static _GetRGBAArrayBuffer;
  103224. private static _ExtractLongWordOrder;
  103225. private static _GetRGBArrayBuffer;
  103226. private static _GetLuminanceArrayBuffer;
  103227. /**
  103228. * Uploads DDS Levels to a Babylon Texture
  103229. * @hidden
  103230. */
  103231. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103232. }
  103233. interface Engine {
  103234. /**
  103235. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103236. * @param rootUrl defines the url where the file to load is located
  103237. * @param scene defines the current scene
  103238. * @param lodScale defines scale to apply to the mip map selection
  103239. * @param lodOffset defines offset to apply to the mip map selection
  103240. * @param onLoad defines an optional callback raised when the texture is loaded
  103241. * @param onError defines an optional callback raised if there is an issue to load the texture
  103242. * @param format defines the format of the data
  103243. * @param forcedExtension defines the extension to use to pick the right loader
  103244. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103245. * @returns the cube texture as an InternalTexture
  103246. */
  103247. 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;
  103248. }
  103249. }
  103250. declare module BABYLON {
  103251. /**
  103252. * Implementation of the DDS Texture Loader.
  103253. * @hidden
  103254. */
  103255. export class _DDSTextureLoader implements IInternalTextureLoader {
  103256. /**
  103257. * Defines wether the loader supports cascade loading the different faces.
  103258. */
  103259. readonly supportCascades: boolean;
  103260. /**
  103261. * This returns if the loader support the current file information.
  103262. * @param extension defines the file extension of the file being loaded
  103263. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103264. * @param fallback defines the fallback internal texture if any
  103265. * @param isBase64 defines whether the texture is encoded as a base64
  103266. * @param isBuffer defines whether the texture data are stored as a buffer
  103267. * @returns true if the loader can load the specified file
  103268. */
  103269. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103270. /**
  103271. * Transform the url before loading if required.
  103272. * @param rootUrl the url of the texture
  103273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103274. * @returns the transformed texture
  103275. */
  103276. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103277. /**
  103278. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103279. * @param rootUrl the url of the texture
  103280. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103281. * @returns the fallback texture
  103282. */
  103283. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103284. /**
  103285. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103286. * @param data contains the texture data
  103287. * @param texture defines the BabylonJS internal texture
  103288. * @param createPolynomials will be true if polynomials have been requested
  103289. * @param onLoad defines the callback to trigger once the texture is ready
  103290. * @param onError defines the callback to trigger in case of error
  103291. */
  103292. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103293. /**
  103294. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103295. * @param data contains the texture data
  103296. * @param texture defines the BabylonJS internal texture
  103297. * @param callback defines the method to call once ready to upload
  103298. */
  103299. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103300. }
  103301. }
  103302. declare module BABYLON {
  103303. /** @hidden */
  103304. export var rgbdEncodePixelShader: {
  103305. name: string;
  103306. shader: string;
  103307. };
  103308. }
  103309. declare module BABYLON {
  103310. /** @hidden */
  103311. export var rgbdDecodePixelShader: {
  103312. name: string;
  103313. shader: string;
  103314. };
  103315. }
  103316. declare module BABYLON {
  103317. /**
  103318. * Raw texture data and descriptor sufficient for WebGL texture upload
  103319. */
  103320. export interface EnvironmentTextureInfo {
  103321. /**
  103322. * Version of the environment map
  103323. */
  103324. version: number;
  103325. /**
  103326. * Width of image
  103327. */
  103328. width: number;
  103329. /**
  103330. * Irradiance information stored in the file.
  103331. */
  103332. irradiance: any;
  103333. /**
  103334. * Specular information stored in the file.
  103335. */
  103336. specular: any;
  103337. }
  103338. /**
  103339. * Sets of helpers addressing the serialization and deserialization of environment texture
  103340. * stored in a BabylonJS env file.
  103341. * Those files are usually stored as .env files.
  103342. */
  103343. export class EnvironmentTextureTools {
  103344. /**
  103345. * Magic number identifying the env file.
  103346. */
  103347. private static _MagicBytes;
  103348. /**
  103349. * Gets the environment info from an env file.
  103350. * @param data The array buffer containing the .env bytes.
  103351. * @returns the environment file info (the json header) if successfully parsed.
  103352. */
  103353. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103354. /**
  103355. * Creates an environment texture from a loaded cube texture.
  103356. * @param texture defines the cube texture to convert in env file
  103357. * @return a promise containing the environment data if succesfull.
  103358. */
  103359. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103360. /**
  103361. * Creates a JSON representation of the spherical data.
  103362. * @param texture defines the texture containing the polynomials
  103363. * @return the JSON representation of the spherical info
  103364. */
  103365. private static _CreateEnvTextureIrradiance;
  103366. /**
  103367. * Uploads the texture info contained in the env file to the GPU.
  103368. * @param texture defines the internal texture to upload to
  103369. * @param arrayBuffer defines the buffer cotaining the data to load
  103370. * @param info defines the texture info retrieved through the GetEnvInfo method
  103371. * @returns a promise
  103372. */
  103373. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103374. /**
  103375. * Uploads the levels of image data to the GPU.
  103376. * @param texture defines the internal texture to upload to
  103377. * @param imageData defines the array buffer views of image data [mipmap][face]
  103378. * @returns a promise
  103379. */
  103380. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103381. /**
  103382. * Uploads spherical polynomials information to the texture.
  103383. * @param texture defines the texture we are trying to upload the information to
  103384. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103385. */
  103386. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103387. /** @hidden */
  103388. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103389. }
  103390. }
  103391. declare module BABYLON {
  103392. /**
  103393. * Implementation of the ENV Texture Loader.
  103394. * @hidden
  103395. */
  103396. export class _ENVTextureLoader implements IInternalTextureLoader {
  103397. /**
  103398. * Defines wether the loader supports cascade loading the different faces.
  103399. */
  103400. readonly supportCascades: boolean;
  103401. /**
  103402. * This returns if the loader support the current file information.
  103403. * @param extension defines the file extension of the file being loaded
  103404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103405. * @param fallback defines the fallback internal texture if any
  103406. * @param isBase64 defines whether the texture is encoded as a base64
  103407. * @param isBuffer defines whether the texture data are stored as a buffer
  103408. * @returns true if the loader can load the specified file
  103409. */
  103410. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103411. /**
  103412. * Transform the url before loading if required.
  103413. * @param rootUrl the url of the texture
  103414. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103415. * @returns the transformed texture
  103416. */
  103417. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103418. /**
  103419. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103420. * @param rootUrl the url of the texture
  103421. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103422. * @returns the fallback texture
  103423. */
  103424. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103425. /**
  103426. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103427. * @param data contains the texture data
  103428. * @param texture defines the BabylonJS internal texture
  103429. * @param createPolynomials will be true if polynomials have been requested
  103430. * @param onLoad defines the callback to trigger once the texture is ready
  103431. * @param onError defines the callback to trigger in case of error
  103432. */
  103433. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103434. /**
  103435. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103436. * @param data contains the texture data
  103437. * @param texture defines the BabylonJS internal texture
  103438. * @param callback defines the method to call once ready to upload
  103439. */
  103440. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103441. }
  103442. }
  103443. declare module BABYLON {
  103444. /**
  103445. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103446. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103447. */
  103448. export class KhronosTextureContainer {
  103449. /** contents of the KTX container file */
  103450. arrayBuffer: any;
  103451. private static HEADER_LEN;
  103452. private static COMPRESSED_2D;
  103453. private static COMPRESSED_3D;
  103454. private static TEX_2D;
  103455. private static TEX_3D;
  103456. /**
  103457. * Gets the openGL type
  103458. */
  103459. glType: number;
  103460. /**
  103461. * Gets the openGL type size
  103462. */
  103463. glTypeSize: number;
  103464. /**
  103465. * Gets the openGL format
  103466. */
  103467. glFormat: number;
  103468. /**
  103469. * Gets the openGL internal format
  103470. */
  103471. glInternalFormat: number;
  103472. /**
  103473. * Gets the base internal format
  103474. */
  103475. glBaseInternalFormat: number;
  103476. /**
  103477. * Gets image width in pixel
  103478. */
  103479. pixelWidth: number;
  103480. /**
  103481. * Gets image height in pixel
  103482. */
  103483. pixelHeight: number;
  103484. /**
  103485. * Gets image depth in pixels
  103486. */
  103487. pixelDepth: number;
  103488. /**
  103489. * Gets the number of array elements
  103490. */
  103491. numberOfArrayElements: number;
  103492. /**
  103493. * Gets the number of faces
  103494. */
  103495. numberOfFaces: number;
  103496. /**
  103497. * Gets the number of mipmap levels
  103498. */
  103499. numberOfMipmapLevels: number;
  103500. /**
  103501. * Gets the bytes of key value data
  103502. */
  103503. bytesOfKeyValueData: number;
  103504. /**
  103505. * Gets the load type
  103506. */
  103507. loadType: number;
  103508. /**
  103509. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103510. */
  103511. isInvalid: boolean;
  103512. /**
  103513. * Creates a new KhronosTextureContainer
  103514. * @param arrayBuffer contents of the KTX container file
  103515. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103516. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103517. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103518. */
  103519. constructor(
  103520. /** contents of the KTX container file */
  103521. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103522. /**
  103523. * Uploads KTX content to a Babylon Texture.
  103524. * It is assumed that the texture has already been created & is currently bound
  103525. * @hidden
  103526. */
  103527. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103528. private _upload2DCompressedLevels;
  103529. }
  103530. }
  103531. declare module BABYLON {
  103532. /**
  103533. * Implementation of the KTX Texture Loader.
  103534. * @hidden
  103535. */
  103536. export class _KTXTextureLoader implements IInternalTextureLoader {
  103537. /**
  103538. * Defines wether the loader supports cascade loading the different faces.
  103539. */
  103540. readonly supportCascades: boolean;
  103541. /**
  103542. * This returns if the loader support the current file information.
  103543. * @param extension defines the file extension of the file being loaded
  103544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103545. * @param fallback defines the fallback internal texture if any
  103546. * @param isBase64 defines whether the texture is encoded as a base64
  103547. * @param isBuffer defines whether the texture data are stored as a buffer
  103548. * @returns true if the loader can load the specified file
  103549. */
  103550. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103551. /**
  103552. * Transform the url before loading if required.
  103553. * @param rootUrl the url of the texture
  103554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103555. * @returns the transformed texture
  103556. */
  103557. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103558. /**
  103559. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103560. * @param rootUrl the url of the texture
  103561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103562. * @returns the fallback texture
  103563. */
  103564. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103565. /**
  103566. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103567. * @param data contains the texture data
  103568. * @param texture defines the BabylonJS internal texture
  103569. * @param createPolynomials will be true if polynomials have been requested
  103570. * @param onLoad defines the callback to trigger once the texture is ready
  103571. * @param onError defines the callback to trigger in case of error
  103572. */
  103573. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103574. /**
  103575. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103576. * @param data contains the texture data
  103577. * @param texture defines the BabylonJS internal texture
  103578. * @param callback defines the method to call once ready to upload
  103579. */
  103580. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103581. }
  103582. }
  103583. declare module BABYLON {
  103584. /** @hidden */
  103585. export var _forceSceneHelpersToBundle: boolean;
  103586. interface Scene {
  103587. /**
  103588. * Creates a default light for the scene.
  103589. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103590. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103591. */
  103592. createDefaultLight(replace?: boolean): void;
  103593. /**
  103594. * Creates a default camera for the scene.
  103595. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103596. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103597. * @param replace has default false, when true replaces the active camera in the scene
  103598. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103599. */
  103600. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103601. /**
  103602. * Creates a default camera and a default light.
  103603. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103604. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103605. * @param replace has the default false, when true replaces the active camera/light in the scene
  103606. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103607. */
  103608. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103609. /**
  103610. * Creates a new sky box
  103611. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103612. * @param environmentTexture defines the texture to use as environment texture
  103613. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103614. * @param scale defines the overall scale of the skybox
  103615. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103616. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103617. * @returns a new mesh holding the sky box
  103618. */
  103619. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103620. /**
  103621. * Creates a new environment
  103622. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103623. * @param options defines the options you can use to configure the environment
  103624. * @returns the new EnvironmentHelper
  103625. */
  103626. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103627. /**
  103628. * Creates a new VREXperienceHelper
  103629. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103630. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103631. * @returns a new VREXperienceHelper
  103632. */
  103633. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103634. /**
  103635. * Creates a new XREXperienceHelper
  103636. * @see http://doc.babylonjs.com/how_to/webxr
  103637. * @returns a promise for a new XREXperienceHelper
  103638. */
  103639. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103640. }
  103641. }
  103642. declare module BABYLON {
  103643. /**
  103644. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103645. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103646. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103647. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103648. */
  103649. export class VideoDome extends TransformNode {
  103650. /**
  103651. * Define the video source as a Monoscopic panoramic 360 video.
  103652. */
  103653. static readonly MODE_MONOSCOPIC: number;
  103654. /**
  103655. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103656. */
  103657. static readonly MODE_TOPBOTTOM: number;
  103658. /**
  103659. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103660. */
  103661. static readonly MODE_SIDEBYSIDE: number;
  103662. private _useDirectMapping;
  103663. /**
  103664. * The video texture being displayed on the sphere
  103665. */
  103666. protected _videoTexture: VideoTexture;
  103667. /**
  103668. * Gets the video texture being displayed on the sphere
  103669. */
  103670. readonly videoTexture: VideoTexture;
  103671. /**
  103672. * The skybox material
  103673. */
  103674. protected _material: BackgroundMaterial;
  103675. /**
  103676. * The surface used for the skybox
  103677. */
  103678. protected _mesh: Mesh;
  103679. /**
  103680. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103681. * Also see the options.resolution property.
  103682. */
  103683. fovMultiplier: number;
  103684. private _videoMode;
  103685. /**
  103686. * Gets or set the current video mode for the video. It can be:
  103687. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103688. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103689. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103690. */
  103691. videoMode: number;
  103692. /**
  103693. * Oberserver used in Stereoscopic VR Mode.
  103694. */
  103695. private _onBeforeCameraRenderObserver;
  103696. /**
  103697. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103698. * @param name Element's name, child elements will append suffixes for their own names.
  103699. * @param urlsOrVideo defines the url(s) or the video element to use
  103700. * @param options An object containing optional or exposed sub element properties
  103701. */
  103702. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103703. resolution?: number;
  103704. clickToPlay?: boolean;
  103705. autoPlay?: boolean;
  103706. loop?: boolean;
  103707. size?: number;
  103708. poster?: string;
  103709. faceForward?: boolean;
  103710. useDirectMapping?: boolean;
  103711. }, scene: Scene);
  103712. private _changeVideoMode;
  103713. /**
  103714. * Releases resources associated with this node.
  103715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103717. */
  103718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103719. }
  103720. }
  103721. declare module BABYLON {
  103722. /**
  103723. * This class can be used to get instrumentation data from a Babylon engine
  103724. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103725. */
  103726. export class EngineInstrumentation implements IDisposable {
  103727. /**
  103728. * Define the instrumented engine.
  103729. */
  103730. engine: Engine;
  103731. private _captureGPUFrameTime;
  103732. private _gpuFrameTimeToken;
  103733. private _gpuFrameTime;
  103734. private _captureShaderCompilationTime;
  103735. private _shaderCompilationTime;
  103736. private _onBeginFrameObserver;
  103737. private _onEndFrameObserver;
  103738. private _onBeforeShaderCompilationObserver;
  103739. private _onAfterShaderCompilationObserver;
  103740. /**
  103741. * Gets the perf counter used for GPU frame time
  103742. */
  103743. readonly gpuFrameTimeCounter: PerfCounter;
  103744. /**
  103745. * Gets the GPU frame time capture status
  103746. */
  103747. /**
  103748. * Enable or disable the GPU frame time capture
  103749. */
  103750. captureGPUFrameTime: boolean;
  103751. /**
  103752. * Gets the perf counter used for shader compilation time
  103753. */
  103754. readonly shaderCompilationTimeCounter: PerfCounter;
  103755. /**
  103756. * Gets the shader compilation time capture status
  103757. */
  103758. /**
  103759. * Enable or disable the shader compilation time capture
  103760. */
  103761. captureShaderCompilationTime: boolean;
  103762. /**
  103763. * Instantiates a new engine instrumentation.
  103764. * This class can be used to get instrumentation data from a Babylon engine
  103765. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103766. * @param engine Defines the engine to instrument
  103767. */
  103768. constructor(
  103769. /**
  103770. * Define the instrumented engine.
  103771. */
  103772. engine: Engine);
  103773. /**
  103774. * Dispose and release associated resources.
  103775. */
  103776. dispose(): void;
  103777. }
  103778. }
  103779. declare module BABYLON {
  103780. /**
  103781. * This class can be used to get instrumentation data from a Babylon engine
  103782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103783. */
  103784. export class SceneInstrumentation implements IDisposable {
  103785. /**
  103786. * Defines the scene to instrument
  103787. */
  103788. scene: Scene;
  103789. private _captureActiveMeshesEvaluationTime;
  103790. private _activeMeshesEvaluationTime;
  103791. private _captureRenderTargetsRenderTime;
  103792. private _renderTargetsRenderTime;
  103793. private _captureFrameTime;
  103794. private _frameTime;
  103795. private _captureRenderTime;
  103796. private _renderTime;
  103797. private _captureInterFrameTime;
  103798. private _interFrameTime;
  103799. private _captureParticlesRenderTime;
  103800. private _particlesRenderTime;
  103801. private _captureSpritesRenderTime;
  103802. private _spritesRenderTime;
  103803. private _capturePhysicsTime;
  103804. private _physicsTime;
  103805. private _captureAnimationsTime;
  103806. private _animationsTime;
  103807. private _captureCameraRenderTime;
  103808. private _cameraRenderTime;
  103809. private _onBeforeActiveMeshesEvaluationObserver;
  103810. private _onAfterActiveMeshesEvaluationObserver;
  103811. private _onBeforeRenderTargetsRenderObserver;
  103812. private _onAfterRenderTargetsRenderObserver;
  103813. private _onAfterRenderObserver;
  103814. private _onBeforeDrawPhaseObserver;
  103815. private _onAfterDrawPhaseObserver;
  103816. private _onBeforeAnimationsObserver;
  103817. private _onBeforeParticlesRenderingObserver;
  103818. private _onAfterParticlesRenderingObserver;
  103819. private _onBeforeSpritesRenderingObserver;
  103820. private _onAfterSpritesRenderingObserver;
  103821. private _onBeforePhysicsObserver;
  103822. private _onAfterPhysicsObserver;
  103823. private _onAfterAnimationsObserver;
  103824. private _onBeforeCameraRenderObserver;
  103825. private _onAfterCameraRenderObserver;
  103826. /**
  103827. * Gets the perf counter used for active meshes evaluation time
  103828. */
  103829. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  103830. /**
  103831. * Gets the active meshes evaluation time capture status
  103832. */
  103833. /**
  103834. * Enable or disable the active meshes evaluation time capture
  103835. */
  103836. captureActiveMeshesEvaluationTime: boolean;
  103837. /**
  103838. * Gets the perf counter used for render targets render time
  103839. */
  103840. readonly renderTargetsRenderTimeCounter: PerfCounter;
  103841. /**
  103842. * Gets the render targets render time capture status
  103843. */
  103844. /**
  103845. * Enable or disable the render targets render time capture
  103846. */
  103847. captureRenderTargetsRenderTime: boolean;
  103848. /**
  103849. * Gets the perf counter used for particles render time
  103850. */
  103851. readonly particlesRenderTimeCounter: PerfCounter;
  103852. /**
  103853. * Gets the particles render time capture status
  103854. */
  103855. /**
  103856. * Enable or disable the particles render time capture
  103857. */
  103858. captureParticlesRenderTime: boolean;
  103859. /**
  103860. * Gets the perf counter used for sprites render time
  103861. */
  103862. readonly spritesRenderTimeCounter: PerfCounter;
  103863. /**
  103864. * Gets the sprites render time capture status
  103865. */
  103866. /**
  103867. * Enable or disable the sprites render time capture
  103868. */
  103869. captureSpritesRenderTime: boolean;
  103870. /**
  103871. * Gets the perf counter used for physics time
  103872. */
  103873. readonly physicsTimeCounter: PerfCounter;
  103874. /**
  103875. * Gets the physics time capture status
  103876. */
  103877. /**
  103878. * Enable or disable the physics time capture
  103879. */
  103880. capturePhysicsTime: boolean;
  103881. /**
  103882. * Gets the perf counter used for animations time
  103883. */
  103884. readonly animationsTimeCounter: PerfCounter;
  103885. /**
  103886. * Gets the animations time capture status
  103887. */
  103888. /**
  103889. * Enable or disable the animations time capture
  103890. */
  103891. captureAnimationsTime: boolean;
  103892. /**
  103893. * Gets the perf counter used for frame time capture
  103894. */
  103895. readonly frameTimeCounter: PerfCounter;
  103896. /**
  103897. * Gets the frame time capture status
  103898. */
  103899. /**
  103900. * Enable or disable the frame time capture
  103901. */
  103902. captureFrameTime: boolean;
  103903. /**
  103904. * Gets the perf counter used for inter-frames time capture
  103905. */
  103906. readonly interFrameTimeCounter: PerfCounter;
  103907. /**
  103908. * Gets the inter-frames time capture status
  103909. */
  103910. /**
  103911. * Enable or disable the inter-frames time capture
  103912. */
  103913. captureInterFrameTime: boolean;
  103914. /**
  103915. * Gets the perf counter used for render time capture
  103916. */
  103917. readonly renderTimeCounter: PerfCounter;
  103918. /**
  103919. * Gets the render time capture status
  103920. */
  103921. /**
  103922. * Enable or disable the render time capture
  103923. */
  103924. captureRenderTime: boolean;
  103925. /**
  103926. * Gets the perf counter used for camera render time capture
  103927. */
  103928. readonly cameraRenderTimeCounter: PerfCounter;
  103929. /**
  103930. * Gets the camera render time capture status
  103931. */
  103932. /**
  103933. * Enable or disable the camera render time capture
  103934. */
  103935. captureCameraRenderTime: boolean;
  103936. /**
  103937. * Gets the perf counter used for draw calls
  103938. */
  103939. readonly drawCallsCounter: PerfCounter;
  103940. /**
  103941. * Gets the perf counter used for texture collisions
  103942. */
  103943. readonly textureCollisionsCounter: PerfCounter;
  103944. /**
  103945. * Instantiates a new scene instrumentation.
  103946. * This class can be used to get instrumentation data from a Babylon engine
  103947. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103948. * @param scene Defines the scene to instrument
  103949. */
  103950. constructor(
  103951. /**
  103952. * Defines the scene to instrument
  103953. */
  103954. scene: Scene);
  103955. /**
  103956. * Dispose and release associated resources.
  103957. */
  103958. dispose(): void;
  103959. }
  103960. }
  103961. declare module BABYLON {
  103962. /** @hidden */
  103963. export var glowMapGenerationPixelShader: {
  103964. name: string;
  103965. shader: string;
  103966. };
  103967. }
  103968. declare module BABYLON {
  103969. /** @hidden */
  103970. export var glowMapGenerationVertexShader: {
  103971. name: string;
  103972. shader: string;
  103973. };
  103974. }
  103975. declare module BABYLON {
  103976. /**
  103977. * Effect layer options. This helps customizing the behaviour
  103978. * of the effect layer.
  103979. */
  103980. export interface IEffectLayerOptions {
  103981. /**
  103982. * Multiplication factor apply to the canvas size to compute the render target size
  103983. * used to generated the objects (the smaller the faster).
  103984. */
  103985. mainTextureRatio: number;
  103986. /**
  103987. * Enforces a fixed size texture to ensure effect stability across devices.
  103988. */
  103989. mainTextureFixedSize?: number;
  103990. /**
  103991. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  103992. */
  103993. alphaBlendingMode: number;
  103994. /**
  103995. * The camera attached to the layer.
  103996. */
  103997. camera: Nullable<Camera>;
  103998. /**
  103999. * The rendering group to draw the layer in.
  104000. */
  104001. renderingGroupId: number;
  104002. }
  104003. /**
  104004. * The effect layer Helps adding post process effect blended with the main pass.
  104005. *
  104006. * This can be for instance use to generate glow or higlight effects on the scene.
  104007. *
  104008. * The effect layer class can not be used directly and is intented to inherited from to be
  104009. * customized per effects.
  104010. */
  104011. export abstract class EffectLayer {
  104012. private _vertexBuffers;
  104013. private _indexBuffer;
  104014. private _cachedDefines;
  104015. private _effectLayerMapGenerationEffect;
  104016. private _effectLayerOptions;
  104017. private _mergeEffect;
  104018. protected _scene: Scene;
  104019. protected _engine: Engine;
  104020. protected _maxSize: number;
  104021. protected _mainTextureDesiredSize: ISize;
  104022. protected _mainTexture: RenderTargetTexture;
  104023. protected _shouldRender: boolean;
  104024. protected _postProcesses: PostProcess[];
  104025. protected _textures: BaseTexture[];
  104026. protected _emissiveTextureAndColor: {
  104027. texture: Nullable<BaseTexture>;
  104028. color: Color4;
  104029. };
  104030. /**
  104031. * The name of the layer
  104032. */
  104033. name: string;
  104034. /**
  104035. * The clear color of the texture used to generate the glow map.
  104036. */
  104037. neutralColor: Color4;
  104038. /**
  104039. * Specifies wether the highlight layer is enabled or not.
  104040. */
  104041. isEnabled: boolean;
  104042. /**
  104043. * Gets the camera attached to the layer.
  104044. */
  104045. readonly camera: Nullable<Camera>;
  104046. /**
  104047. * Gets the rendering group id the layer should render in.
  104048. */
  104049. readonly renderingGroupId: number;
  104050. /**
  104051. * An event triggered when the effect layer has been disposed.
  104052. */
  104053. onDisposeObservable: Observable<EffectLayer>;
  104054. /**
  104055. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  104056. */
  104057. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  104058. /**
  104059. * An event triggered when the generated texture is being merged in the scene.
  104060. */
  104061. onBeforeComposeObservable: Observable<EffectLayer>;
  104062. /**
  104063. * An event triggered when the generated texture has been merged in the scene.
  104064. */
  104065. onAfterComposeObservable: Observable<EffectLayer>;
  104066. /**
  104067. * An event triggered when the efffect layer changes its size.
  104068. */
  104069. onSizeChangedObservable: Observable<EffectLayer>;
  104070. /** @hidden */
  104071. static _SceneComponentInitialization: (scene: Scene) => void;
  104072. /**
  104073. * Instantiates a new effect Layer and references it in the scene.
  104074. * @param name The name of the layer
  104075. * @param scene The scene to use the layer in
  104076. */
  104077. constructor(
  104078. /** The Friendly of the effect in the scene */
  104079. name: string, scene: Scene);
  104080. /**
  104081. * Get the effect name of the layer.
  104082. * @return The effect name
  104083. */
  104084. abstract getEffectName(): string;
  104085. /**
  104086. * Checks for the readiness of the element composing the layer.
  104087. * @param subMesh the mesh to check for
  104088. * @param useInstances specify wether or not to use instances to render the mesh
  104089. * @return true if ready otherwise, false
  104090. */
  104091. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104092. /**
  104093. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104094. * @returns true if the effect requires stencil during the main canvas render pass.
  104095. */
  104096. abstract needStencil(): boolean;
  104097. /**
  104098. * Create the merge effect. This is the shader use to blit the information back
  104099. * to the main canvas at the end of the scene rendering.
  104100. * @returns The effect containing the shader used to merge the effect on the main canvas
  104101. */
  104102. protected abstract _createMergeEffect(): Effect;
  104103. /**
  104104. * Creates the render target textures and post processes used in the effect layer.
  104105. */
  104106. protected abstract _createTextureAndPostProcesses(): void;
  104107. /**
  104108. * Implementation specific of rendering the generating effect on the main canvas.
  104109. * @param effect The effect used to render through
  104110. */
  104111. protected abstract _internalRender(effect: Effect): void;
  104112. /**
  104113. * Sets the required values for both the emissive texture and and the main color.
  104114. */
  104115. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104116. /**
  104117. * Free any resources and references associated to a mesh.
  104118. * Internal use
  104119. * @param mesh The mesh to free.
  104120. */
  104121. abstract _disposeMesh(mesh: Mesh): void;
  104122. /**
  104123. * Serializes this layer (Glow or Highlight for example)
  104124. * @returns a serialized layer object
  104125. */
  104126. abstract serialize?(): any;
  104127. /**
  104128. * Initializes the effect layer with the required options.
  104129. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  104130. */
  104131. protected _init(options: Partial<IEffectLayerOptions>): void;
  104132. /**
  104133. * Generates the index buffer of the full screen quad blending to the main canvas.
  104134. */
  104135. private _generateIndexBuffer;
  104136. /**
  104137. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  104138. */
  104139. private _genrateVertexBuffer;
  104140. /**
  104141. * Sets the main texture desired size which is the closest power of two
  104142. * of the engine canvas size.
  104143. */
  104144. private _setMainTextureSize;
  104145. /**
  104146. * Creates the main texture for the effect layer.
  104147. */
  104148. protected _createMainTexture(): void;
  104149. /**
  104150. * Adds specific effects defines.
  104151. * @param defines The defines to add specifics to.
  104152. */
  104153. protected _addCustomEffectDefines(defines: string[]): void;
  104154. /**
  104155. * Checks for the readiness of the element composing the layer.
  104156. * @param subMesh the mesh to check for
  104157. * @param useInstances specify wether or not to use instances to render the mesh
  104158. * @param emissiveTexture the associated emissive texture used to generate the glow
  104159. * @return true if ready otherwise, false
  104160. */
  104161. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  104162. /**
  104163. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  104164. */
  104165. render(): void;
  104166. /**
  104167. * Determine if a given mesh will be used in the current effect.
  104168. * @param mesh mesh to test
  104169. * @returns true if the mesh will be used
  104170. */
  104171. hasMesh(mesh: AbstractMesh): boolean;
  104172. /**
  104173. * Returns true if the layer contains information to display, otherwise false.
  104174. * @returns true if the glow layer should be rendered
  104175. */
  104176. shouldRender(): boolean;
  104177. /**
  104178. * Returns true if the mesh should render, otherwise false.
  104179. * @param mesh The mesh to render
  104180. * @returns true if it should render otherwise false
  104181. */
  104182. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  104183. /**
  104184. * Returns true if the mesh can be rendered, otherwise false.
  104185. * @param mesh The mesh to render
  104186. * @param material The material used on the mesh
  104187. * @returns true if it can be rendered otherwise false
  104188. */
  104189. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104190. /**
  104191. * Returns true if the mesh should render, otherwise false.
  104192. * @param mesh The mesh to render
  104193. * @returns true if it should render otherwise false
  104194. */
  104195. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  104196. /**
  104197. * Renders the submesh passed in parameter to the generation map.
  104198. */
  104199. protected _renderSubMesh(subMesh: SubMesh): void;
  104200. /**
  104201. * Rebuild the required buffers.
  104202. * @hidden Internal use only.
  104203. */
  104204. _rebuild(): void;
  104205. /**
  104206. * Dispose only the render target textures and post process.
  104207. */
  104208. private _disposeTextureAndPostProcesses;
  104209. /**
  104210. * Dispose the highlight layer and free resources.
  104211. */
  104212. dispose(): void;
  104213. /**
  104214. * Gets the class name of the effect layer
  104215. * @returns the string with the class name of the effect layer
  104216. */
  104217. getClassName(): string;
  104218. /**
  104219. * Creates an effect layer from parsed effect layer data
  104220. * @param parsedEffectLayer defines effect layer data
  104221. * @param scene defines the current scene
  104222. * @param rootUrl defines the root URL containing the effect layer information
  104223. * @returns a parsed effect Layer
  104224. */
  104225. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  104226. }
  104227. }
  104228. declare module BABYLON {
  104229. interface AbstractScene {
  104230. /**
  104231. * The list of effect layers (highlights/glow) added to the scene
  104232. * @see http://doc.babylonjs.com/how_to/highlight_layer
  104233. * @see http://doc.babylonjs.com/how_to/glow_layer
  104234. */
  104235. effectLayers: Array<EffectLayer>;
  104236. /**
  104237. * Removes the given effect layer from this scene.
  104238. * @param toRemove defines the effect layer to remove
  104239. * @returns the index of the removed effect layer
  104240. */
  104241. removeEffectLayer(toRemove: EffectLayer): number;
  104242. /**
  104243. * Adds the given effect layer to this scene
  104244. * @param newEffectLayer defines the effect layer to add
  104245. */
  104246. addEffectLayer(newEffectLayer: EffectLayer): void;
  104247. }
  104248. /**
  104249. * Defines the layer scene component responsible to manage any effect layers
  104250. * in a given scene.
  104251. */
  104252. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104253. /**
  104254. * The component name helpfull to identify the component in the list of scene components.
  104255. */
  104256. readonly name: string;
  104257. /**
  104258. * The scene the component belongs to.
  104259. */
  104260. scene: Scene;
  104261. private _engine;
  104262. private _renderEffects;
  104263. private _needStencil;
  104264. private _previousStencilState;
  104265. /**
  104266. * Creates a new instance of the component for the given scene
  104267. * @param scene Defines the scene to register the component in
  104268. */
  104269. constructor(scene: Scene);
  104270. /**
  104271. * Registers the component in a given scene
  104272. */
  104273. register(): void;
  104274. /**
  104275. * Rebuilds the elements related to this component in case of
  104276. * context lost for instance.
  104277. */
  104278. rebuild(): void;
  104279. /**
  104280. * Serializes the component data to the specified json object
  104281. * @param serializationObject The object to serialize to
  104282. */
  104283. serialize(serializationObject: any): void;
  104284. /**
  104285. * Adds all the element from the container to the scene
  104286. * @param container the container holding the elements
  104287. */
  104288. addFromContainer(container: AbstractScene): void;
  104289. /**
  104290. * Removes all the elements in the container from the scene
  104291. * @param container contains the elements to remove
  104292. */
  104293. removeFromContainer(container: AbstractScene): void;
  104294. /**
  104295. * Disposes the component and the associated ressources.
  104296. */
  104297. dispose(): void;
  104298. private _isReadyForMesh;
  104299. private _renderMainTexture;
  104300. private _setStencil;
  104301. private _setStencilBack;
  104302. private _draw;
  104303. private _drawCamera;
  104304. private _drawRenderingGroup;
  104305. }
  104306. }
  104307. declare module BABYLON {
  104308. /** @hidden */
  104309. export var glowMapMergePixelShader: {
  104310. name: string;
  104311. shader: string;
  104312. };
  104313. }
  104314. declare module BABYLON {
  104315. /** @hidden */
  104316. export var glowMapMergeVertexShader: {
  104317. name: string;
  104318. shader: string;
  104319. };
  104320. }
  104321. declare module BABYLON {
  104322. interface AbstractScene {
  104323. /**
  104324. * Return a the first highlight layer of the scene with a given name.
  104325. * @param name The name of the highlight layer to look for.
  104326. * @return The highlight layer if found otherwise null.
  104327. */
  104328. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104329. }
  104330. /**
  104331. * Glow layer options. This helps customizing the behaviour
  104332. * of the glow layer.
  104333. */
  104334. export interface IGlowLayerOptions {
  104335. /**
  104336. * Multiplication factor apply to the canvas size to compute the render target size
  104337. * used to generated the glowing objects (the smaller the faster).
  104338. */
  104339. mainTextureRatio: number;
  104340. /**
  104341. * Enforces a fixed size texture to ensure resize independant blur.
  104342. */
  104343. mainTextureFixedSize?: number;
  104344. /**
  104345. * How big is the kernel of the blur texture.
  104346. */
  104347. blurKernelSize: number;
  104348. /**
  104349. * The camera attached to the layer.
  104350. */
  104351. camera: Nullable<Camera>;
  104352. /**
  104353. * Enable MSAA by chosing the number of samples.
  104354. */
  104355. mainTextureSamples?: number;
  104356. /**
  104357. * The rendering group to draw the layer in.
  104358. */
  104359. renderingGroupId: number;
  104360. }
  104361. /**
  104362. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104363. *
  104364. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104365. * glowy meshes to your scene.
  104366. *
  104367. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104368. */
  104369. export class GlowLayer extends EffectLayer {
  104370. /**
  104371. * Effect Name of the layer.
  104372. */
  104373. static readonly EffectName: string;
  104374. /**
  104375. * The default blur kernel size used for the glow.
  104376. */
  104377. static DefaultBlurKernelSize: number;
  104378. /**
  104379. * The default texture size ratio used for the glow.
  104380. */
  104381. static DefaultTextureRatio: number;
  104382. /**
  104383. * Sets the kernel size of the blur.
  104384. */
  104385. /**
  104386. * Gets the kernel size of the blur.
  104387. */
  104388. blurKernelSize: number;
  104389. /**
  104390. * Sets the glow intensity.
  104391. */
  104392. /**
  104393. * Gets the glow intensity.
  104394. */
  104395. intensity: number;
  104396. private _options;
  104397. private _intensity;
  104398. private _horizontalBlurPostprocess1;
  104399. private _verticalBlurPostprocess1;
  104400. private _horizontalBlurPostprocess2;
  104401. private _verticalBlurPostprocess2;
  104402. private _blurTexture1;
  104403. private _blurTexture2;
  104404. private _postProcesses1;
  104405. private _postProcesses2;
  104406. private _includedOnlyMeshes;
  104407. private _excludedMeshes;
  104408. /**
  104409. * Callback used to let the user override the color selection on a per mesh basis
  104410. */
  104411. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104412. /**
  104413. * Callback used to let the user override the texture selection on a per mesh basis
  104414. */
  104415. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104416. /**
  104417. * Instantiates a new glow Layer and references it to the scene.
  104418. * @param name The name of the layer
  104419. * @param scene The scene to use the layer in
  104420. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104421. */
  104422. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104423. /**
  104424. * Get the effect name of the layer.
  104425. * @return The effect name
  104426. */
  104427. getEffectName(): string;
  104428. /**
  104429. * Create the merge effect. This is the shader use to blit the information back
  104430. * to the main canvas at the end of the scene rendering.
  104431. */
  104432. protected _createMergeEffect(): Effect;
  104433. /**
  104434. * Creates the render target textures and post processes used in the glow layer.
  104435. */
  104436. protected _createTextureAndPostProcesses(): void;
  104437. /**
  104438. * Checks for the readiness of the element composing the layer.
  104439. * @param subMesh the mesh to check for
  104440. * @param useInstances specify wether or not to use instances to render the mesh
  104441. * @param emissiveTexture the associated emissive texture used to generate the glow
  104442. * @return true if ready otherwise, false
  104443. */
  104444. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104445. /**
  104446. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104447. */
  104448. needStencil(): boolean;
  104449. /**
  104450. * Returns true if the mesh can be rendered, otherwise false.
  104451. * @param mesh The mesh to render
  104452. * @param material The material used on the mesh
  104453. * @returns true if it can be rendered otherwise false
  104454. */
  104455. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104456. /**
  104457. * Implementation specific of rendering the generating effect on the main canvas.
  104458. * @param effect The effect used to render through
  104459. */
  104460. protected _internalRender(effect: Effect): void;
  104461. /**
  104462. * Sets the required values for both the emissive texture and and the main color.
  104463. */
  104464. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104465. /**
  104466. * Returns true if the mesh should render, otherwise false.
  104467. * @param mesh The mesh to render
  104468. * @returns true if it should render otherwise false
  104469. */
  104470. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104471. /**
  104472. * Adds specific effects defines.
  104473. * @param defines The defines to add specifics to.
  104474. */
  104475. protected _addCustomEffectDefines(defines: string[]): void;
  104476. /**
  104477. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104478. * @param mesh The mesh to exclude from the glow layer
  104479. */
  104480. addExcludedMesh(mesh: Mesh): void;
  104481. /**
  104482. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104483. * @param mesh The mesh to remove
  104484. */
  104485. removeExcludedMesh(mesh: Mesh): void;
  104486. /**
  104487. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104488. * @param mesh The mesh to include in the glow layer
  104489. */
  104490. addIncludedOnlyMesh(mesh: Mesh): void;
  104491. /**
  104492. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104493. * @param mesh The mesh to remove
  104494. */
  104495. removeIncludedOnlyMesh(mesh: Mesh): void;
  104496. /**
  104497. * Determine if a given mesh will be used in the glow layer
  104498. * @param mesh The mesh to test
  104499. * @returns true if the mesh will be highlighted by the current glow layer
  104500. */
  104501. hasMesh(mesh: AbstractMesh): boolean;
  104502. /**
  104503. * Free any resources and references associated to a mesh.
  104504. * Internal use
  104505. * @param mesh The mesh to free.
  104506. * @hidden
  104507. */
  104508. _disposeMesh(mesh: Mesh): void;
  104509. /**
  104510. * Gets the class name of the effect layer
  104511. * @returns the string with the class name of the effect layer
  104512. */
  104513. getClassName(): string;
  104514. /**
  104515. * Serializes this glow layer
  104516. * @returns a serialized glow layer object
  104517. */
  104518. serialize(): any;
  104519. /**
  104520. * Creates a Glow Layer from parsed glow layer data
  104521. * @param parsedGlowLayer defines glow layer data
  104522. * @param scene defines the current scene
  104523. * @param rootUrl defines the root URL containing the glow layer information
  104524. * @returns a parsed Glow Layer
  104525. */
  104526. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104527. }
  104528. }
  104529. declare module BABYLON {
  104530. /** @hidden */
  104531. export var glowBlurPostProcessPixelShader: {
  104532. name: string;
  104533. shader: string;
  104534. };
  104535. }
  104536. declare module BABYLON {
  104537. interface AbstractScene {
  104538. /**
  104539. * Return a the first highlight layer of the scene with a given name.
  104540. * @param name The name of the highlight layer to look for.
  104541. * @return The highlight layer if found otherwise null.
  104542. */
  104543. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104544. }
  104545. /**
  104546. * Highlight layer options. This helps customizing the behaviour
  104547. * of the highlight layer.
  104548. */
  104549. export interface IHighlightLayerOptions {
  104550. /**
  104551. * Multiplication factor apply to the canvas size to compute the render target size
  104552. * used to generated the glowing objects (the smaller the faster).
  104553. */
  104554. mainTextureRatio: number;
  104555. /**
  104556. * Enforces a fixed size texture to ensure resize independant blur.
  104557. */
  104558. mainTextureFixedSize?: number;
  104559. /**
  104560. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104561. * of the picture to blur (the smaller the faster).
  104562. */
  104563. blurTextureSizeRatio: number;
  104564. /**
  104565. * How big in texel of the blur texture is the vertical blur.
  104566. */
  104567. blurVerticalSize: number;
  104568. /**
  104569. * How big in texel of the blur texture is the horizontal blur.
  104570. */
  104571. blurHorizontalSize: number;
  104572. /**
  104573. * Alpha blending mode used to apply the blur. Default is combine.
  104574. */
  104575. alphaBlendingMode: number;
  104576. /**
  104577. * The camera attached to the layer.
  104578. */
  104579. camera: Nullable<Camera>;
  104580. /**
  104581. * Should we display highlight as a solid stroke?
  104582. */
  104583. isStroke?: boolean;
  104584. /**
  104585. * The rendering group to draw the layer in.
  104586. */
  104587. renderingGroupId: number;
  104588. }
  104589. /**
  104590. * The highlight layer Helps adding a glow effect around a mesh.
  104591. *
  104592. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104593. * glowy meshes to your scene.
  104594. *
  104595. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104596. */
  104597. export class HighlightLayer extends EffectLayer {
  104598. name: string;
  104599. /**
  104600. * Effect Name of the highlight layer.
  104601. */
  104602. static readonly EffectName: string;
  104603. /**
  104604. * The neutral color used during the preparation of the glow effect.
  104605. * This is black by default as the blend operation is a blend operation.
  104606. */
  104607. static NeutralColor: Color4;
  104608. /**
  104609. * Stencil value used for glowing meshes.
  104610. */
  104611. static GlowingMeshStencilReference: number;
  104612. /**
  104613. * Stencil value used for the other meshes in the scene.
  104614. */
  104615. static NormalMeshStencilReference: number;
  104616. /**
  104617. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104618. */
  104619. innerGlow: boolean;
  104620. /**
  104621. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104622. */
  104623. outerGlow: boolean;
  104624. /**
  104625. * Specifies the horizontal size of the blur.
  104626. */
  104627. /**
  104628. * Gets the horizontal size of the blur.
  104629. */
  104630. blurHorizontalSize: number;
  104631. /**
  104632. * Specifies the vertical size of the blur.
  104633. */
  104634. /**
  104635. * Gets the vertical size of the blur.
  104636. */
  104637. blurVerticalSize: number;
  104638. /**
  104639. * An event triggered when the highlight layer is being blurred.
  104640. */
  104641. onBeforeBlurObservable: Observable<HighlightLayer>;
  104642. /**
  104643. * An event triggered when the highlight layer has been blurred.
  104644. */
  104645. onAfterBlurObservable: Observable<HighlightLayer>;
  104646. private _instanceGlowingMeshStencilReference;
  104647. private _options;
  104648. private _downSamplePostprocess;
  104649. private _horizontalBlurPostprocess;
  104650. private _verticalBlurPostprocess;
  104651. private _blurTexture;
  104652. private _meshes;
  104653. private _excludedMeshes;
  104654. /**
  104655. * Instantiates a new highlight Layer and references it to the scene..
  104656. * @param name The name of the layer
  104657. * @param scene The scene to use the layer in
  104658. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104659. */
  104660. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104661. /**
  104662. * Get the effect name of the layer.
  104663. * @return The effect name
  104664. */
  104665. getEffectName(): string;
  104666. /**
  104667. * Create the merge effect. This is the shader use to blit the information back
  104668. * to the main canvas at the end of the scene rendering.
  104669. */
  104670. protected _createMergeEffect(): Effect;
  104671. /**
  104672. * Creates the render target textures and post processes used in the highlight layer.
  104673. */
  104674. protected _createTextureAndPostProcesses(): void;
  104675. /**
  104676. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104677. */
  104678. needStencil(): boolean;
  104679. /**
  104680. * Checks for the readiness of the element composing the layer.
  104681. * @param subMesh the mesh to check for
  104682. * @param useInstances specify wether or not to use instances to render the mesh
  104683. * @param emissiveTexture the associated emissive texture used to generate the glow
  104684. * @return true if ready otherwise, false
  104685. */
  104686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104687. /**
  104688. * Implementation specific of rendering the generating effect on the main canvas.
  104689. * @param effect The effect used to render through
  104690. */
  104691. protected _internalRender(effect: Effect): void;
  104692. /**
  104693. * Returns true if the layer contains information to display, otherwise false.
  104694. */
  104695. shouldRender(): boolean;
  104696. /**
  104697. * Returns true if the mesh should render, otherwise false.
  104698. * @param mesh The mesh to render
  104699. * @returns true if it should render otherwise false
  104700. */
  104701. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104702. /**
  104703. * Sets the required values for both the emissive texture and and the main color.
  104704. */
  104705. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104706. /**
  104707. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104708. * @param mesh The mesh to exclude from the highlight layer
  104709. */
  104710. addExcludedMesh(mesh: Mesh): void;
  104711. /**
  104712. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104713. * @param mesh The mesh to highlight
  104714. */
  104715. removeExcludedMesh(mesh: Mesh): void;
  104716. /**
  104717. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104718. * @param mesh mesh to test
  104719. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104720. */
  104721. hasMesh(mesh: AbstractMesh): boolean;
  104722. /**
  104723. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104724. * @param mesh The mesh to highlight
  104725. * @param color The color of the highlight
  104726. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104727. */
  104728. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104729. /**
  104730. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104731. * @param mesh The mesh to highlight
  104732. */
  104733. removeMesh(mesh: Mesh): void;
  104734. /**
  104735. * Force the stencil to the normal expected value for none glowing parts
  104736. */
  104737. private _defaultStencilReference;
  104738. /**
  104739. * Free any resources and references associated to a mesh.
  104740. * Internal use
  104741. * @param mesh The mesh to free.
  104742. * @hidden
  104743. */
  104744. _disposeMesh(mesh: Mesh): void;
  104745. /**
  104746. * Dispose the highlight layer and free resources.
  104747. */
  104748. dispose(): void;
  104749. /**
  104750. * Gets the class name of the effect layer
  104751. * @returns the string with the class name of the effect layer
  104752. */
  104753. getClassName(): string;
  104754. /**
  104755. * Serializes this Highlight layer
  104756. * @returns a serialized Highlight layer object
  104757. */
  104758. serialize(): any;
  104759. /**
  104760. * Creates a Highlight layer from parsed Highlight layer data
  104761. * @param parsedHightlightLayer defines the Highlight layer data
  104762. * @param scene defines the current scene
  104763. * @param rootUrl defines the root URL containing the Highlight layer information
  104764. * @returns a parsed Highlight layer
  104765. */
  104766. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  104767. }
  104768. }
  104769. declare module BABYLON {
  104770. /** @hidden */
  104771. export var lensFlarePixelShader: {
  104772. name: string;
  104773. shader: string;
  104774. };
  104775. }
  104776. declare module BABYLON {
  104777. /** @hidden */
  104778. export var lensFlareVertexShader: {
  104779. name: string;
  104780. shader: string;
  104781. };
  104782. }
  104783. declare module BABYLON {
  104784. /**
  104785. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104786. * It is usually composed of several `lensFlare`.
  104787. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104788. */
  104789. export class LensFlareSystem {
  104790. /**
  104791. * Define the name of the lens flare system
  104792. */
  104793. name: string;
  104794. /**
  104795. * List of lens flares used in this system.
  104796. */
  104797. lensFlares: LensFlare[];
  104798. /**
  104799. * Define a limit from the border the lens flare can be visible.
  104800. */
  104801. borderLimit: number;
  104802. /**
  104803. * Define a viewport border we do not want to see the lens flare in.
  104804. */
  104805. viewportBorder: number;
  104806. /**
  104807. * Define a predicate which could limit the list of meshes able to occlude the effect.
  104808. */
  104809. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104810. /**
  104811. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  104812. */
  104813. layerMask: number;
  104814. /**
  104815. * Define the id of the lens flare system in the scene.
  104816. * (equal to name by default)
  104817. */
  104818. id: string;
  104819. private _scene;
  104820. private _emitter;
  104821. private _vertexBuffers;
  104822. private _indexBuffer;
  104823. private _effect;
  104824. private _positionX;
  104825. private _positionY;
  104826. private _isEnabled;
  104827. /** @hidden */
  104828. static _SceneComponentInitialization: (scene: Scene) => void;
  104829. /**
  104830. * Instantiates a lens flare system.
  104831. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104832. * It is usually composed of several `lensFlare`.
  104833. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104834. * @param name Define the name of the lens flare system in the scene
  104835. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  104836. * @param scene Define the scene the lens flare system belongs to
  104837. */
  104838. constructor(
  104839. /**
  104840. * Define the name of the lens flare system
  104841. */
  104842. name: string, emitter: any, scene: Scene);
  104843. /**
  104844. * Define if the lens flare system is enabled.
  104845. */
  104846. isEnabled: boolean;
  104847. /**
  104848. * Get the scene the effects belongs to.
  104849. * @returns the scene holding the lens flare system
  104850. */
  104851. getScene(): Scene;
  104852. /**
  104853. * Get the emitter of the lens flare system.
  104854. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104855. * @returns the emitter of the lens flare system
  104856. */
  104857. getEmitter(): any;
  104858. /**
  104859. * Set the emitter of the lens flare system.
  104860. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104861. * @param newEmitter Define the new emitter of the system
  104862. */
  104863. setEmitter(newEmitter: any): void;
  104864. /**
  104865. * Get the lens flare system emitter position.
  104866. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  104867. * @returns the position
  104868. */
  104869. getEmitterPosition(): Vector3;
  104870. /**
  104871. * @hidden
  104872. */
  104873. computeEffectivePosition(globalViewport: Viewport): boolean;
  104874. /** @hidden */
  104875. _isVisible(): boolean;
  104876. /**
  104877. * @hidden
  104878. */
  104879. render(): boolean;
  104880. /**
  104881. * Dispose and release the lens flare with its associated resources.
  104882. */
  104883. dispose(): void;
  104884. /**
  104885. * Parse a lens flare system from a JSON repressentation
  104886. * @param parsedLensFlareSystem Define the JSON to parse
  104887. * @param scene Define the scene the parsed system should be instantiated in
  104888. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  104889. * @returns the parsed system
  104890. */
  104891. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  104892. /**
  104893. * Serialize the current Lens Flare System into a JSON representation.
  104894. * @returns the serialized JSON
  104895. */
  104896. serialize(): any;
  104897. }
  104898. }
  104899. declare module BABYLON {
  104900. /**
  104901. * This represents one of the lens effect in a `lensFlareSystem`.
  104902. * It controls one of the indiviual texture used in the effect.
  104903. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104904. */
  104905. export class LensFlare {
  104906. /**
  104907. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104908. */
  104909. size: number;
  104910. /**
  104911. * 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.
  104912. */
  104913. position: number;
  104914. /**
  104915. * Define the lens color.
  104916. */
  104917. color: Color3;
  104918. /**
  104919. * Define the lens texture.
  104920. */
  104921. texture: Nullable<Texture>;
  104922. /**
  104923. * Define the alpha mode to render this particular lens.
  104924. */
  104925. alphaMode: number;
  104926. private _system;
  104927. /**
  104928. * Creates a new Lens Flare.
  104929. * This represents one of the lens effect in a `lensFlareSystem`.
  104930. * It controls one of the indiviual texture used in the effect.
  104931. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104932. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  104933. * @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.
  104934. * @param color Define the lens color
  104935. * @param imgUrl Define the lens texture url
  104936. * @param system Define the `lensFlareSystem` this flare is part of
  104937. * @returns The newly created Lens Flare
  104938. */
  104939. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  104940. /**
  104941. * Instantiates a new Lens Flare.
  104942. * This represents one of the lens effect in a `lensFlareSystem`.
  104943. * It controls one of the indiviual texture used in the effect.
  104944. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104945. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  104946. * @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.
  104947. * @param color Define the lens color
  104948. * @param imgUrl Define the lens texture url
  104949. * @param system Define the `lensFlareSystem` this flare is part of
  104950. */
  104951. constructor(
  104952. /**
  104953. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104954. */
  104955. size: number,
  104956. /**
  104957. * 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.
  104958. */
  104959. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  104960. /**
  104961. * Dispose and release the lens flare with its associated resources.
  104962. */
  104963. dispose(): void;
  104964. }
  104965. }
  104966. declare module BABYLON {
  104967. interface AbstractScene {
  104968. /**
  104969. * The list of lens flare system added to the scene
  104970. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104971. */
  104972. lensFlareSystems: Array<LensFlareSystem>;
  104973. /**
  104974. * Removes the given lens flare system from this scene.
  104975. * @param toRemove The lens flare system to remove
  104976. * @returns The index of the removed lens flare system
  104977. */
  104978. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  104979. /**
  104980. * Adds the given lens flare system to this scene
  104981. * @param newLensFlareSystem The lens flare system to add
  104982. */
  104983. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  104984. /**
  104985. * Gets a lens flare system using its name
  104986. * @param name defines the name to look for
  104987. * @returns the lens flare system or null if not found
  104988. */
  104989. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  104990. /**
  104991. * Gets a lens flare system using its id
  104992. * @param id defines the id to look for
  104993. * @returns the lens flare system or null if not found
  104994. */
  104995. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104996. }
  104997. /**
  104998. * Defines the lens flare scene component responsible to manage any lens flares
  104999. * in a given scene.
  105000. */
  105001. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  105002. /**
  105003. * The component name helpfull to identify the component in the list of scene components.
  105004. */
  105005. readonly name: string;
  105006. /**
  105007. * The scene the component belongs to.
  105008. */
  105009. scene: Scene;
  105010. /**
  105011. * Creates a new instance of the component for the given scene
  105012. * @param scene Defines the scene to register the component in
  105013. */
  105014. constructor(scene: Scene);
  105015. /**
  105016. * Registers the component in a given scene
  105017. */
  105018. register(): void;
  105019. /**
  105020. * Rebuilds the elements related to this component in case of
  105021. * context lost for instance.
  105022. */
  105023. rebuild(): void;
  105024. /**
  105025. * Adds all the element from the container to the scene
  105026. * @param container the container holding the elements
  105027. */
  105028. addFromContainer(container: AbstractScene): void;
  105029. /**
  105030. * Removes all the elements in the container from the scene
  105031. * @param container contains the elements to remove
  105032. */
  105033. removeFromContainer(container: AbstractScene): void;
  105034. /**
  105035. * Serializes the component data to the specified json object
  105036. * @param serializationObject The object to serialize to
  105037. */
  105038. serialize(serializationObject: any): void;
  105039. /**
  105040. * Disposes the component and the associated ressources.
  105041. */
  105042. dispose(): void;
  105043. private _draw;
  105044. }
  105045. }
  105046. declare module BABYLON {
  105047. /**
  105048. * Defines the shadow generator component responsible to manage any shadow generators
  105049. * in a given scene.
  105050. */
  105051. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  105052. /**
  105053. * The component name helpfull to identify the component in the list of scene components.
  105054. */
  105055. readonly name: string;
  105056. /**
  105057. * The scene the component belongs to.
  105058. */
  105059. scene: Scene;
  105060. /**
  105061. * Creates a new instance of the component for the given scene
  105062. * @param scene Defines the scene to register the component in
  105063. */
  105064. constructor(scene: Scene);
  105065. /**
  105066. * Registers the component in a given scene
  105067. */
  105068. register(): void;
  105069. /**
  105070. * Rebuilds the elements related to this component in case of
  105071. * context lost for instance.
  105072. */
  105073. rebuild(): void;
  105074. /**
  105075. * Serializes the component data to the specified json object
  105076. * @param serializationObject The object to serialize to
  105077. */
  105078. serialize(serializationObject: any): void;
  105079. /**
  105080. * Adds all the element from the container to the scene
  105081. * @param container the container holding the elements
  105082. */
  105083. addFromContainer(container: AbstractScene): void;
  105084. /**
  105085. * Removes all the elements in the container from the scene
  105086. * @param container contains the elements to remove
  105087. */
  105088. removeFromContainer(container: AbstractScene): void;
  105089. /**
  105090. * Rebuilds the elements related to this component in case of
  105091. * context lost for instance.
  105092. */
  105093. dispose(): void;
  105094. private _gatherRenderTargets;
  105095. }
  105096. }
  105097. declare module BABYLON {
  105098. /**
  105099. * A directional light is defined by a direction (what a surprise!).
  105100. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105101. * 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.
  105102. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105103. */
  105104. export class DirectionalLight extends ShadowLight {
  105105. private _shadowFrustumSize;
  105106. /**
  105107. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105108. */
  105109. /**
  105110. * Specifies a fix frustum size for the shadow generation.
  105111. */
  105112. shadowFrustumSize: number;
  105113. private _shadowOrthoScale;
  105114. /**
  105115. * Gets the shadow projection scale against the optimal computed one.
  105116. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105117. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105118. */
  105119. /**
  105120. * Sets the shadow projection scale against the optimal computed one.
  105121. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105122. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105123. */
  105124. shadowOrthoScale: number;
  105125. /**
  105126. * Automatically compute the projection matrix to best fit (including all the casters)
  105127. * on each frame.
  105128. */
  105129. autoUpdateExtends: boolean;
  105130. private _orthoLeft;
  105131. private _orthoRight;
  105132. private _orthoTop;
  105133. private _orthoBottom;
  105134. /**
  105135. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105136. * The directional light is emitted from everywhere in the given direction.
  105137. * It can cast shadows.
  105138. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105139. * @param name The friendly name of the light
  105140. * @param direction The direction of the light
  105141. * @param scene The scene the light belongs to
  105142. */
  105143. constructor(name: string, direction: Vector3, scene: Scene);
  105144. /**
  105145. * Returns the string "DirectionalLight".
  105146. * @return The class name
  105147. */
  105148. getClassName(): string;
  105149. /**
  105150. * Returns the integer 1.
  105151. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105152. */
  105153. getTypeID(): number;
  105154. /**
  105155. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105156. * Returns the DirectionalLight Shadow projection matrix.
  105157. */
  105158. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105159. /**
  105160. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105161. * Returns the DirectionalLight Shadow projection matrix.
  105162. */
  105163. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105164. /**
  105165. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105166. * Returns the DirectionalLight Shadow projection matrix.
  105167. */
  105168. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105169. protected _buildUniformLayout(): void;
  105170. /**
  105171. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105172. * @param effect The effect to update
  105173. * @param lightIndex The index of the light in the effect to update
  105174. * @returns The directional light
  105175. */
  105176. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105177. /**
  105178. * Gets the minZ used for shadow according to both the scene and the light.
  105179. *
  105180. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105181. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105182. * @param activeCamera The camera we are returning the min for
  105183. * @returns the depth min z
  105184. */
  105185. getDepthMinZ(activeCamera: Camera): number;
  105186. /**
  105187. * Gets the maxZ used for shadow according to both the scene and the light.
  105188. *
  105189. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105190. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105191. * @param activeCamera The camera we are returning the max for
  105192. * @returns the depth max z
  105193. */
  105194. getDepthMaxZ(activeCamera: Camera): number;
  105195. /**
  105196. * Prepares the list of defines specific to the light type.
  105197. * @param defines the list of defines
  105198. * @param lightIndex defines the index of the light for the effect
  105199. */
  105200. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105201. }
  105202. }
  105203. declare module BABYLON {
  105204. /**
  105205. * A point light is a light defined by an unique point in world space.
  105206. * The light is emitted in every direction from this point.
  105207. * A good example of a point light is a standard light bulb.
  105208. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105209. */
  105210. export class PointLight extends ShadowLight {
  105211. private _shadowAngle;
  105212. /**
  105213. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105214. * This specifies what angle the shadow will use to be created.
  105215. *
  105216. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105217. */
  105218. /**
  105219. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105220. * This specifies what angle the shadow will use to be created.
  105221. *
  105222. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105223. */
  105224. shadowAngle: number;
  105225. /**
  105226. * Gets the direction if it has been set.
  105227. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105228. */
  105229. /**
  105230. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105231. */
  105232. direction: Vector3;
  105233. /**
  105234. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  105235. * A PointLight emits the light in every direction.
  105236. * It can cast shadows.
  105237. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  105238. * ```javascript
  105239. * var pointLight = new PointLight("pl", camera.position, scene);
  105240. * ```
  105241. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105242. * @param name The light friendly name
  105243. * @param position The position of the point light in the scene
  105244. * @param scene The scene the lights belongs to
  105245. */
  105246. constructor(name: string, position: Vector3, scene: Scene);
  105247. /**
  105248. * Returns the string "PointLight"
  105249. * @returns the class name
  105250. */
  105251. getClassName(): string;
  105252. /**
  105253. * Returns the integer 0.
  105254. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105255. */
  105256. getTypeID(): number;
  105257. /**
  105258. * Specifies wether or not the shadowmap should be a cube texture.
  105259. * @returns true if the shadowmap needs to be a cube texture.
  105260. */
  105261. needCube(): boolean;
  105262. /**
  105263. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105264. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105265. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105266. */
  105267. getShadowDirection(faceIndex?: number): Vector3;
  105268. /**
  105269. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105270. * - fov = PI / 2
  105271. * - aspect ratio : 1.0
  105272. * - z-near and far equal to the active camera minZ and maxZ.
  105273. * Returns the PointLight.
  105274. */
  105275. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105276. protected _buildUniformLayout(): void;
  105277. /**
  105278. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105279. * @param effect The effect to update
  105280. * @param lightIndex The index of the light in the effect to update
  105281. * @returns The point light
  105282. */
  105283. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105284. /**
  105285. * Prepares the list of defines specific to the light type.
  105286. * @param defines the list of defines
  105287. * @param lightIndex defines the index of the light for the effect
  105288. */
  105289. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105290. }
  105291. }
  105292. declare module BABYLON {
  105293. /**
  105294. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105295. * These values define a cone of light starting from the position, emitting toward the direction.
  105296. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105297. * and the exponent defines the speed of the decay of the light with distance (reach).
  105298. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105299. */
  105300. export class SpotLight extends ShadowLight {
  105301. private _angle;
  105302. private _innerAngle;
  105303. private _cosHalfAngle;
  105304. private _lightAngleScale;
  105305. private _lightAngleOffset;
  105306. /**
  105307. * Gets the cone angle of the spot light in Radians.
  105308. */
  105309. /**
  105310. * Sets the cone angle of the spot light in Radians.
  105311. */
  105312. angle: number;
  105313. /**
  105314. * Only used in gltf falloff mode, this defines the angle where
  105315. * the directional falloff will start before cutting at angle which could be seen
  105316. * as outer angle.
  105317. */
  105318. /**
  105319. * Only used in gltf falloff mode, this defines the angle where
  105320. * the directional falloff will start before cutting at angle which could be seen
  105321. * as outer angle.
  105322. */
  105323. innerAngle: number;
  105324. private _shadowAngleScale;
  105325. /**
  105326. * Allows scaling the angle of the light for shadow generation only.
  105327. */
  105328. /**
  105329. * Allows scaling the angle of the light for shadow generation only.
  105330. */
  105331. shadowAngleScale: number;
  105332. /**
  105333. * The light decay speed with the distance from the emission spot.
  105334. */
  105335. exponent: number;
  105336. private _projectionTextureMatrix;
  105337. /**
  105338. * Allows reading the projecton texture
  105339. */
  105340. readonly projectionTextureMatrix: Matrix;
  105341. protected _projectionTextureLightNear: number;
  105342. /**
  105343. * Gets the near clip of the Spotlight for texture projection.
  105344. */
  105345. /**
  105346. * Sets the near clip of the Spotlight for texture projection.
  105347. */
  105348. projectionTextureLightNear: number;
  105349. protected _projectionTextureLightFar: number;
  105350. /**
  105351. * Gets the far clip of the Spotlight for texture projection.
  105352. */
  105353. /**
  105354. * Sets the far clip of the Spotlight for texture projection.
  105355. */
  105356. projectionTextureLightFar: number;
  105357. protected _projectionTextureUpDirection: Vector3;
  105358. /**
  105359. * Gets the Up vector of the Spotlight for texture projection.
  105360. */
  105361. /**
  105362. * Sets the Up vector of the Spotlight for texture projection.
  105363. */
  105364. projectionTextureUpDirection: Vector3;
  105365. private _projectionTexture;
  105366. /**
  105367. * Gets the projection texture of the light.
  105368. */
  105369. /**
  105370. * Sets the projection texture of the light.
  105371. */
  105372. projectionTexture: Nullable<BaseTexture>;
  105373. private _projectionTextureViewLightDirty;
  105374. private _projectionTextureProjectionLightDirty;
  105375. private _projectionTextureDirty;
  105376. private _projectionTextureViewTargetVector;
  105377. private _projectionTextureViewLightMatrix;
  105378. private _projectionTextureProjectionLightMatrix;
  105379. private _projectionTextureScalingMatrix;
  105380. /**
  105381. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105382. * It can cast shadows.
  105383. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105384. * @param name The light friendly name
  105385. * @param position The position of the spot light in the scene
  105386. * @param direction The direction of the light in the scene
  105387. * @param angle The cone angle of the light in Radians
  105388. * @param exponent The light decay speed with the distance from the emission spot
  105389. * @param scene The scene the lights belongs to
  105390. */
  105391. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105392. /**
  105393. * Returns the string "SpotLight".
  105394. * @returns the class name
  105395. */
  105396. getClassName(): string;
  105397. /**
  105398. * Returns the integer 2.
  105399. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105400. */
  105401. getTypeID(): number;
  105402. /**
  105403. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105404. */
  105405. protected _setDirection(value: Vector3): void;
  105406. /**
  105407. * Overrides the position setter to recompute the projection texture view light Matrix.
  105408. */
  105409. protected _setPosition(value: Vector3): void;
  105410. /**
  105411. * 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.
  105412. * Returns the SpotLight.
  105413. */
  105414. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105415. protected _computeProjectionTextureViewLightMatrix(): void;
  105416. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105417. /**
  105418. * Main function for light texture projection matrix computing.
  105419. */
  105420. protected _computeProjectionTextureMatrix(): void;
  105421. protected _buildUniformLayout(): void;
  105422. private _computeAngleValues;
  105423. /**
  105424. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105425. * @param effect The effect to update
  105426. * @param lightIndex The index of the light in the effect to update
  105427. * @returns The spot light
  105428. */
  105429. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105430. /**
  105431. * Disposes the light and the associated resources.
  105432. */
  105433. dispose(): void;
  105434. /**
  105435. * Prepares the list of defines specific to the light type.
  105436. * @param defines the list of defines
  105437. * @param lightIndex defines the index of the light for the effect
  105438. */
  105439. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105440. }
  105441. }
  105442. declare module BABYLON {
  105443. /**
  105444. * Header information of HDR texture files.
  105445. */
  105446. export interface HDRInfo {
  105447. /**
  105448. * The height of the texture in pixels.
  105449. */
  105450. height: number;
  105451. /**
  105452. * The width of the texture in pixels.
  105453. */
  105454. width: number;
  105455. /**
  105456. * The index of the beginning of the data in the binary file.
  105457. */
  105458. dataPosition: number;
  105459. }
  105460. /**
  105461. * This groups tools to convert HDR texture to native colors array.
  105462. */
  105463. export class HDRTools {
  105464. private static Ldexp;
  105465. private static Rgbe2float;
  105466. private static readStringLine;
  105467. /**
  105468. * Reads header information from an RGBE texture stored in a native array.
  105469. * More information on this format are available here:
  105470. * https://en.wikipedia.org/wiki/RGBE_image_format
  105471. *
  105472. * @param uint8array The binary file stored in native array.
  105473. * @return The header information.
  105474. */
  105475. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105476. /**
  105477. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105478. * This RGBE texture needs to store the information as a panorama.
  105479. *
  105480. * More information on this format are available here:
  105481. * https://en.wikipedia.org/wiki/RGBE_image_format
  105482. *
  105483. * @param buffer The binary file stored in an array buffer.
  105484. * @param size The expected size of the extracted cubemap.
  105485. * @return The Cube Map information.
  105486. */
  105487. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105488. /**
  105489. * Returns the pixels data extracted from an RGBE texture.
  105490. * This pixels will be stored left to right up to down in the R G B order in one array.
  105491. *
  105492. * More information on this format are available here:
  105493. * https://en.wikipedia.org/wiki/RGBE_image_format
  105494. *
  105495. * @param uint8array The binary file stored in an array buffer.
  105496. * @param hdrInfo The header information of the file.
  105497. * @return The pixels data in RGB right to left up to down order.
  105498. */
  105499. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105500. private static RGBE_ReadPixels_RLE;
  105501. }
  105502. }
  105503. declare module BABYLON {
  105504. /**
  105505. * This represents a texture coming from an HDR input.
  105506. *
  105507. * The only supported format is currently panorama picture stored in RGBE format.
  105508. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105509. */
  105510. export class HDRCubeTexture extends BaseTexture {
  105511. private static _facesMapping;
  105512. private _generateHarmonics;
  105513. private _noMipmap;
  105514. private _textureMatrix;
  105515. private _size;
  105516. private _onLoad;
  105517. private _onError;
  105518. /**
  105519. * The texture URL.
  105520. */
  105521. url: string;
  105522. /**
  105523. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105524. */
  105525. coordinatesMode: number;
  105526. protected _isBlocking: boolean;
  105527. /**
  105528. * Sets wether or not the texture is blocking during loading.
  105529. */
  105530. /**
  105531. * Gets wether or not the texture is blocking during loading.
  105532. */
  105533. isBlocking: boolean;
  105534. protected _rotationY: number;
  105535. /**
  105536. * Sets texture matrix rotation angle around Y axis in radians.
  105537. */
  105538. /**
  105539. * Gets texture matrix rotation angle around Y axis radians.
  105540. */
  105541. rotationY: number;
  105542. /**
  105543. * Gets or sets the center of the bounding box associated with the cube texture
  105544. * It must define where the camera used to render the texture was set
  105545. */
  105546. boundingBoxPosition: Vector3;
  105547. private _boundingBoxSize;
  105548. /**
  105549. * Gets or sets the size of the bounding box associated with the cube texture
  105550. * When defined, the cubemap will switch to local mode
  105551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105552. * @example https://www.babylonjs-playground.com/#RNASML
  105553. */
  105554. boundingBoxSize: Vector3;
  105555. /**
  105556. * Instantiates an HDRTexture from the following parameters.
  105557. *
  105558. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105559. * @param scene The scene the texture will be used in
  105560. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105561. * @param noMipmap Forces to not generate the mipmap if true
  105562. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105563. * @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)
  105564. * @param reserved Reserved flag for internal use.
  105565. */
  105566. 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>);
  105567. /**
  105568. * Get the current class name of the texture useful for serialization or dynamic coding.
  105569. * @returns "HDRCubeTexture"
  105570. */
  105571. getClassName(): string;
  105572. /**
  105573. * Occurs when the file is raw .hdr file.
  105574. */
  105575. private loadTexture;
  105576. clone(): HDRCubeTexture;
  105577. delayLoad(): void;
  105578. /**
  105579. * Get the texture reflection matrix used to rotate/transform the reflection.
  105580. * @returns the reflection matrix
  105581. */
  105582. getReflectionTextureMatrix(): Matrix;
  105583. /**
  105584. * Set the texture reflection matrix used to rotate/transform the reflection.
  105585. * @param value Define the reflection matrix to set
  105586. */
  105587. setReflectionTextureMatrix(value: Matrix): void;
  105588. /**
  105589. * Parses a JSON representation of an HDR Texture in order to create the texture
  105590. * @param parsedTexture Define the JSON representation
  105591. * @param scene Define the scene the texture should be created in
  105592. * @param rootUrl Define the root url in case we need to load relative dependencies
  105593. * @returns the newly created texture after parsing
  105594. */
  105595. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105596. serialize(): any;
  105597. }
  105598. }
  105599. declare module BABYLON {
  105600. /**
  105601. * Class used to control physics engine
  105602. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105603. */
  105604. export class PhysicsEngine implements IPhysicsEngine {
  105605. private _physicsPlugin;
  105606. /**
  105607. * Global value used to control the smallest number supported by the simulation
  105608. */
  105609. static Epsilon: number;
  105610. private _impostors;
  105611. private _joints;
  105612. /**
  105613. * Gets the gravity vector used by the simulation
  105614. */
  105615. gravity: Vector3;
  105616. /**
  105617. * Factory used to create the default physics plugin.
  105618. * @returns The default physics plugin
  105619. */
  105620. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105621. /**
  105622. * Creates a new Physics Engine
  105623. * @param gravity defines the gravity vector used by the simulation
  105624. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105625. */
  105626. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105627. /**
  105628. * Sets the gravity vector used by the simulation
  105629. * @param gravity defines the gravity vector to use
  105630. */
  105631. setGravity(gravity: Vector3): void;
  105632. /**
  105633. * Set the time step of the physics engine.
  105634. * Default is 1/60.
  105635. * To slow it down, enter 1/600 for example.
  105636. * To speed it up, 1/30
  105637. * @param newTimeStep defines the new timestep to apply to this world.
  105638. */
  105639. setTimeStep(newTimeStep?: number): void;
  105640. /**
  105641. * Get the time step of the physics engine.
  105642. * @returns the current time step
  105643. */
  105644. getTimeStep(): number;
  105645. /**
  105646. * Release all resources
  105647. */
  105648. dispose(): void;
  105649. /**
  105650. * Gets the name of the current physics plugin
  105651. * @returns the name of the plugin
  105652. */
  105653. getPhysicsPluginName(): string;
  105654. /**
  105655. * Adding a new impostor for the impostor tracking.
  105656. * This will be done by the impostor itself.
  105657. * @param impostor the impostor to add
  105658. */
  105659. addImpostor(impostor: PhysicsImpostor): void;
  105660. /**
  105661. * Remove an impostor from the engine.
  105662. * This impostor and its mesh will not longer be updated by the physics engine.
  105663. * @param impostor the impostor to remove
  105664. */
  105665. removeImpostor(impostor: PhysicsImpostor): void;
  105666. /**
  105667. * Add a joint to the physics engine
  105668. * @param mainImpostor defines the main impostor to which the joint is added.
  105669. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105670. * @param joint defines the joint that will connect both impostors.
  105671. */
  105672. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105673. /**
  105674. * Removes a joint from the simulation
  105675. * @param mainImpostor defines the impostor used with the joint
  105676. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105677. * @param joint defines the joint to remove
  105678. */
  105679. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105680. /**
  105681. * Called by the scene. No need to call it.
  105682. * @param delta defines the timespam between frames
  105683. */
  105684. _step(delta: number): void;
  105685. /**
  105686. * Gets the current plugin used to run the simulation
  105687. * @returns current plugin
  105688. */
  105689. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105690. /**
  105691. * Gets the list of physic impostors
  105692. * @returns an array of PhysicsImpostor
  105693. */
  105694. getImpostors(): Array<PhysicsImpostor>;
  105695. /**
  105696. * Gets the impostor for a physics enabled object
  105697. * @param object defines the object impersonated by the impostor
  105698. * @returns the PhysicsImpostor or null if not found
  105699. */
  105700. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105701. /**
  105702. * Gets the impostor for a physics body object
  105703. * @param body defines physics body used by the impostor
  105704. * @returns the PhysicsImpostor or null if not found
  105705. */
  105706. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105707. /**
  105708. * Does a raycast in the physics world
  105709. * @param from when should the ray start?
  105710. * @param to when should the ray end?
  105711. * @returns PhysicsRaycastResult
  105712. */
  105713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105714. }
  105715. }
  105716. declare module BABYLON {
  105717. /** @hidden */
  105718. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105719. private _useDeltaForWorldStep;
  105720. world: any;
  105721. name: string;
  105722. private _physicsMaterials;
  105723. private _fixedTimeStep;
  105724. private _cannonRaycastResult;
  105725. private _raycastResult;
  105726. BJSCANNON: any;
  105727. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105728. setGravity(gravity: Vector3): void;
  105729. setTimeStep(timeStep: number): void;
  105730. getTimeStep(): number;
  105731. executeStep(delta: number): void;
  105732. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105733. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105734. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105735. private _processChildMeshes;
  105736. removePhysicsBody(impostor: PhysicsImpostor): void;
  105737. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105738. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105739. private _addMaterial;
  105740. private _checkWithEpsilon;
  105741. private _createShape;
  105742. private _createHeightmap;
  105743. private _minus90X;
  105744. private _plus90X;
  105745. private _tmpPosition;
  105746. private _tmpDeltaPosition;
  105747. private _tmpUnityRotation;
  105748. private _updatePhysicsBodyTransformation;
  105749. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105751. isSupported(): boolean;
  105752. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105753. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105754. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105755. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105756. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105757. getBodyMass(impostor: PhysicsImpostor): number;
  105758. getBodyFriction(impostor: PhysicsImpostor): number;
  105759. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105760. getBodyRestitution(impostor: PhysicsImpostor): number;
  105761. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105762. sleepBody(impostor: PhysicsImpostor): void;
  105763. wakeUpBody(impostor: PhysicsImpostor): void;
  105764. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  105765. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105766. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105767. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105768. getRadius(impostor: PhysicsImpostor): number;
  105769. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105770. dispose(): void;
  105771. private _extendNamespace;
  105772. /**
  105773. * Does a raycast in the physics world
  105774. * @param from when should the ray start?
  105775. * @param to when should the ray end?
  105776. * @returns PhysicsRaycastResult
  105777. */
  105778. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105779. }
  105780. }
  105781. declare module BABYLON {
  105782. /** @hidden */
  105783. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  105784. world: any;
  105785. name: string;
  105786. BJSOIMO: any;
  105787. private _raycastResult;
  105788. constructor(iterations?: number, oimoInjection?: any);
  105789. setGravity(gravity: Vector3): void;
  105790. setTimeStep(timeStep: number): void;
  105791. getTimeStep(): number;
  105792. private _tmpImpostorsArray;
  105793. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105794. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105795. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105796. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105797. private _tmpPositionVector;
  105798. removePhysicsBody(impostor: PhysicsImpostor): void;
  105799. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105800. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105801. isSupported(): boolean;
  105802. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105803. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105804. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105805. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105806. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105807. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105808. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105809. getBodyMass(impostor: PhysicsImpostor): number;
  105810. getBodyFriction(impostor: PhysicsImpostor): number;
  105811. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105812. getBodyRestitution(impostor: PhysicsImpostor): number;
  105813. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105814. sleepBody(impostor: PhysicsImpostor): void;
  105815. wakeUpBody(impostor: PhysicsImpostor): void;
  105816. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105817. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  105818. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105819. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105820. getRadius(impostor: PhysicsImpostor): number;
  105821. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105822. dispose(): void;
  105823. /**
  105824. * Does a raycast in the physics world
  105825. * @param from when should the ray start?
  105826. * @param to when should the ray end?
  105827. * @returns PhysicsRaycastResult
  105828. */
  105829. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105830. }
  105831. }
  105832. declare module BABYLON {
  105833. interface AbstractScene {
  105834. /**
  105835. * The list of reflection probes added to the scene
  105836. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105837. */
  105838. reflectionProbes: Array<ReflectionProbe>;
  105839. /**
  105840. * Removes the given reflection probe from this scene.
  105841. * @param toRemove The reflection probe to remove
  105842. * @returns The index of the removed reflection probe
  105843. */
  105844. removeReflectionProbe(toRemove: ReflectionProbe): number;
  105845. /**
  105846. * Adds the given reflection probe to this scene.
  105847. * @param newReflectionProbe The reflection probe to add
  105848. */
  105849. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  105850. }
  105851. /**
  105852. * Class used to generate realtime reflection / refraction cube textures
  105853. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105854. */
  105855. export class ReflectionProbe {
  105856. /** defines the name of the probe */
  105857. name: string;
  105858. private _scene;
  105859. private _renderTargetTexture;
  105860. private _projectionMatrix;
  105861. private _viewMatrix;
  105862. private _target;
  105863. private _add;
  105864. private _attachedMesh;
  105865. private _invertYAxis;
  105866. /** Gets or sets probe position (center of the cube map) */
  105867. position: Vector3;
  105868. /**
  105869. * Creates a new reflection probe
  105870. * @param name defines the name of the probe
  105871. * @param size defines the texture resolution (for each face)
  105872. * @param scene defines the hosting scene
  105873. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  105874. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  105875. */
  105876. constructor(
  105877. /** defines the name of the probe */
  105878. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  105879. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  105880. samples: number;
  105881. /** Gets or sets the refresh rate to use (on every frame by default) */
  105882. refreshRate: number;
  105883. /**
  105884. * Gets the hosting scene
  105885. * @returns a Scene
  105886. */
  105887. getScene(): Scene;
  105888. /** Gets the internal CubeTexture used to render to */
  105889. readonly cubeTexture: RenderTargetTexture;
  105890. /** Gets the list of meshes to render */
  105891. readonly renderList: Nullable<AbstractMesh[]>;
  105892. /**
  105893. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  105894. * @param mesh defines the mesh to attach to
  105895. */
  105896. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105897. /**
  105898. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  105899. * @param renderingGroupId The rendering group id corresponding to its index
  105900. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105901. */
  105902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105903. /**
  105904. * Clean all associated resources
  105905. */
  105906. dispose(): void;
  105907. /**
  105908. * Converts the reflection probe information to a readable string for debug purpose.
  105909. * @param fullDetails Supports for multiple levels of logging within scene loading
  105910. * @returns the human readable reflection probe info
  105911. */
  105912. toString(fullDetails?: boolean): string;
  105913. /**
  105914. * Get the class name of the relfection probe.
  105915. * @returns "ReflectionProbe"
  105916. */
  105917. getClassName(): string;
  105918. /**
  105919. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  105920. * @returns The JSON representation of the texture
  105921. */
  105922. serialize(): any;
  105923. /**
  105924. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  105925. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  105926. * @param scene Define the scene the parsed reflection probe should be instantiated in
  105927. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  105928. * @returns The parsed reflection probe if successful
  105929. */
  105930. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  105931. }
  105932. }
  105933. declare module BABYLON {
  105934. /** @hidden */
  105935. export var _BabylonLoaderRegistered: boolean;
  105936. }
  105937. declare module BABYLON {
  105938. /**
  105939. * The Physically based simple base material of BJS.
  105940. *
  105941. * This enables better naming and convention enforcements on top of the pbrMaterial.
  105942. * It is used as the base class for both the specGloss and metalRough conventions.
  105943. */
  105944. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  105945. /**
  105946. * Number of Simultaneous lights allowed on the material.
  105947. */
  105948. maxSimultaneousLights: number;
  105949. /**
  105950. * If sets to true, disables all the lights affecting the material.
  105951. */
  105952. disableLighting: boolean;
  105953. /**
  105954. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  105955. */
  105956. environmentTexture: BaseTexture;
  105957. /**
  105958. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105959. */
  105960. invertNormalMapX: boolean;
  105961. /**
  105962. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105963. */
  105964. invertNormalMapY: boolean;
  105965. /**
  105966. * Normal map used in the model.
  105967. */
  105968. normalTexture: BaseTexture;
  105969. /**
  105970. * Emissivie color used to self-illuminate the model.
  105971. */
  105972. emissiveColor: Color3;
  105973. /**
  105974. * Emissivie texture used to self-illuminate the model.
  105975. */
  105976. emissiveTexture: BaseTexture;
  105977. /**
  105978. * Occlusion Channel Strenght.
  105979. */
  105980. occlusionStrength: number;
  105981. /**
  105982. * Occlusion Texture of the material (adding extra occlusion effects).
  105983. */
  105984. occlusionTexture: BaseTexture;
  105985. /**
  105986. * Defines the alpha limits in alpha test mode.
  105987. */
  105988. alphaCutOff: number;
  105989. /**
  105990. * Gets the current double sided mode.
  105991. */
  105992. /**
  105993. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105994. */
  105995. doubleSided: boolean;
  105996. /**
  105997. * Stores the pre-calculated light information of a mesh in a texture.
  105998. */
  105999. lightmapTexture: BaseTexture;
  106000. /**
  106001. * If true, the light map contains occlusion information instead of lighting info.
  106002. */
  106003. useLightmapAsShadowmap: boolean;
  106004. /**
  106005. * Instantiates a new PBRMaterial instance.
  106006. *
  106007. * @param name The material name
  106008. * @param scene The scene the material will be use in.
  106009. */
  106010. constructor(name: string, scene: Scene);
  106011. getClassName(): string;
  106012. }
  106013. }
  106014. declare module BABYLON {
  106015. /**
  106016. * The PBR material of BJS following the metal roughness convention.
  106017. *
  106018. * This fits to the PBR convention in the GLTF definition:
  106019. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  106020. */
  106021. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  106022. /**
  106023. * The base color has two different interpretations depending on the value of metalness.
  106024. * When the material is a metal, the base color is the specific measured reflectance value
  106025. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  106026. * of the material.
  106027. */
  106028. baseColor: Color3;
  106029. /**
  106030. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  106031. * well as opacity information in the alpha channel.
  106032. */
  106033. baseTexture: BaseTexture;
  106034. /**
  106035. * Specifies the metallic scalar value of the material.
  106036. * Can also be used to scale the metalness values of the metallic texture.
  106037. */
  106038. metallic: number;
  106039. /**
  106040. * Specifies the roughness scalar value of the material.
  106041. * Can also be used to scale the roughness values of the metallic texture.
  106042. */
  106043. roughness: number;
  106044. /**
  106045. * Texture containing both the metallic value in the B channel and the
  106046. * roughness value in the G channel to keep better precision.
  106047. */
  106048. metallicRoughnessTexture: BaseTexture;
  106049. /**
  106050. * Instantiates a new PBRMetalRoughnessMaterial instance.
  106051. *
  106052. * @param name The material name
  106053. * @param scene The scene the material will be use in.
  106054. */
  106055. constructor(name: string, scene: Scene);
  106056. /**
  106057. * Return the currrent class name of the material.
  106058. */
  106059. getClassName(): string;
  106060. /**
  106061. * Makes a duplicate of the current material.
  106062. * @param name - name to use for the new material.
  106063. */
  106064. clone(name: string): PBRMetallicRoughnessMaterial;
  106065. /**
  106066. * Serialize the material to a parsable JSON object.
  106067. */
  106068. serialize(): any;
  106069. /**
  106070. * Parses a JSON object correponding to the serialize function.
  106071. */
  106072. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  106073. }
  106074. }
  106075. declare module BABYLON {
  106076. /**
  106077. * The PBR material of BJS following the specular glossiness convention.
  106078. *
  106079. * This fits to the PBR convention in the GLTF definition:
  106080. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  106081. */
  106082. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  106083. /**
  106084. * Specifies the diffuse color of the material.
  106085. */
  106086. diffuseColor: Color3;
  106087. /**
  106088. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  106089. * channel.
  106090. */
  106091. diffuseTexture: BaseTexture;
  106092. /**
  106093. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  106094. */
  106095. specularColor: Color3;
  106096. /**
  106097. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  106098. */
  106099. glossiness: number;
  106100. /**
  106101. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  106102. */
  106103. specularGlossinessTexture: BaseTexture;
  106104. /**
  106105. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  106106. *
  106107. * @param name The material name
  106108. * @param scene The scene the material will be use in.
  106109. */
  106110. constructor(name: string, scene: Scene);
  106111. /**
  106112. * Return the currrent class name of the material.
  106113. */
  106114. getClassName(): string;
  106115. /**
  106116. * Makes a duplicate of the current material.
  106117. * @param name - name to use for the new material.
  106118. */
  106119. clone(name: string): PBRSpecularGlossinessMaterial;
  106120. /**
  106121. * Serialize the material to a parsable JSON object.
  106122. */
  106123. serialize(): any;
  106124. /**
  106125. * Parses a JSON object correponding to the serialize function.
  106126. */
  106127. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  106128. }
  106129. }
  106130. declare module BABYLON {
  106131. /**
  106132. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  106133. * It can help converting any input color in a desired output one. This can then be used to create effects
  106134. * from sepia, black and white to sixties or futuristic rendering...
  106135. *
  106136. * The only supported format is currently 3dl.
  106137. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  106138. */
  106139. export class ColorGradingTexture extends BaseTexture {
  106140. /**
  106141. * The current texture matrix. (will always be identity in color grading texture)
  106142. */
  106143. private _textureMatrix;
  106144. /**
  106145. * The texture URL.
  106146. */
  106147. url: string;
  106148. /**
  106149. * Empty line regex stored for GC.
  106150. */
  106151. private static _noneEmptyLineRegex;
  106152. private _engine;
  106153. /**
  106154. * Instantiates a ColorGradingTexture from the following parameters.
  106155. *
  106156. * @param url The location of the color gradind data (currently only supporting 3dl)
  106157. * @param scene The scene the texture will be used in
  106158. */
  106159. constructor(url: string, scene: Scene);
  106160. /**
  106161. * Returns the texture matrix used in most of the material.
  106162. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  106163. */
  106164. getTextureMatrix(): Matrix;
  106165. /**
  106166. * Occurs when the file being loaded is a .3dl LUT file.
  106167. */
  106168. private load3dlTexture;
  106169. /**
  106170. * Starts the loading process of the texture.
  106171. */
  106172. private loadTexture;
  106173. /**
  106174. * Clones the color gradind texture.
  106175. */
  106176. clone(): ColorGradingTexture;
  106177. /**
  106178. * Called during delayed load for textures.
  106179. */
  106180. delayLoad(): void;
  106181. /**
  106182. * Parses a color grading texture serialized by Babylon.
  106183. * @param parsedTexture The texture information being parsedTexture
  106184. * @param scene The scene to load the texture in
  106185. * @param rootUrl The root url of the data assets to load
  106186. * @return A color gradind texture
  106187. */
  106188. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  106189. /**
  106190. * Serializes the LUT texture to json format.
  106191. */
  106192. serialize(): any;
  106193. }
  106194. }
  106195. declare module BABYLON {
  106196. /**
  106197. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  106198. */
  106199. export class EquiRectangularCubeTexture extends BaseTexture {
  106200. /** The six faces of the cube. */
  106201. private static _FacesMapping;
  106202. private _noMipmap;
  106203. private _onLoad;
  106204. private _onError;
  106205. /** The size of the cubemap. */
  106206. private _size;
  106207. /** The buffer of the image. */
  106208. private _buffer;
  106209. /** The width of the input image. */
  106210. private _width;
  106211. /** The height of the input image. */
  106212. private _height;
  106213. /** The URL to the image. */
  106214. url: string;
  106215. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  106216. coordinatesMode: number;
  106217. /**
  106218. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  106219. * @param url The location of the image
  106220. * @param scene The scene the texture will be used in
  106221. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106222. * @param noMipmap Forces to not generate the mipmap if true
  106223. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  106224. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  106225. * @param onLoad — defines a callback called when texture is loaded
  106226. * @param onError — defines a callback called if there is an error
  106227. */
  106228. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  106229. /**
  106230. * Load the image data, by putting the image on a canvas and extracting its buffer.
  106231. */
  106232. private loadImage;
  106233. /**
  106234. * Convert the image buffer into a cubemap and create a CubeTexture.
  106235. */
  106236. private loadTexture;
  106237. /**
  106238. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  106239. * @param buffer The ArrayBuffer that should be converted.
  106240. * @returns The buffer as Float32Array.
  106241. */
  106242. private getFloat32ArrayFromArrayBuffer;
  106243. /**
  106244. * Get the current class name of the texture useful for serialization or dynamic coding.
  106245. * @returns "EquiRectangularCubeTexture"
  106246. */
  106247. getClassName(): string;
  106248. /**
  106249. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106250. * @returns A clone of the current EquiRectangularCubeTexture.
  106251. */
  106252. clone(): EquiRectangularCubeTexture;
  106253. }
  106254. }
  106255. declare module BABYLON {
  106256. /**
  106257. * Based on jsTGALoader - Javascript loader for TGA file
  106258. * By Vincent Thibault
  106259. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106260. */
  106261. export class TGATools {
  106262. private static _TYPE_INDEXED;
  106263. private static _TYPE_RGB;
  106264. private static _TYPE_GREY;
  106265. private static _TYPE_RLE_INDEXED;
  106266. private static _TYPE_RLE_RGB;
  106267. private static _TYPE_RLE_GREY;
  106268. private static _ORIGIN_MASK;
  106269. private static _ORIGIN_SHIFT;
  106270. private static _ORIGIN_BL;
  106271. private static _ORIGIN_BR;
  106272. private static _ORIGIN_UL;
  106273. private static _ORIGIN_UR;
  106274. /**
  106275. * Gets the header of a TGA file
  106276. * @param data defines the TGA data
  106277. * @returns the header
  106278. */
  106279. static GetTGAHeader(data: Uint8Array): any;
  106280. /**
  106281. * Uploads TGA content to a Babylon Texture
  106282. * @hidden
  106283. */
  106284. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106285. /** @hidden */
  106286. 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;
  106287. /** @hidden */
  106288. 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;
  106289. /** @hidden */
  106290. 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;
  106291. /** @hidden */
  106292. 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;
  106293. /** @hidden */
  106294. 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;
  106295. /** @hidden */
  106296. 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;
  106297. }
  106298. }
  106299. declare module BABYLON {
  106300. /**
  106301. * Implementation of the TGA Texture Loader.
  106302. * @hidden
  106303. */
  106304. export class _TGATextureLoader implements IInternalTextureLoader {
  106305. /**
  106306. * Defines wether the loader supports cascade loading the different faces.
  106307. */
  106308. readonly supportCascades: boolean;
  106309. /**
  106310. * This returns if the loader support the current file information.
  106311. * @param extension defines the file extension of the file being loaded
  106312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106313. * @param fallback defines the fallback internal texture if any
  106314. * @param isBase64 defines whether the texture is encoded as a base64
  106315. * @param isBuffer defines whether the texture data are stored as a buffer
  106316. * @returns true if the loader can load the specified file
  106317. */
  106318. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106319. /**
  106320. * Transform the url before loading if required.
  106321. * @param rootUrl the url of the texture
  106322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106323. * @returns the transformed texture
  106324. */
  106325. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106326. /**
  106327. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106328. * @param rootUrl the url of the texture
  106329. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106330. * @returns the fallback texture
  106331. */
  106332. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106333. /**
  106334. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106335. * @param data contains the texture data
  106336. * @param texture defines the BabylonJS internal texture
  106337. * @param createPolynomials will be true if polynomials have been requested
  106338. * @param onLoad defines the callback to trigger once the texture is ready
  106339. * @param onError defines the callback to trigger in case of error
  106340. */
  106341. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106342. /**
  106343. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106344. * @param data contains the texture data
  106345. * @param texture defines the BabylonJS internal texture
  106346. * @param callback defines the method to call once ready to upload
  106347. */
  106348. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106349. }
  106350. }
  106351. declare module BABYLON {
  106352. /**
  106353. * 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.
  106354. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106355. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106356. */
  106357. export class CustomProceduralTexture extends ProceduralTexture {
  106358. private _animate;
  106359. private _time;
  106360. private _config;
  106361. private _texturePath;
  106362. /**
  106363. * Instantiates a new Custom Procedural Texture.
  106364. * 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.
  106365. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106366. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106367. * @param name Define the name of the texture
  106368. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106369. * @param size Define the size of the texture to create
  106370. * @param scene Define the scene the texture belongs to
  106371. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106372. * @param generateMipMaps Define if the texture should creates mip maps or not
  106373. */
  106374. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106375. private _loadJson;
  106376. /**
  106377. * Is the texture ready to be used ? (rendered at least once)
  106378. * @returns true if ready, otherwise, false.
  106379. */
  106380. isReady(): boolean;
  106381. /**
  106382. * Render the texture to its associated render target.
  106383. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106384. */
  106385. render(useCameraPostProcess?: boolean): void;
  106386. /**
  106387. * Update the list of dependant textures samplers in the shader.
  106388. */
  106389. updateTextures(): void;
  106390. /**
  106391. * Update the uniform values of the procedural texture in the shader.
  106392. */
  106393. updateShaderUniforms(): void;
  106394. /**
  106395. * Define if the texture animates or not.
  106396. */
  106397. animate: boolean;
  106398. }
  106399. }
  106400. declare module BABYLON {
  106401. /** @hidden */
  106402. export var noisePixelShader: {
  106403. name: string;
  106404. shader: string;
  106405. };
  106406. }
  106407. declare module BABYLON {
  106408. /**
  106409. * Class used to generate noise procedural textures
  106410. */
  106411. export class NoiseProceduralTexture extends ProceduralTexture {
  106412. private _time;
  106413. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106414. brightness: number;
  106415. /** Defines the number of octaves to process */
  106416. octaves: number;
  106417. /** Defines the level of persistence (0.8 by default) */
  106418. persistence: number;
  106419. /** Gets or sets animation speed factor (default is 1) */
  106420. animationSpeedFactor: number;
  106421. /**
  106422. * Creates a new NoiseProceduralTexture
  106423. * @param name defines the name fo the texture
  106424. * @param size defines the size of the texture (default is 256)
  106425. * @param scene defines the hosting scene
  106426. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106427. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106428. */
  106429. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106430. private _updateShaderUniforms;
  106431. protected _getDefines(): string;
  106432. /** Generate the current state of the procedural texture */
  106433. render(useCameraPostProcess?: boolean): void;
  106434. /**
  106435. * Serializes this noise procedural texture
  106436. * @returns a serialized noise procedural texture object
  106437. */
  106438. serialize(): any;
  106439. /**
  106440. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106441. * @param parsedTexture defines parsed texture data
  106442. * @param scene defines the current scene
  106443. * @param rootUrl defines the root URL containing noise procedural texture information
  106444. * @returns a parsed NoiseProceduralTexture
  106445. */
  106446. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106447. }
  106448. }
  106449. declare module BABYLON {
  106450. /**
  106451. * Raw cube texture where the raw buffers are passed in
  106452. */
  106453. export class RawCubeTexture extends CubeTexture {
  106454. /**
  106455. * Creates a cube texture where the raw buffers are passed in.
  106456. * @param scene defines the scene the texture is attached to
  106457. * @param data defines the array of data to use to create each face
  106458. * @param size defines the size of the textures
  106459. * @param format defines the format of the data
  106460. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106461. * @param generateMipMaps defines if the engine should generate the mip levels
  106462. * @param invertY defines if data must be stored with Y axis inverted
  106463. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106464. * @param compression defines the compression used (null by default)
  106465. */
  106466. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106467. /**
  106468. * Updates the raw cube texture.
  106469. * @param data defines the data to store
  106470. * @param format defines the data format
  106471. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106472. * @param invertY defines if data must be stored with Y axis inverted
  106473. * @param compression defines the compression used (null by default)
  106474. * @param level defines which level of the texture to update
  106475. */
  106476. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106477. /**
  106478. * Updates a raw cube texture with RGBD encoded data.
  106479. * @param data defines the array of data [mipmap][face] to use to create each face
  106480. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106481. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106482. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106483. * @returns a promsie that resolves when the operation is complete
  106484. */
  106485. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106486. /**
  106487. * Clones the raw cube texture.
  106488. * @return a new cube texture
  106489. */
  106490. clone(): CubeTexture;
  106491. /** @hidden */
  106492. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106493. }
  106494. }
  106495. declare module BABYLON {
  106496. /**
  106497. * Class used to store 3D textures containing user data
  106498. */
  106499. export class RawTexture3D extends Texture {
  106500. /** Gets or sets the texture format to use */
  106501. format: number;
  106502. private _engine;
  106503. /**
  106504. * Create a new RawTexture3D
  106505. * @param data defines the data of the texture
  106506. * @param width defines the width of the texture
  106507. * @param height defines the height of the texture
  106508. * @param depth defines the depth of the texture
  106509. * @param format defines the texture format to use
  106510. * @param scene defines the hosting scene
  106511. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106512. * @param invertY defines if texture must be stored with Y axis inverted
  106513. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106514. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106515. */
  106516. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106517. /** Gets or sets the texture format to use */
  106518. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106519. /**
  106520. * Update the texture with new data
  106521. * @param data defines the data to store in the texture
  106522. */
  106523. update(data: ArrayBufferView): void;
  106524. }
  106525. }
  106526. declare module BABYLON {
  106527. /**
  106528. * Creates a refraction texture used by refraction channel of the standard material.
  106529. * It is like a mirror but to see through a material.
  106530. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106531. */
  106532. export class RefractionTexture extends RenderTargetTexture {
  106533. /**
  106534. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106535. * 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.
  106536. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106537. */
  106538. refractionPlane: Plane;
  106539. /**
  106540. * Define how deep under the surface we should see.
  106541. */
  106542. depth: number;
  106543. /**
  106544. * Creates a refraction texture used by refraction channel of the standard material.
  106545. * It is like a mirror but to see through a material.
  106546. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106547. * @param name Define the texture name
  106548. * @param size Define the size of the underlying texture
  106549. * @param scene Define the scene the refraction belongs to
  106550. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106551. */
  106552. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106553. /**
  106554. * Clone the refraction texture.
  106555. * @returns the cloned texture
  106556. */
  106557. clone(): RefractionTexture;
  106558. /**
  106559. * Serialize the texture to a JSON representation you could use in Parse later on
  106560. * @returns the serialized JSON representation
  106561. */
  106562. serialize(): any;
  106563. }
  106564. }
  106565. declare module BABYLON {
  106566. /**
  106567. * Configuration for Draco compression
  106568. */
  106569. export interface IDracoCompressionConfiguration {
  106570. /**
  106571. * Configuration for the decoder.
  106572. */
  106573. decoder?: {
  106574. /**
  106575. * The url to the WebAssembly module.
  106576. */
  106577. wasmUrl?: string;
  106578. /**
  106579. * The url to the WebAssembly binary.
  106580. */
  106581. wasmBinaryUrl?: string;
  106582. /**
  106583. * The url to the fallback JavaScript module.
  106584. */
  106585. fallbackUrl?: string;
  106586. };
  106587. }
  106588. /**
  106589. * Draco compression (https://google.github.io/draco/)
  106590. *
  106591. * This class wraps the Draco module.
  106592. *
  106593. * **Encoder**
  106594. *
  106595. * The encoder is not currently implemented.
  106596. *
  106597. * **Decoder**
  106598. *
  106599. * 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.
  106600. *
  106601. * To update the configuration, use the following code:
  106602. * ```javascript
  106603. * DracoCompression.Configuration = {
  106604. * decoder: {
  106605. * wasmUrl: "<url to the WebAssembly library>",
  106606. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106607. * fallbackUrl: "<url to the fallback JavaScript library>",
  106608. * }
  106609. * };
  106610. * ```
  106611. *
  106612. * 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.
  106613. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106614. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106615. *
  106616. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106617. * ```javascript
  106618. * var dracoCompression = new DracoCompression();
  106619. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106620. * [VertexBuffer.PositionKind]: 0
  106621. * });
  106622. * ```
  106623. *
  106624. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106625. */
  106626. export class DracoCompression implements IDisposable {
  106627. private static _DecoderModulePromise;
  106628. /**
  106629. * The configuration. Defaults to the following urls:
  106630. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106631. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106632. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106633. */
  106634. static Configuration: IDracoCompressionConfiguration;
  106635. /**
  106636. * Returns true if the decoder is available.
  106637. */
  106638. static readonly DecoderAvailable: boolean;
  106639. /**
  106640. * Constructor
  106641. */
  106642. constructor();
  106643. /**
  106644. * Stop all async operations and release resources.
  106645. */
  106646. dispose(): void;
  106647. /**
  106648. * Decode Draco compressed mesh data to vertex data.
  106649. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106650. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106651. * @returns A promise that resolves with the decoded vertex data
  106652. */
  106653. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106654. [kind: string]: number;
  106655. }): Promise<VertexData>;
  106656. private static _GetDecoderModule;
  106657. private static _LoadScriptAsync;
  106658. private static _LoadFileAsync;
  106659. }
  106660. }
  106661. declare module BABYLON {
  106662. /**
  106663. * Class for building Constructive Solid Geometry
  106664. */
  106665. export class CSG {
  106666. private polygons;
  106667. /**
  106668. * The world matrix
  106669. */
  106670. matrix: Matrix;
  106671. /**
  106672. * Stores the position
  106673. */
  106674. position: Vector3;
  106675. /**
  106676. * Stores the rotation
  106677. */
  106678. rotation: Vector3;
  106679. /**
  106680. * Stores the rotation quaternion
  106681. */
  106682. rotationQuaternion: Nullable<Quaternion>;
  106683. /**
  106684. * Stores the scaling vector
  106685. */
  106686. scaling: Vector3;
  106687. /**
  106688. * Convert the Mesh to CSG
  106689. * @param mesh The Mesh to convert to CSG
  106690. * @returns A new CSG from the Mesh
  106691. */
  106692. static FromMesh(mesh: Mesh): CSG;
  106693. /**
  106694. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106695. * @param polygons Polygons used to construct a CSG solid
  106696. */
  106697. private static FromPolygons;
  106698. /**
  106699. * Clones, or makes a deep copy, of the CSG
  106700. * @returns A new CSG
  106701. */
  106702. clone(): CSG;
  106703. /**
  106704. * Unions this CSG with another CSG
  106705. * @param csg The CSG to union against this CSG
  106706. * @returns The unioned CSG
  106707. */
  106708. union(csg: CSG): CSG;
  106709. /**
  106710. * Unions this CSG with another CSG in place
  106711. * @param csg The CSG to union against this CSG
  106712. */
  106713. unionInPlace(csg: CSG): void;
  106714. /**
  106715. * Subtracts this CSG with another CSG
  106716. * @param csg The CSG to subtract against this CSG
  106717. * @returns A new CSG
  106718. */
  106719. subtract(csg: CSG): CSG;
  106720. /**
  106721. * Subtracts this CSG with another CSG in place
  106722. * @param csg The CSG to subtact against this CSG
  106723. */
  106724. subtractInPlace(csg: CSG): void;
  106725. /**
  106726. * Intersect this CSG with another CSG
  106727. * @param csg The CSG to intersect against this CSG
  106728. * @returns A new CSG
  106729. */
  106730. intersect(csg: CSG): CSG;
  106731. /**
  106732. * Intersects this CSG with another CSG in place
  106733. * @param csg The CSG to intersect against this CSG
  106734. */
  106735. intersectInPlace(csg: CSG): void;
  106736. /**
  106737. * Return a new CSG solid with solid and empty space switched. This solid is
  106738. * not modified.
  106739. * @returns A new CSG solid with solid and empty space switched
  106740. */
  106741. inverse(): CSG;
  106742. /**
  106743. * Inverses the CSG in place
  106744. */
  106745. inverseInPlace(): void;
  106746. /**
  106747. * This is used to keep meshes transformations so they can be restored
  106748. * when we build back a Babylon Mesh
  106749. * NB : All CSG operations are performed in world coordinates
  106750. * @param csg The CSG to copy the transform attributes from
  106751. * @returns This CSG
  106752. */
  106753. copyTransformAttributes(csg: CSG): CSG;
  106754. /**
  106755. * Build Raw mesh from CSG
  106756. * Coordinates here are in world space
  106757. * @param name The name of the mesh geometry
  106758. * @param scene The Scene
  106759. * @param keepSubMeshes Specifies if the submeshes should be kept
  106760. * @returns A new Mesh
  106761. */
  106762. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  106763. /**
  106764. * Build Mesh from CSG taking material and transforms into account
  106765. * @param name The name of the Mesh
  106766. * @param material The material of the Mesh
  106767. * @param scene The Scene
  106768. * @param keepSubMeshes Specifies if submeshes should be kept
  106769. * @returns The new Mesh
  106770. */
  106771. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  106772. }
  106773. }
  106774. declare module BABYLON {
  106775. /**
  106776. * Class used to create a trail following a mesh
  106777. */
  106778. export class TrailMesh extends Mesh {
  106779. private _generator;
  106780. private _autoStart;
  106781. private _running;
  106782. private _diameter;
  106783. private _length;
  106784. private _sectionPolygonPointsCount;
  106785. private _sectionVectors;
  106786. private _sectionNormalVectors;
  106787. private _beforeRenderObserver;
  106788. /**
  106789. * @constructor
  106790. * @param name The value used by scene.getMeshByName() to do a lookup.
  106791. * @param generator The mesh to generate a trail.
  106792. * @param scene The scene to add this mesh to.
  106793. * @param diameter Diameter of trailing mesh. Default is 1.
  106794. * @param length Length of trailing mesh. Default is 60.
  106795. * @param autoStart Automatically start trailing mesh. Default true.
  106796. */
  106797. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  106798. /**
  106799. * "TrailMesh"
  106800. * @returns "TrailMesh"
  106801. */
  106802. getClassName(): string;
  106803. private _createMesh;
  106804. /**
  106805. * Start trailing mesh.
  106806. */
  106807. start(): void;
  106808. /**
  106809. * Stop trailing mesh.
  106810. */
  106811. stop(): void;
  106812. /**
  106813. * Update trailing mesh geometry.
  106814. */
  106815. update(): void;
  106816. /**
  106817. * Returns a new TrailMesh object.
  106818. * @param name is a string, the name given to the new mesh
  106819. * @param newGenerator use new generator object for cloned trail mesh
  106820. * @returns a new mesh
  106821. */
  106822. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  106823. /**
  106824. * Serializes this trail mesh
  106825. * @param serializationObject object to write serialization to
  106826. */
  106827. serialize(serializationObject: any): void;
  106828. /**
  106829. * Parses a serialized trail mesh
  106830. * @param parsedMesh the serialized mesh
  106831. * @param scene the scene to create the trail mesh in
  106832. * @returns the created trail mesh
  106833. */
  106834. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  106835. }
  106836. }
  106837. declare module BABYLON {
  106838. /**
  106839. * Class containing static functions to help procedurally build meshes
  106840. */
  106841. export class RibbonBuilder {
  106842. /**
  106843. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106844. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106845. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106846. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106847. * * 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
  106848. * * 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
  106849. * * 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
  106850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106852. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106853. * * 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
  106854. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106855. * * 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
  106856. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106858. * @param name defines the name of the mesh
  106859. * @param options defines the options used to create the mesh
  106860. * @param scene defines the hosting scene
  106861. * @returns the ribbon mesh
  106862. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106863. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106864. */
  106865. static CreateRibbon(name: string, options: {
  106866. pathArray: Vector3[][];
  106867. closeArray?: boolean;
  106868. closePath?: boolean;
  106869. offset?: number;
  106870. updatable?: boolean;
  106871. sideOrientation?: number;
  106872. frontUVs?: Vector4;
  106873. backUVs?: Vector4;
  106874. instance?: Mesh;
  106875. invertUV?: boolean;
  106876. uvs?: Vector2[];
  106877. colors?: Color4[];
  106878. }, scene?: Nullable<Scene>): Mesh;
  106879. }
  106880. }
  106881. declare module BABYLON {
  106882. /**
  106883. * Class containing static functions to help procedurally build meshes
  106884. */
  106885. export class TorusKnotBuilder {
  106886. /**
  106887. * Creates a torus knot mesh
  106888. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106889. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106890. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106891. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106895. * @param name defines the name of the mesh
  106896. * @param options defines the options used to create the mesh
  106897. * @param scene defines the hosting scene
  106898. * @returns the torus knot mesh
  106899. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106900. */
  106901. static CreateTorusKnot(name: string, options: {
  106902. radius?: number;
  106903. tube?: number;
  106904. radialSegments?: number;
  106905. tubularSegments?: number;
  106906. p?: number;
  106907. q?: number;
  106908. updatable?: boolean;
  106909. sideOrientation?: number;
  106910. frontUVs?: Vector4;
  106911. backUVs?: Vector4;
  106912. }, scene: any): Mesh;
  106913. }
  106914. }
  106915. declare module BABYLON {
  106916. /**
  106917. * Polygon
  106918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106919. */
  106920. export class Polygon {
  106921. /**
  106922. * Creates a rectangle
  106923. * @param xmin bottom X coord
  106924. * @param ymin bottom Y coord
  106925. * @param xmax top X coord
  106926. * @param ymax top Y coord
  106927. * @returns points that make the resulting rectation
  106928. */
  106929. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  106930. /**
  106931. * Creates a circle
  106932. * @param radius radius of circle
  106933. * @param cx scale in x
  106934. * @param cy scale in y
  106935. * @param numberOfSides number of sides that make up the circle
  106936. * @returns points that make the resulting circle
  106937. */
  106938. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  106939. /**
  106940. * Creates a polygon from input string
  106941. * @param input Input polygon data
  106942. * @returns the parsed points
  106943. */
  106944. static Parse(input: string): Vector2[];
  106945. /**
  106946. * Starts building a polygon from x and y coordinates
  106947. * @param x x coordinate
  106948. * @param y y coordinate
  106949. * @returns the started path2
  106950. */
  106951. static StartingAt(x: number, y: number): Path2;
  106952. }
  106953. /**
  106954. * Builds a polygon
  106955. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  106956. */
  106957. export class PolygonMeshBuilder {
  106958. private _points;
  106959. private _outlinepoints;
  106960. private _holes;
  106961. private _name;
  106962. private _scene;
  106963. private _epoints;
  106964. private _eholes;
  106965. private _addToepoint;
  106966. /**
  106967. * Babylon reference to the earcut plugin.
  106968. */
  106969. bjsEarcut: any;
  106970. /**
  106971. * Creates a PolygonMeshBuilder
  106972. * @param name name of the builder
  106973. * @param contours Path of the polygon
  106974. * @param scene scene to add to when creating the mesh
  106975. * @param earcutInjection can be used to inject your own earcut reference
  106976. */
  106977. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  106978. /**
  106979. * Adds a whole within the polygon
  106980. * @param hole Array of points defining the hole
  106981. * @returns this
  106982. */
  106983. addHole(hole: Vector2[]): PolygonMeshBuilder;
  106984. /**
  106985. * Creates the polygon
  106986. * @param updatable If the mesh should be updatable
  106987. * @param depth The depth of the mesh created
  106988. * @returns the created mesh
  106989. */
  106990. build(updatable?: boolean, depth?: number): Mesh;
  106991. /**
  106992. * Creates the polygon
  106993. * @param depth The depth of the mesh created
  106994. * @returns the created VertexData
  106995. */
  106996. buildVertexData(depth?: number): VertexData;
  106997. /**
  106998. * Adds a side to the polygon
  106999. * @param positions points that make the polygon
  107000. * @param normals normals of the polygon
  107001. * @param uvs uvs of the polygon
  107002. * @param indices indices of the polygon
  107003. * @param bounds bounds of the polygon
  107004. * @param points points of the polygon
  107005. * @param depth depth of the polygon
  107006. * @param flip flip of the polygon
  107007. */
  107008. private addSide;
  107009. }
  107010. }
  107011. declare module BABYLON {
  107012. /**
  107013. * Class containing static functions to help procedurally build meshes
  107014. */
  107015. export class PolygonBuilder {
  107016. /**
  107017. * Creates a polygon mesh
  107018. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107019. * * 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
  107020. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107023. * * Remember you can only change the shape positions, not their number when updating a polygon
  107024. * @param name defines the name of the mesh
  107025. * @param options defines the options used to create the mesh
  107026. * @param scene defines the hosting scene
  107027. * @param earcutInjection can be used to inject your own earcut reference
  107028. * @returns the polygon mesh
  107029. */
  107030. static CreatePolygon(name: string, options: {
  107031. shape: Vector3[];
  107032. holes?: Vector3[][];
  107033. depth?: number;
  107034. faceUV?: Vector4[];
  107035. faceColors?: Color4[];
  107036. updatable?: boolean;
  107037. sideOrientation?: number;
  107038. frontUVs?: Vector4;
  107039. backUVs?: Vector4;
  107040. }, scene: Scene, earcutInjection?: any): Mesh;
  107041. /**
  107042. * Creates an extruded polygon mesh, with depth in the Y direction.
  107043. * * 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)
  107044. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107045. * @param name defines the name of the mesh
  107046. * @param options defines the options used to create the mesh
  107047. * @param scene defines the hosting scene
  107048. * @param earcutInjection can be used to inject your own earcut reference
  107049. * @returns the polygon mesh
  107050. */
  107051. static ExtrudePolygon(name: string, options: {
  107052. shape: Vector3[];
  107053. holes?: Vector3[][];
  107054. depth?: number;
  107055. faceUV?: Vector4[];
  107056. faceColors?: Color4[];
  107057. updatable?: boolean;
  107058. sideOrientation?: number;
  107059. frontUVs?: Vector4;
  107060. backUVs?: Vector4;
  107061. }, scene: Scene, earcutInjection?: any): Mesh;
  107062. }
  107063. }
  107064. declare module BABYLON {
  107065. /**
  107066. * Class containing static functions to help procedurally build meshes
  107067. */
  107068. export class ShapeBuilder {
  107069. /**
  107070. * 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.
  107071. * * 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.
  107072. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107073. * * 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.
  107074. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107075. * * 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
  107076. * * 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
  107077. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107082. * @param name defines the name of the mesh
  107083. * @param options defines the options used to create the mesh
  107084. * @param scene defines the hosting scene
  107085. * @returns the extruded shape mesh
  107086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107087. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107088. */
  107089. static ExtrudeShape(name: string, options: {
  107090. shape: Vector3[];
  107091. path: Vector3[];
  107092. scale?: number;
  107093. rotation?: number;
  107094. cap?: number;
  107095. updatable?: boolean;
  107096. sideOrientation?: number;
  107097. frontUVs?: Vector4;
  107098. backUVs?: Vector4;
  107099. instance?: Mesh;
  107100. invertUV?: boolean;
  107101. }, scene?: Nullable<Scene>): Mesh;
  107102. /**
  107103. * Creates an custom extruded shape mesh.
  107104. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107105. * * 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.
  107106. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107107. * * 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
  107108. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107109. * * 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
  107110. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107111. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107112. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107113. * * 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
  107114. * * 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
  107115. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107119. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107120. * @param name defines the name of the mesh
  107121. * @param options defines the options used to create the mesh
  107122. * @param scene defines the hosting scene
  107123. * @returns the custom extruded shape mesh
  107124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107127. */
  107128. static ExtrudeShapeCustom(name: string, options: {
  107129. shape: Vector3[];
  107130. path: Vector3[];
  107131. scaleFunction?: any;
  107132. rotationFunction?: any;
  107133. ribbonCloseArray?: boolean;
  107134. ribbonClosePath?: boolean;
  107135. cap?: number;
  107136. updatable?: boolean;
  107137. sideOrientation?: number;
  107138. frontUVs?: Vector4;
  107139. backUVs?: Vector4;
  107140. instance?: Mesh;
  107141. invertUV?: boolean;
  107142. }, scene: Scene): Mesh;
  107143. private static _ExtrudeShapeGeneric;
  107144. }
  107145. }
  107146. declare module BABYLON {
  107147. /**
  107148. * Class containing static functions to help procedurally build meshes
  107149. */
  107150. export class LatheBuilder {
  107151. /**
  107152. * Creates lathe mesh.
  107153. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107154. * * 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
  107155. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107156. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107157. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107158. * * 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
  107159. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107160. * * 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
  107161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107165. * @param name defines the name of the mesh
  107166. * @param options defines the options used to create the mesh
  107167. * @param scene defines the hosting scene
  107168. * @returns the lathe mesh
  107169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107170. */
  107171. static CreateLathe(name: string, options: {
  107172. shape: Vector3[];
  107173. radius?: number;
  107174. tessellation?: number;
  107175. clip?: number;
  107176. arc?: number;
  107177. closed?: boolean;
  107178. updatable?: boolean;
  107179. sideOrientation?: number;
  107180. frontUVs?: Vector4;
  107181. backUVs?: Vector4;
  107182. cap?: number;
  107183. invertUV?: boolean;
  107184. }, scene: Scene): Mesh;
  107185. }
  107186. }
  107187. declare module BABYLON {
  107188. /**
  107189. * Class containing static functions to help procedurally build meshes
  107190. */
  107191. export class TubeBuilder {
  107192. /**
  107193. * Creates a tube mesh.
  107194. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107195. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107196. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107197. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107198. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107199. * * 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)
  107200. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107201. * * 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
  107202. * * 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
  107203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107207. * @param name defines the name of the mesh
  107208. * @param options defines the options used to create the mesh
  107209. * @param scene defines the hosting scene
  107210. * @returns the tube mesh
  107211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107212. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107213. */
  107214. static CreateTube(name: string, options: {
  107215. path: Vector3[];
  107216. radius?: number;
  107217. tessellation?: number;
  107218. radiusFunction?: {
  107219. (i: number, distance: number): number;
  107220. };
  107221. cap?: number;
  107222. arc?: number;
  107223. updatable?: boolean;
  107224. sideOrientation?: number;
  107225. frontUVs?: Vector4;
  107226. backUVs?: Vector4;
  107227. instance?: Mesh;
  107228. invertUV?: boolean;
  107229. }, scene: Scene): Mesh;
  107230. }
  107231. }
  107232. declare module BABYLON {
  107233. /**
  107234. * Class containing static functions to help procedurally build meshes
  107235. */
  107236. export class IcoSphereBuilder {
  107237. /**
  107238. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107239. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107240. * * 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`)
  107241. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107242. * * 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
  107243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107246. * @param name defines the name of the mesh
  107247. * @param options defines the options used to create the mesh
  107248. * @param scene defines the hosting scene
  107249. * @returns the icosahedron mesh
  107250. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107251. */
  107252. static CreateIcoSphere(name: string, options: {
  107253. radius?: number;
  107254. radiusX?: number;
  107255. radiusY?: number;
  107256. radiusZ?: number;
  107257. flat?: boolean;
  107258. subdivisions?: number;
  107259. sideOrientation?: number;
  107260. frontUVs?: Vector4;
  107261. backUVs?: Vector4;
  107262. updatable?: boolean;
  107263. }, scene: Scene): Mesh;
  107264. }
  107265. }
  107266. declare module BABYLON {
  107267. /**
  107268. * Class containing static functions to help procedurally build meshes
  107269. */
  107270. export class DecalBuilder {
  107271. /**
  107272. * Creates a decal mesh.
  107273. * 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
  107274. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107275. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107276. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107277. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107278. * @param name defines the name of the mesh
  107279. * @param sourceMesh defines the mesh where the decal must be applied
  107280. * @param options defines the options used to create the mesh
  107281. * @param scene defines the hosting scene
  107282. * @returns the decal mesh
  107283. * @see https://doc.babylonjs.com/how_to/decals
  107284. */
  107285. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107286. position?: Vector3;
  107287. normal?: Vector3;
  107288. size?: Vector3;
  107289. angle?: number;
  107290. }): Mesh;
  107291. }
  107292. }
  107293. declare module BABYLON {
  107294. /**
  107295. * Class containing static functions to help procedurally build meshes
  107296. */
  107297. export class MeshBuilder {
  107298. /**
  107299. * Creates a box mesh
  107300. * * The parameter `size` sets the size (float) of each box side (default 1)
  107301. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107302. * * 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)
  107303. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107307. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107308. * @param name defines the name of the mesh
  107309. * @param options defines the options used to create the mesh
  107310. * @param scene defines the hosting scene
  107311. * @returns the box mesh
  107312. */
  107313. static CreateBox(name: string, options: {
  107314. size?: number;
  107315. width?: number;
  107316. height?: number;
  107317. depth?: number;
  107318. faceUV?: Vector4[];
  107319. faceColors?: Color4[];
  107320. sideOrientation?: number;
  107321. frontUVs?: Vector4;
  107322. backUVs?: Vector4;
  107323. updatable?: boolean;
  107324. }, scene?: Nullable<Scene>): Mesh;
  107325. /**
  107326. * Creates a sphere mesh
  107327. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107328. * * 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`)
  107329. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107330. * * 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
  107331. * * 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)
  107332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107335. * @param name defines the name of the mesh
  107336. * @param options defines the options used to create the mesh
  107337. * @param scene defines the hosting scene
  107338. * @returns the sphere mesh
  107339. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107340. */
  107341. static CreateSphere(name: string, options: {
  107342. segments?: number;
  107343. diameter?: number;
  107344. diameterX?: number;
  107345. diameterY?: number;
  107346. diameterZ?: number;
  107347. arc?: number;
  107348. slice?: number;
  107349. sideOrientation?: number;
  107350. frontUVs?: Vector4;
  107351. backUVs?: Vector4;
  107352. updatable?: boolean;
  107353. }, scene: any): Mesh;
  107354. /**
  107355. * Creates a plane polygonal mesh. By default, this is a disc
  107356. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107357. * * 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
  107358. * * 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
  107359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107362. * @param name defines the name of the mesh
  107363. * @param options defines the options used to create the mesh
  107364. * @param scene defines the hosting scene
  107365. * @returns the plane polygonal mesh
  107366. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107367. */
  107368. static CreateDisc(name: string, options: {
  107369. radius?: number;
  107370. tessellation?: number;
  107371. arc?: number;
  107372. updatable?: boolean;
  107373. sideOrientation?: number;
  107374. frontUVs?: Vector4;
  107375. backUVs?: Vector4;
  107376. }, scene?: Nullable<Scene>): Mesh;
  107377. /**
  107378. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107379. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107380. * * 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`)
  107381. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107382. * * 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
  107383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107386. * @param name defines the name of the mesh
  107387. * @param options defines the options used to create the mesh
  107388. * @param scene defines the hosting scene
  107389. * @returns the icosahedron mesh
  107390. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107391. */
  107392. static CreateIcoSphere(name: string, options: {
  107393. radius?: number;
  107394. radiusX?: number;
  107395. radiusY?: number;
  107396. radiusZ?: number;
  107397. flat?: boolean;
  107398. subdivisions?: number;
  107399. sideOrientation?: number;
  107400. frontUVs?: Vector4;
  107401. backUVs?: Vector4;
  107402. updatable?: boolean;
  107403. }, scene: Scene): Mesh;
  107404. /**
  107405. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107406. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107407. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107408. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107409. * * 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
  107410. * * 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
  107411. * * 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
  107412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107415. * * 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
  107416. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107417. * * 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
  107418. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107420. * @param name defines the name of the mesh
  107421. * @param options defines the options used to create the mesh
  107422. * @param scene defines the hosting scene
  107423. * @returns the ribbon mesh
  107424. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107425. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107426. */
  107427. static CreateRibbon(name: string, options: {
  107428. pathArray: Vector3[][];
  107429. closeArray?: boolean;
  107430. closePath?: boolean;
  107431. offset?: number;
  107432. updatable?: boolean;
  107433. sideOrientation?: number;
  107434. frontUVs?: Vector4;
  107435. backUVs?: Vector4;
  107436. instance?: Mesh;
  107437. invertUV?: boolean;
  107438. uvs?: Vector2[];
  107439. colors?: Color4[];
  107440. }, scene?: Nullable<Scene>): Mesh;
  107441. /**
  107442. * Creates a cylinder or a cone mesh
  107443. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107444. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107445. * * 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.
  107446. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107447. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107448. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107449. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107450. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107451. * * 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).
  107452. * * 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
  107453. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107454. * * 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
  107455. * * 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.
  107456. * * If `enclose` is false, a ring surface is one element.
  107457. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107458. * * 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
  107459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107462. * @param name defines the name of the mesh
  107463. * @param options defines the options used to create the mesh
  107464. * @param scene defines the hosting scene
  107465. * @returns the cylinder mesh
  107466. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107467. */
  107468. static CreateCylinder(name: string, options: {
  107469. height?: number;
  107470. diameterTop?: number;
  107471. diameterBottom?: number;
  107472. diameter?: number;
  107473. tessellation?: number;
  107474. subdivisions?: number;
  107475. arc?: number;
  107476. faceColors?: Color4[];
  107477. faceUV?: Vector4[];
  107478. updatable?: boolean;
  107479. hasRings?: boolean;
  107480. enclose?: boolean;
  107481. sideOrientation?: number;
  107482. frontUVs?: Vector4;
  107483. backUVs?: Vector4;
  107484. }, scene: any): Mesh;
  107485. /**
  107486. * Creates a torus mesh
  107487. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107488. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107489. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107493. * @param name defines the name of the mesh
  107494. * @param options defines the options used to create the mesh
  107495. * @param scene defines the hosting scene
  107496. * @returns the torus mesh
  107497. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107498. */
  107499. static CreateTorus(name: string, options: {
  107500. diameter?: number;
  107501. thickness?: number;
  107502. tessellation?: number;
  107503. updatable?: boolean;
  107504. sideOrientation?: number;
  107505. frontUVs?: Vector4;
  107506. backUVs?: Vector4;
  107507. }, scene: any): Mesh;
  107508. /**
  107509. * Creates a torus knot mesh
  107510. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107511. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107512. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107513. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107515. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107517. * @param name defines the name of the mesh
  107518. * @param options defines the options used to create the mesh
  107519. * @param scene defines the hosting scene
  107520. * @returns the torus knot mesh
  107521. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107522. */
  107523. static CreateTorusKnot(name: string, options: {
  107524. radius?: number;
  107525. tube?: number;
  107526. radialSegments?: number;
  107527. tubularSegments?: number;
  107528. p?: number;
  107529. q?: number;
  107530. updatable?: boolean;
  107531. sideOrientation?: number;
  107532. frontUVs?: Vector4;
  107533. backUVs?: Vector4;
  107534. }, scene: any): Mesh;
  107535. /**
  107536. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107537. * * 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
  107538. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107539. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107540. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107541. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107542. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107543. * * 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
  107544. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107547. * @param name defines the name of the new line system
  107548. * @param options defines the options used to create the line system
  107549. * @param scene defines the hosting scene
  107550. * @returns a new line system mesh
  107551. */
  107552. static CreateLineSystem(name: string, options: {
  107553. lines: Vector3[][];
  107554. updatable?: boolean;
  107555. instance?: Nullable<LinesMesh>;
  107556. colors?: Nullable<Color4[][]>;
  107557. useVertexAlpha?: boolean;
  107558. }, scene: Nullable<Scene>): LinesMesh;
  107559. /**
  107560. * Creates a line mesh
  107561. * 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
  107562. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107563. * * The parameter `points` is an array successive Vector3
  107564. * * 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
  107565. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107566. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107567. * * When updating an instance, remember that only point positions can change, not the number of points
  107568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107570. * @param name defines the name of the new line system
  107571. * @param options defines the options used to create the line system
  107572. * @param scene defines the hosting scene
  107573. * @returns a new line mesh
  107574. */
  107575. static CreateLines(name: string, options: {
  107576. points: Vector3[];
  107577. updatable?: boolean;
  107578. instance?: Nullable<LinesMesh>;
  107579. colors?: Color4[];
  107580. useVertexAlpha?: boolean;
  107581. }, scene?: Nullable<Scene>): LinesMesh;
  107582. /**
  107583. * Creates a dashed line mesh
  107584. * * 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
  107585. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107586. * * The parameter `points` is an array successive Vector3
  107587. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107588. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107589. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107590. * * 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
  107591. * * When updating an instance, remember that only point positions can change, not the number of points
  107592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107593. * @param name defines the name of the mesh
  107594. * @param options defines the options used to create the mesh
  107595. * @param scene defines the hosting scene
  107596. * @returns the dashed line mesh
  107597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107598. */
  107599. static CreateDashedLines(name: string, options: {
  107600. points: Vector3[];
  107601. dashSize?: number;
  107602. gapSize?: number;
  107603. dashNb?: number;
  107604. updatable?: boolean;
  107605. instance?: LinesMesh;
  107606. }, scene?: Nullable<Scene>): LinesMesh;
  107607. /**
  107608. * 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.
  107609. * * 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.
  107610. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107611. * * 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.
  107612. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107613. * * 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
  107614. * * 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
  107615. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107618. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107620. * @param name defines the name of the mesh
  107621. * @param options defines the options used to create the mesh
  107622. * @param scene defines the hosting scene
  107623. * @returns the extruded shape mesh
  107624. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107626. */
  107627. static ExtrudeShape(name: string, options: {
  107628. shape: Vector3[];
  107629. path: Vector3[];
  107630. scale?: number;
  107631. rotation?: number;
  107632. cap?: number;
  107633. updatable?: boolean;
  107634. sideOrientation?: number;
  107635. frontUVs?: Vector4;
  107636. backUVs?: Vector4;
  107637. instance?: Mesh;
  107638. invertUV?: boolean;
  107639. }, scene?: Nullable<Scene>): Mesh;
  107640. /**
  107641. * Creates an custom extruded shape mesh.
  107642. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107643. * * 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.
  107644. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107645. * * 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
  107646. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107647. * * 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
  107648. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107649. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107650. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107651. * * 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
  107652. * * 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
  107653. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107656. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107658. * @param name defines the name of the mesh
  107659. * @param options defines the options used to create the mesh
  107660. * @param scene defines the hosting scene
  107661. * @returns the custom extruded shape mesh
  107662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107665. */
  107666. static ExtrudeShapeCustom(name: string, options: {
  107667. shape: Vector3[];
  107668. path: Vector3[];
  107669. scaleFunction?: any;
  107670. rotationFunction?: any;
  107671. ribbonCloseArray?: boolean;
  107672. ribbonClosePath?: boolean;
  107673. cap?: number;
  107674. updatable?: boolean;
  107675. sideOrientation?: number;
  107676. frontUVs?: Vector4;
  107677. backUVs?: Vector4;
  107678. instance?: Mesh;
  107679. invertUV?: boolean;
  107680. }, scene: Scene): Mesh;
  107681. /**
  107682. * Creates lathe mesh.
  107683. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107684. * * 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
  107685. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107686. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107687. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107688. * * 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
  107689. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107690. * * 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
  107691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107693. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107695. * @param name defines the name of the mesh
  107696. * @param options defines the options used to create the mesh
  107697. * @param scene defines the hosting scene
  107698. * @returns the lathe mesh
  107699. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107700. */
  107701. static CreateLathe(name: string, options: {
  107702. shape: Vector3[];
  107703. radius?: number;
  107704. tessellation?: number;
  107705. clip?: number;
  107706. arc?: number;
  107707. closed?: boolean;
  107708. updatable?: boolean;
  107709. sideOrientation?: number;
  107710. frontUVs?: Vector4;
  107711. backUVs?: Vector4;
  107712. cap?: number;
  107713. invertUV?: boolean;
  107714. }, scene: Scene): Mesh;
  107715. /**
  107716. * Creates a plane mesh
  107717. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107718. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107719. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107720. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107721. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107723. * @param name defines the name of the mesh
  107724. * @param options defines the options used to create the mesh
  107725. * @param scene defines the hosting scene
  107726. * @returns the plane mesh
  107727. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107728. */
  107729. static CreatePlane(name: string, options: {
  107730. size?: number;
  107731. width?: number;
  107732. height?: number;
  107733. sideOrientation?: number;
  107734. frontUVs?: Vector4;
  107735. backUVs?: Vector4;
  107736. updatable?: boolean;
  107737. sourcePlane?: Plane;
  107738. }, scene: Scene): Mesh;
  107739. /**
  107740. * Creates a ground mesh
  107741. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107742. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107744. * @param name defines the name of the mesh
  107745. * @param options defines the options used to create the mesh
  107746. * @param scene defines the hosting scene
  107747. * @returns the ground mesh
  107748. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107749. */
  107750. static CreateGround(name: string, options: {
  107751. width?: number;
  107752. height?: number;
  107753. subdivisions?: number;
  107754. subdivisionsX?: number;
  107755. subdivisionsY?: number;
  107756. updatable?: boolean;
  107757. }, scene: any): Mesh;
  107758. /**
  107759. * Creates a tiled ground mesh
  107760. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107761. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107762. * * 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
  107763. * * 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
  107764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107765. * @param name defines the name of the mesh
  107766. * @param options defines the options used to create the mesh
  107767. * @param scene defines the hosting scene
  107768. * @returns the tiled ground mesh
  107769. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107770. */
  107771. static CreateTiledGround(name: string, options: {
  107772. xmin: number;
  107773. zmin: number;
  107774. xmax: number;
  107775. zmax: number;
  107776. subdivisions?: {
  107777. w: number;
  107778. h: number;
  107779. };
  107780. precision?: {
  107781. w: number;
  107782. h: number;
  107783. };
  107784. updatable?: boolean;
  107785. }, scene: Scene): Mesh;
  107786. /**
  107787. * Creates a ground mesh from a height map
  107788. * * The parameter `url` sets the URL of the height map image resource.
  107789. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107790. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107791. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107792. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107793. * * 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.
  107794. * * 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).
  107795. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107797. * @param name defines the name of the mesh
  107798. * @param url defines the url to the height map
  107799. * @param options defines the options used to create the mesh
  107800. * @param scene defines the hosting scene
  107801. * @returns the ground mesh
  107802. * @see https://doc.babylonjs.com/babylon101/height_map
  107803. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107804. */
  107805. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107806. width?: number;
  107807. height?: number;
  107808. subdivisions?: number;
  107809. minHeight?: number;
  107810. maxHeight?: number;
  107811. colorFilter?: Color3;
  107812. alphaFilter?: number;
  107813. updatable?: boolean;
  107814. onReady?: (mesh: GroundMesh) => void;
  107815. }, scene: Scene): GroundMesh;
  107816. /**
  107817. * Creates a polygon mesh
  107818. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107819. * * 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
  107820. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107823. * * Remember you can only change the shape positions, not their number when updating a polygon
  107824. * @param name defines the name of the mesh
  107825. * @param options defines the options used to create the mesh
  107826. * @param scene defines the hosting scene
  107827. * @param earcutInjection can be used to inject your own earcut reference
  107828. * @returns the polygon mesh
  107829. */
  107830. static CreatePolygon(name: string, options: {
  107831. shape: Vector3[];
  107832. holes?: Vector3[][];
  107833. depth?: number;
  107834. faceUV?: Vector4[];
  107835. faceColors?: Color4[];
  107836. updatable?: boolean;
  107837. sideOrientation?: number;
  107838. frontUVs?: Vector4;
  107839. backUVs?: Vector4;
  107840. }, scene: Scene, earcutInjection?: any): Mesh;
  107841. /**
  107842. * Creates an extruded polygon mesh, with depth in the Y direction.
  107843. * * 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)
  107844. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107845. * @param name defines the name of the mesh
  107846. * @param options defines the options used to create the mesh
  107847. * @param scene defines the hosting scene
  107848. * @param earcutInjection can be used to inject your own earcut reference
  107849. * @returns the polygon mesh
  107850. */
  107851. static ExtrudePolygon(name: string, options: {
  107852. shape: Vector3[];
  107853. holes?: Vector3[][];
  107854. depth?: number;
  107855. faceUV?: Vector4[];
  107856. faceColors?: Color4[];
  107857. updatable?: boolean;
  107858. sideOrientation?: number;
  107859. frontUVs?: Vector4;
  107860. backUVs?: Vector4;
  107861. }, scene: Scene, earcutInjection?: any): Mesh;
  107862. /**
  107863. * Creates a tube mesh.
  107864. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107865. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107866. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107867. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107868. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107869. * * 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)
  107870. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107871. * * 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
  107872. * * 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
  107873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107875. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107877. * @param name defines the name of the mesh
  107878. * @param options defines the options used to create the mesh
  107879. * @param scene defines the hosting scene
  107880. * @returns the tube mesh
  107881. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107882. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107883. */
  107884. static CreateTube(name: string, options: {
  107885. path: Vector3[];
  107886. radius?: number;
  107887. tessellation?: number;
  107888. radiusFunction?: {
  107889. (i: number, distance: number): number;
  107890. };
  107891. cap?: number;
  107892. arc?: number;
  107893. updatable?: boolean;
  107894. sideOrientation?: number;
  107895. frontUVs?: Vector4;
  107896. backUVs?: Vector4;
  107897. instance?: Mesh;
  107898. invertUV?: boolean;
  107899. }, scene: Scene): Mesh;
  107900. /**
  107901. * Creates a polyhedron mesh
  107902. * * 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
  107903. * * The parameter `size` (positive float, default 1) sets the polygon size
  107904. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107905. * * 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`
  107906. * * 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
  107907. * * 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)`)
  107908. * * 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
  107909. * * 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
  107910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107913. * @param name defines the name of the mesh
  107914. * @param options defines the options used to create the mesh
  107915. * @param scene defines the hosting scene
  107916. * @returns the polyhedron mesh
  107917. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107918. */
  107919. static CreatePolyhedron(name: string, options: {
  107920. type?: number;
  107921. size?: number;
  107922. sizeX?: number;
  107923. sizeY?: number;
  107924. sizeZ?: number;
  107925. custom?: any;
  107926. faceUV?: Vector4[];
  107927. faceColors?: Color4[];
  107928. flat?: boolean;
  107929. updatable?: boolean;
  107930. sideOrientation?: number;
  107931. frontUVs?: Vector4;
  107932. backUVs?: Vector4;
  107933. }, scene: Scene): Mesh;
  107934. /**
  107935. * Creates a decal mesh.
  107936. * 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
  107937. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107938. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107939. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107940. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107941. * @param name defines the name of the mesh
  107942. * @param sourceMesh defines the mesh where the decal must be applied
  107943. * @param options defines the options used to create the mesh
  107944. * @param scene defines the hosting scene
  107945. * @returns the decal mesh
  107946. * @see https://doc.babylonjs.com/how_to/decals
  107947. */
  107948. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107949. position?: Vector3;
  107950. normal?: Vector3;
  107951. size?: Vector3;
  107952. angle?: number;
  107953. }): Mesh;
  107954. }
  107955. }
  107956. declare module BABYLON {
  107957. /**
  107958. * A simplifier interface for future simplification implementations
  107959. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107960. */
  107961. export interface ISimplifier {
  107962. /**
  107963. * Simplification of a given mesh according to the given settings.
  107964. * Since this requires computation, it is assumed that the function runs async.
  107965. * @param settings The settings of the simplification, including quality and distance
  107966. * @param successCallback A callback that will be called after the mesh was simplified.
  107967. * @param errorCallback in case of an error, this callback will be called. optional.
  107968. */
  107969. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  107970. }
  107971. /**
  107972. * Expected simplification settings.
  107973. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  107974. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107975. */
  107976. export interface ISimplificationSettings {
  107977. /**
  107978. * Gets or sets the expected quality
  107979. */
  107980. quality: number;
  107981. /**
  107982. * Gets or sets the distance when this optimized version should be used
  107983. */
  107984. distance: number;
  107985. /**
  107986. * Gets an already optimized mesh
  107987. */
  107988. optimizeMesh?: boolean;
  107989. }
  107990. /**
  107991. * Class used to specify simplification options
  107992. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107993. */
  107994. export class SimplificationSettings implements ISimplificationSettings {
  107995. /** expected quality */
  107996. quality: number;
  107997. /** distance when this optimized version should be used */
  107998. distance: number;
  107999. /** already optimized mesh */
  108000. optimizeMesh?: boolean | undefined;
  108001. /**
  108002. * Creates a SimplificationSettings
  108003. * @param quality expected quality
  108004. * @param distance distance when this optimized version should be used
  108005. * @param optimizeMesh already optimized mesh
  108006. */
  108007. constructor(
  108008. /** expected quality */
  108009. quality: number,
  108010. /** distance when this optimized version should be used */
  108011. distance: number,
  108012. /** already optimized mesh */
  108013. optimizeMesh?: boolean | undefined);
  108014. }
  108015. /**
  108016. * Interface used to define a simplification task
  108017. */
  108018. export interface ISimplificationTask {
  108019. /**
  108020. * Array of settings
  108021. */
  108022. settings: Array<ISimplificationSettings>;
  108023. /**
  108024. * Simplification type
  108025. */
  108026. simplificationType: SimplificationType;
  108027. /**
  108028. * Mesh to simplify
  108029. */
  108030. mesh: Mesh;
  108031. /**
  108032. * Callback called on success
  108033. */
  108034. successCallback?: () => void;
  108035. /**
  108036. * Defines if parallel processing can be used
  108037. */
  108038. parallelProcessing: boolean;
  108039. }
  108040. /**
  108041. * Queue used to order the simplification tasks
  108042. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108043. */
  108044. export class SimplificationQueue {
  108045. private _simplificationArray;
  108046. /**
  108047. * Gets a boolean indicating that the process is still running
  108048. */
  108049. running: boolean;
  108050. /**
  108051. * Creates a new queue
  108052. */
  108053. constructor();
  108054. /**
  108055. * Adds a new simplification task
  108056. * @param task defines a task to add
  108057. */
  108058. addTask(task: ISimplificationTask): void;
  108059. /**
  108060. * Execute next task
  108061. */
  108062. executeNext(): void;
  108063. /**
  108064. * Execute a simplification task
  108065. * @param task defines the task to run
  108066. */
  108067. runSimplification(task: ISimplificationTask): void;
  108068. private getSimplifier;
  108069. }
  108070. /**
  108071. * The implemented types of simplification
  108072. * At the moment only Quadratic Error Decimation is implemented
  108073. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108074. */
  108075. export enum SimplificationType {
  108076. /** Quadratic error decimation */
  108077. QUADRATIC = 0
  108078. }
  108079. }
  108080. declare module BABYLON {
  108081. interface Scene {
  108082. /** @hidden (Backing field) */
  108083. _simplificationQueue: SimplificationQueue;
  108084. /**
  108085. * Gets or sets the simplification queue attached to the scene
  108086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108087. */
  108088. simplificationQueue: SimplificationQueue;
  108089. }
  108090. interface Mesh {
  108091. /**
  108092. * Simplify the mesh according to the given array of settings.
  108093. * Function will return immediately and will simplify async
  108094. * @param settings a collection of simplification settings
  108095. * @param parallelProcessing should all levels calculate parallel or one after the other
  108096. * @param simplificationType the type of simplification to run
  108097. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  108098. * @returns the current mesh
  108099. */
  108100. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  108101. }
  108102. /**
  108103. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  108104. * created in a scene
  108105. */
  108106. export class SimplicationQueueSceneComponent implements ISceneComponent {
  108107. /**
  108108. * The component name helpfull to identify the component in the list of scene components.
  108109. */
  108110. readonly name: string;
  108111. /**
  108112. * The scene the component belongs to.
  108113. */
  108114. scene: Scene;
  108115. /**
  108116. * Creates a new instance of the component for the given scene
  108117. * @param scene Defines the scene to register the component in
  108118. */
  108119. constructor(scene: Scene);
  108120. /**
  108121. * Registers the component in a given scene
  108122. */
  108123. register(): void;
  108124. /**
  108125. * Rebuilds the elements related to this component in case of
  108126. * context lost for instance.
  108127. */
  108128. rebuild(): void;
  108129. /**
  108130. * Disposes the component and the associated ressources
  108131. */
  108132. dispose(): void;
  108133. private _beforeCameraUpdate;
  108134. }
  108135. }
  108136. declare module BABYLON {
  108137. /**
  108138. * Class used to enable access to IndexedDB
  108139. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108140. */
  108141. export class Database implements IOfflineProvider {
  108142. private _callbackManifestChecked;
  108143. private _currentSceneUrl;
  108144. private _db;
  108145. private _enableSceneOffline;
  108146. private _enableTexturesOffline;
  108147. private _manifestVersionFound;
  108148. private _mustUpdateRessources;
  108149. private _hasReachedQuota;
  108150. private _isSupported;
  108151. private _idbFactory;
  108152. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  108153. private static IsUASupportingBlobStorage;
  108154. /**
  108155. * Gets a boolean indicating if Database storate is enabled (off by default)
  108156. */
  108157. static IDBStorageEnabled: boolean;
  108158. /**
  108159. * Gets a boolean indicating if scene must be saved in the database
  108160. */
  108161. readonly enableSceneOffline: boolean;
  108162. /**
  108163. * Gets a boolean indicating if textures must be saved in the database
  108164. */
  108165. readonly enableTexturesOffline: boolean;
  108166. /**
  108167. * Creates a new Database
  108168. * @param urlToScene defines the url to load the scene
  108169. * @param callbackManifestChecked defines the callback to use when manifest is checked
  108170. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  108171. */
  108172. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  108173. private static _ParseURL;
  108174. private static _ReturnFullUrlLocation;
  108175. private _checkManifestFile;
  108176. /**
  108177. * Open the database and make it available
  108178. * @param successCallback defines the callback to call on success
  108179. * @param errorCallback defines the callback to call on error
  108180. */
  108181. open(successCallback: () => void, errorCallback: () => void): void;
  108182. /**
  108183. * Loads an image from the database
  108184. * @param url defines the url to load from
  108185. * @param image defines the target DOM image
  108186. */
  108187. loadImage(url: string, image: HTMLImageElement): void;
  108188. private _loadImageFromDBAsync;
  108189. private _saveImageIntoDBAsync;
  108190. private _checkVersionFromDB;
  108191. private _loadVersionFromDBAsync;
  108192. private _saveVersionIntoDBAsync;
  108193. /**
  108194. * Loads a file from database
  108195. * @param url defines the URL to load from
  108196. * @param sceneLoaded defines a callback to call on success
  108197. * @param progressCallBack defines a callback to call when progress changed
  108198. * @param errorCallback defines a callback to call on error
  108199. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  108200. */
  108201. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  108202. private _loadFileAsync;
  108203. private _saveFileAsync;
  108204. /**
  108205. * Validates if xhr data is correct
  108206. * @param xhr defines the request to validate
  108207. * @param dataType defines the expected data type
  108208. * @returns true if data is correct
  108209. */
  108210. private static _ValidateXHRData;
  108211. }
  108212. }
  108213. declare module BABYLON {
  108214. /** @hidden */
  108215. export var gpuUpdateParticlesPixelShader: {
  108216. name: string;
  108217. shader: string;
  108218. };
  108219. }
  108220. declare module BABYLON {
  108221. /** @hidden */
  108222. export var gpuUpdateParticlesVertexShader: {
  108223. name: string;
  108224. shader: string;
  108225. };
  108226. }
  108227. declare module BABYLON {
  108228. /** @hidden */
  108229. export var clipPlaneFragmentDeclaration2: {
  108230. name: string;
  108231. shader: string;
  108232. };
  108233. }
  108234. declare module BABYLON {
  108235. /** @hidden */
  108236. export var gpuRenderParticlesPixelShader: {
  108237. name: string;
  108238. shader: string;
  108239. };
  108240. }
  108241. declare module BABYLON {
  108242. /** @hidden */
  108243. export var clipPlaneVertexDeclaration2: {
  108244. name: string;
  108245. shader: string;
  108246. };
  108247. }
  108248. declare module BABYLON {
  108249. /** @hidden */
  108250. export var gpuRenderParticlesVertexShader: {
  108251. name: string;
  108252. shader: string;
  108253. };
  108254. }
  108255. declare module BABYLON {
  108256. /**
  108257. * This represents a GPU particle system in Babylon
  108258. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108259. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108260. */
  108261. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108262. /**
  108263. * The layer mask we are rendering the particles through.
  108264. */
  108265. layerMask: number;
  108266. private _capacity;
  108267. private _activeCount;
  108268. private _currentActiveCount;
  108269. private _accumulatedCount;
  108270. private _renderEffect;
  108271. private _updateEffect;
  108272. private _buffer0;
  108273. private _buffer1;
  108274. private _spriteBuffer;
  108275. private _updateVAO;
  108276. private _renderVAO;
  108277. private _targetIndex;
  108278. private _sourceBuffer;
  108279. private _targetBuffer;
  108280. private _engine;
  108281. private _currentRenderId;
  108282. private _started;
  108283. private _stopped;
  108284. private _timeDelta;
  108285. private _randomTexture;
  108286. private _randomTexture2;
  108287. private _attributesStrideSize;
  108288. private _updateEffectOptions;
  108289. private _randomTextureSize;
  108290. private _actualFrame;
  108291. private readonly _rawTextureWidth;
  108292. /**
  108293. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108294. */
  108295. static readonly IsSupported: boolean;
  108296. /**
  108297. * An event triggered when the system is disposed.
  108298. */
  108299. onDisposeObservable: Observable<GPUParticleSystem>;
  108300. /**
  108301. * Gets the maximum number of particles active at the same time.
  108302. * @returns The max number of active particles.
  108303. */
  108304. getCapacity(): number;
  108305. /**
  108306. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108307. * to override the particles.
  108308. */
  108309. forceDepthWrite: boolean;
  108310. /**
  108311. * Gets or set the number of active particles
  108312. */
  108313. activeParticleCount: number;
  108314. private _preWarmDone;
  108315. /**
  108316. * Is this system ready to be used/rendered
  108317. * @return true if the system is ready
  108318. */
  108319. isReady(): boolean;
  108320. /**
  108321. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108322. * @returns True if it has been started, otherwise false.
  108323. */
  108324. isStarted(): boolean;
  108325. /**
  108326. * Starts the particle system and begins to emit
  108327. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108328. */
  108329. start(delay?: number): void;
  108330. /**
  108331. * Stops the particle system.
  108332. */
  108333. stop(): void;
  108334. /**
  108335. * Remove all active particles
  108336. */
  108337. reset(): void;
  108338. /**
  108339. * Returns the string "GPUParticleSystem"
  108340. * @returns a string containing the class name
  108341. */
  108342. getClassName(): string;
  108343. private _colorGradientsTexture;
  108344. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108345. /**
  108346. * Adds a new color gradient
  108347. * @param gradient defines the gradient to use (between 0 and 1)
  108348. * @param color1 defines the color to affect to the specified gradient
  108349. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108350. * @returns the current particle system
  108351. */
  108352. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108353. /**
  108354. * Remove a specific color gradient
  108355. * @param gradient defines the gradient to remove
  108356. * @returns the current particle system
  108357. */
  108358. removeColorGradient(gradient: number): GPUParticleSystem;
  108359. private _angularSpeedGradientsTexture;
  108360. private _sizeGradientsTexture;
  108361. private _velocityGradientsTexture;
  108362. private _limitVelocityGradientsTexture;
  108363. private _dragGradientsTexture;
  108364. private _addFactorGradient;
  108365. /**
  108366. * Adds a new size gradient
  108367. * @param gradient defines the gradient to use (between 0 and 1)
  108368. * @param factor defines the size factor to affect to the specified gradient
  108369. * @returns the current particle system
  108370. */
  108371. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108372. /**
  108373. * Remove a specific size gradient
  108374. * @param gradient defines the gradient to remove
  108375. * @returns the current particle system
  108376. */
  108377. removeSizeGradient(gradient: number): GPUParticleSystem;
  108378. /**
  108379. * Adds a new angular speed gradient
  108380. * @param gradient defines the gradient to use (between 0 and 1)
  108381. * @param factor defines the angular speed to affect to the specified gradient
  108382. * @returns the current particle system
  108383. */
  108384. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108385. /**
  108386. * Remove a specific angular speed gradient
  108387. * @param gradient defines the gradient to remove
  108388. * @returns the current particle system
  108389. */
  108390. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108391. /**
  108392. * Adds a new velocity gradient
  108393. * @param gradient defines the gradient to use (between 0 and 1)
  108394. * @param factor defines the velocity to affect to the specified gradient
  108395. * @returns the current particle system
  108396. */
  108397. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108398. /**
  108399. * Remove a specific velocity gradient
  108400. * @param gradient defines the gradient to remove
  108401. * @returns the current particle system
  108402. */
  108403. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108404. /**
  108405. * Adds a new limit velocity gradient
  108406. * @param gradient defines the gradient to use (between 0 and 1)
  108407. * @param factor defines the limit velocity value to affect to the specified gradient
  108408. * @returns the current particle system
  108409. */
  108410. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108411. /**
  108412. * Remove a specific limit velocity gradient
  108413. * @param gradient defines the gradient to remove
  108414. * @returns the current particle system
  108415. */
  108416. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108417. /**
  108418. * Adds a new drag gradient
  108419. * @param gradient defines the gradient to use (between 0 and 1)
  108420. * @param factor defines the drag value to affect to the specified gradient
  108421. * @returns the current particle system
  108422. */
  108423. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108424. /**
  108425. * Remove a specific drag gradient
  108426. * @param gradient defines the gradient to remove
  108427. * @returns the current particle system
  108428. */
  108429. removeDragGradient(gradient: number): GPUParticleSystem;
  108430. /**
  108431. * Not supported by GPUParticleSystem
  108432. * @param gradient defines the gradient to use (between 0 and 1)
  108433. * @param factor defines the emit rate value to affect to the specified gradient
  108434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108435. * @returns the current particle system
  108436. */
  108437. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108438. /**
  108439. * Not supported by GPUParticleSystem
  108440. * @param gradient defines the gradient to remove
  108441. * @returns the current particle system
  108442. */
  108443. removeEmitRateGradient(gradient: number): IParticleSystem;
  108444. /**
  108445. * Not supported by GPUParticleSystem
  108446. * @param gradient defines the gradient to use (between 0 and 1)
  108447. * @param factor defines the start size value to affect to the specified gradient
  108448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108449. * @returns the current particle system
  108450. */
  108451. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108452. /**
  108453. * Not supported by GPUParticleSystem
  108454. * @param gradient defines the gradient to remove
  108455. * @returns the current particle system
  108456. */
  108457. removeStartSizeGradient(gradient: number): IParticleSystem;
  108458. /**
  108459. * Not supported by GPUParticleSystem
  108460. * @param gradient defines the gradient to use (between 0 and 1)
  108461. * @param min defines the color remap minimal range
  108462. * @param max defines the color remap maximal range
  108463. * @returns the current particle system
  108464. */
  108465. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108466. /**
  108467. * Not supported by GPUParticleSystem
  108468. * @param gradient defines the gradient to remove
  108469. * @returns the current particle system
  108470. */
  108471. removeColorRemapGradient(): IParticleSystem;
  108472. /**
  108473. * Not supported by GPUParticleSystem
  108474. * @param gradient defines the gradient to use (between 0 and 1)
  108475. * @param min defines the alpha remap minimal range
  108476. * @param max defines the alpha remap maximal range
  108477. * @returns the current particle system
  108478. */
  108479. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108480. /**
  108481. * Not supported by GPUParticleSystem
  108482. * @param gradient defines the gradient to remove
  108483. * @returns the current particle system
  108484. */
  108485. removeAlphaRemapGradient(): IParticleSystem;
  108486. /**
  108487. * Not supported by GPUParticleSystem
  108488. * @param gradient defines the gradient to use (between 0 and 1)
  108489. * @param color defines the color to affect to the specified gradient
  108490. * @returns the current particle system
  108491. */
  108492. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108493. /**
  108494. * Not supported by GPUParticleSystem
  108495. * @param gradient defines the gradient to remove
  108496. * @returns the current particle system
  108497. */
  108498. removeRampGradient(): IParticleSystem;
  108499. /**
  108500. * Not supported by GPUParticleSystem
  108501. * @returns the list of ramp gradients
  108502. */
  108503. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108504. /**
  108505. * Not supported by GPUParticleSystem
  108506. * Gets or sets a boolean indicating that ramp gradients must be used
  108507. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108508. */
  108509. useRampGradients: boolean;
  108510. /**
  108511. * Not supported by GPUParticleSystem
  108512. * @param gradient defines the gradient to use (between 0 and 1)
  108513. * @param factor defines the life time factor to affect to the specified gradient
  108514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108515. * @returns the current particle system
  108516. */
  108517. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108518. /**
  108519. * Not supported by GPUParticleSystem
  108520. * @param gradient defines the gradient to remove
  108521. * @returns the current particle system
  108522. */
  108523. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108524. /**
  108525. * Instantiates a GPU particle system.
  108526. * 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.
  108527. * @param name The name of the particle system
  108528. * @param options The options used to create the system
  108529. * @param scene The scene the particle system belongs to
  108530. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108531. */
  108532. constructor(name: string, options: Partial<{
  108533. capacity: number;
  108534. randomTextureSize: number;
  108535. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108536. protected _reset(): void;
  108537. private _createUpdateVAO;
  108538. private _createRenderVAO;
  108539. private _initialize;
  108540. /** @hidden */
  108541. _recreateUpdateEffect(): void;
  108542. /** @hidden */
  108543. _recreateRenderEffect(): void;
  108544. /**
  108545. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108546. * @param preWarm defines if we are in the pre-warmimg phase
  108547. */
  108548. animate(preWarm?: boolean): void;
  108549. private _createFactorGradientTexture;
  108550. private _createSizeGradientTexture;
  108551. private _createAngularSpeedGradientTexture;
  108552. private _createVelocityGradientTexture;
  108553. private _createLimitVelocityGradientTexture;
  108554. private _createDragGradientTexture;
  108555. private _createColorGradientTexture;
  108556. /**
  108557. * Renders the particle system in its current state
  108558. * @param preWarm defines if the system should only update the particles but not render them
  108559. * @returns the current number of particles
  108560. */
  108561. render(preWarm?: boolean): number;
  108562. /**
  108563. * Rebuilds the particle system
  108564. */
  108565. rebuild(): void;
  108566. private _releaseBuffers;
  108567. private _releaseVAOs;
  108568. /**
  108569. * Disposes the particle system and free the associated resources
  108570. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108571. */
  108572. dispose(disposeTexture?: boolean): void;
  108573. /**
  108574. * Clones the particle system.
  108575. * @param name The name of the cloned object
  108576. * @param newEmitter The new emitter to use
  108577. * @returns the cloned particle system
  108578. */
  108579. clone(name: string, newEmitter: any): GPUParticleSystem;
  108580. /**
  108581. * Serializes the particle system to a JSON object.
  108582. * @returns the JSON object
  108583. */
  108584. serialize(): any;
  108585. /**
  108586. * Parses a JSON object to create a GPU particle system.
  108587. * @param parsedParticleSystem The JSON object to parse
  108588. * @param scene The scene to create the particle system in
  108589. * @param rootUrl The root url to use to load external dependencies like texture
  108590. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108591. * @returns the parsed GPU particle system
  108592. */
  108593. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108594. }
  108595. }
  108596. declare module BABYLON {
  108597. /**
  108598. * Represents a set of particle systems working together to create a specific effect
  108599. */
  108600. export class ParticleSystemSet implements IDisposable {
  108601. private _emitterCreationOptions;
  108602. private _emitterNode;
  108603. /**
  108604. * Gets the particle system list
  108605. */
  108606. systems: IParticleSystem[];
  108607. /**
  108608. * Gets the emitter node used with this set
  108609. */
  108610. readonly emitterNode: Nullable<TransformNode>;
  108611. /**
  108612. * Creates a new emitter mesh as a sphere
  108613. * @param options defines the options used to create the sphere
  108614. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108615. * @param scene defines the hosting scene
  108616. */
  108617. setEmitterAsSphere(options: {
  108618. diameter: number;
  108619. segments: number;
  108620. color: Color3;
  108621. }, renderingGroupId: number, scene: Scene): void;
  108622. /**
  108623. * Starts all particle systems of the set
  108624. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108625. */
  108626. start(emitter?: AbstractMesh): void;
  108627. /**
  108628. * Release all associated resources
  108629. */
  108630. dispose(): void;
  108631. /**
  108632. * Serialize the set into a JSON compatible object
  108633. * @returns a JSON compatible representation of the set
  108634. */
  108635. serialize(): any;
  108636. /**
  108637. * Parse a new ParticleSystemSet from a serialized source
  108638. * @param data defines a JSON compatible representation of the set
  108639. * @param scene defines the hosting scene
  108640. * @param gpu defines if we want GPU particles or CPU particles
  108641. * @returns a new ParticleSystemSet
  108642. */
  108643. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108644. }
  108645. }
  108646. declare module BABYLON {
  108647. /**
  108648. * This class is made for on one-liner static method to help creating particle system set.
  108649. */
  108650. export class ParticleHelper {
  108651. /**
  108652. * Gets or sets base Assets URL
  108653. */
  108654. static BaseAssetsUrl: string;
  108655. /**
  108656. * Create a default particle system that you can tweak
  108657. * @param emitter defines the emitter to use
  108658. * @param capacity defines the system capacity (default is 500 particles)
  108659. * @param scene defines the hosting scene
  108660. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108661. * @returns the new Particle system
  108662. */
  108663. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108664. /**
  108665. * This is the main static method (one-liner) of this helper to create different particle systems
  108666. * @param type This string represents the type to the particle system to create
  108667. * @param scene The scene where the particle system should live
  108668. * @param gpu If the system will use gpu
  108669. * @returns the ParticleSystemSet created
  108670. */
  108671. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108672. /**
  108673. * Static function used to export a particle system to a ParticleSystemSet variable.
  108674. * Please note that the emitter shape is not exported
  108675. * @param systems defines the particle systems to export
  108676. * @returns the created particle system set
  108677. */
  108678. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108679. }
  108680. }
  108681. declare module BABYLON {
  108682. interface Engine {
  108683. /**
  108684. * Create an effect to use with particle systems.
  108685. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108686. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108687. * @param uniformsNames defines a list of attribute names
  108688. * @param samplers defines an array of string used to represent textures
  108689. * @param defines defines the string containing the defines to use to compile the shaders
  108690. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108691. * @param onCompiled defines a function to call when the effect creation is successful
  108692. * @param onError defines a function to call when the effect creation has failed
  108693. * @returns the new Effect
  108694. */
  108695. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108696. }
  108697. interface Mesh {
  108698. /**
  108699. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108700. * @returns an array of IParticleSystem
  108701. */
  108702. getEmittedParticleSystems(): IParticleSystem[];
  108703. /**
  108704. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108705. * @returns an array of IParticleSystem
  108706. */
  108707. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108708. }
  108709. /**
  108710. * @hidden
  108711. */
  108712. export var _IDoNeedToBeInTheBuild: number;
  108713. }
  108714. declare module BABYLON {
  108715. interface Scene {
  108716. /** @hidden (Backing field) */
  108717. _physicsEngine: Nullable<IPhysicsEngine>;
  108718. /**
  108719. * Gets the current physics engine
  108720. * @returns a IPhysicsEngine or null if none attached
  108721. */
  108722. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108723. /**
  108724. * Enables physics to the current scene
  108725. * @param gravity defines the scene's gravity for the physics engine
  108726. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108727. * @return a boolean indicating if the physics engine was initialized
  108728. */
  108729. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108730. /**
  108731. * Disables and disposes the physics engine associated with the scene
  108732. */
  108733. disablePhysicsEngine(): void;
  108734. /**
  108735. * Gets a boolean indicating if there is an active physics engine
  108736. * @returns a boolean indicating if there is an active physics engine
  108737. */
  108738. isPhysicsEnabled(): boolean;
  108739. /**
  108740. * Deletes a physics compound impostor
  108741. * @param compound defines the compound to delete
  108742. */
  108743. deleteCompoundImpostor(compound: any): void;
  108744. /**
  108745. * An event triggered when physic simulation is about to be run
  108746. */
  108747. onBeforePhysicsObservable: Observable<Scene>;
  108748. /**
  108749. * An event triggered when physic simulation has been done
  108750. */
  108751. onAfterPhysicsObservable: Observable<Scene>;
  108752. }
  108753. interface AbstractMesh {
  108754. /** @hidden */
  108755. _physicsImpostor: Nullable<PhysicsImpostor>;
  108756. /**
  108757. * Gets or sets impostor used for physic simulation
  108758. * @see http://doc.babylonjs.com/features/physics_engine
  108759. */
  108760. physicsImpostor: Nullable<PhysicsImpostor>;
  108761. /**
  108762. * Gets the current physics impostor
  108763. * @see http://doc.babylonjs.com/features/physics_engine
  108764. * @returns a physics impostor or null
  108765. */
  108766. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  108767. /** Apply a physic impulse to the mesh
  108768. * @param force defines the force to apply
  108769. * @param contactPoint defines where to apply the force
  108770. * @returns the current mesh
  108771. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108772. */
  108773. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  108774. /**
  108775. * Creates a physic joint between two meshes
  108776. * @param otherMesh defines the other mesh to use
  108777. * @param pivot1 defines the pivot to use on this mesh
  108778. * @param pivot2 defines the pivot to use on the other mesh
  108779. * @param options defines additional options (can be plugin dependent)
  108780. * @returns the current mesh
  108781. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  108782. */
  108783. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  108784. /** @hidden */
  108785. _disposePhysicsObserver: Nullable<Observer<Node>>;
  108786. }
  108787. /**
  108788. * Defines the physics engine scene component responsible to manage a physics engine
  108789. */
  108790. export class PhysicsEngineSceneComponent implements ISceneComponent {
  108791. /**
  108792. * The component name helpful to identify the component in the list of scene components.
  108793. */
  108794. readonly name: string;
  108795. /**
  108796. * The scene the component belongs to.
  108797. */
  108798. scene: Scene;
  108799. /**
  108800. * Creates a new instance of the component for the given scene
  108801. * @param scene Defines the scene to register the component in
  108802. */
  108803. constructor(scene: Scene);
  108804. /**
  108805. * Registers the component in a given scene
  108806. */
  108807. register(): void;
  108808. /**
  108809. * Rebuilds the elements related to this component in case of
  108810. * context lost for instance.
  108811. */
  108812. rebuild(): void;
  108813. /**
  108814. * Disposes the component and the associated ressources
  108815. */
  108816. dispose(): void;
  108817. }
  108818. }
  108819. declare module BABYLON {
  108820. /**
  108821. * A helper for physics simulations
  108822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108823. */
  108824. export class PhysicsHelper {
  108825. private _scene;
  108826. private _physicsEngine;
  108827. /**
  108828. * Initializes the Physics helper
  108829. * @param scene Babylon.js scene
  108830. */
  108831. constructor(scene: Scene);
  108832. /**
  108833. * Applies a radial explosion impulse
  108834. * @param origin the origin of the explosion
  108835. * @param radiusOrEventOptions the radius or the options of radial explosion
  108836. * @param strength the explosion strength
  108837. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108838. * @returns A physics radial explosion event, or null
  108839. */
  108840. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108841. /**
  108842. * Applies a radial explosion force
  108843. * @param origin the origin of the explosion
  108844. * @param radiusOrEventOptions the radius or the options of radial explosion
  108845. * @param strength the explosion strength
  108846. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108847. * @returns A physics radial explosion event, or null
  108848. */
  108849. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108850. /**
  108851. * Creates a gravitational field
  108852. * @param origin the origin of the explosion
  108853. * @param radiusOrEventOptions the radius or the options of radial explosion
  108854. * @param strength the explosion strength
  108855. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108856. * @returns A physics gravitational field event, or null
  108857. */
  108858. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  108859. /**
  108860. * Creates a physics updraft event
  108861. * @param origin the origin of the updraft
  108862. * @param radiusOrEventOptions the radius or the options of the updraft
  108863. * @param strength the strength of the updraft
  108864. * @param height the height of the updraft
  108865. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  108866. * @returns A physics updraft event, or null
  108867. */
  108868. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  108869. /**
  108870. * Creates a physics vortex event
  108871. * @param origin the of the vortex
  108872. * @param radiusOrEventOptions the radius or the options of the vortex
  108873. * @param strength the strength of the vortex
  108874. * @param height the height of the vortex
  108875. * @returns a Physics vortex event, or null
  108876. * A physics vortex event or null
  108877. */
  108878. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  108879. }
  108880. /**
  108881. * Represents a physics radial explosion event
  108882. */
  108883. class PhysicsRadialExplosionEvent {
  108884. private _scene;
  108885. private _options;
  108886. private _sphere;
  108887. private _dataFetched;
  108888. /**
  108889. * Initializes a radial explosioin event
  108890. * @param _scene BabylonJS scene
  108891. * @param _options The options for the vortex event
  108892. */
  108893. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  108894. /**
  108895. * Returns the data related to the radial explosion event (sphere).
  108896. * @returns The radial explosion event data
  108897. */
  108898. getData(): PhysicsRadialExplosionEventData;
  108899. /**
  108900. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  108901. * @param impostor A physics imposter
  108902. * @param origin the origin of the explosion
  108903. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  108904. */
  108905. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  108906. /**
  108907. * Disposes the sphere.
  108908. * @param force Specifies if the sphere should be disposed by force
  108909. */
  108910. dispose(force?: boolean): void;
  108911. /*** Helpers ***/
  108912. private _prepareSphere;
  108913. private _intersectsWithSphere;
  108914. }
  108915. /**
  108916. * Represents a gravitational field event
  108917. */
  108918. class PhysicsGravitationalFieldEvent {
  108919. private _physicsHelper;
  108920. private _scene;
  108921. private _origin;
  108922. private _options;
  108923. private _tickCallback;
  108924. private _sphere;
  108925. private _dataFetched;
  108926. /**
  108927. * Initializes the physics gravitational field event
  108928. * @param _physicsHelper A physics helper
  108929. * @param _scene BabylonJS scene
  108930. * @param _origin The origin position of the gravitational field event
  108931. * @param _options The options for the vortex event
  108932. */
  108933. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  108934. /**
  108935. * Returns the data related to the gravitational field event (sphere).
  108936. * @returns A gravitational field event
  108937. */
  108938. getData(): PhysicsGravitationalFieldEventData;
  108939. /**
  108940. * Enables the gravitational field.
  108941. */
  108942. enable(): void;
  108943. /**
  108944. * Disables the gravitational field.
  108945. */
  108946. disable(): void;
  108947. /**
  108948. * Disposes the sphere.
  108949. * @param force The force to dispose from the gravitational field event
  108950. */
  108951. dispose(force?: boolean): void;
  108952. private _tick;
  108953. }
  108954. /**
  108955. * Represents a physics updraft event
  108956. */
  108957. class PhysicsUpdraftEvent {
  108958. private _scene;
  108959. private _origin;
  108960. private _options;
  108961. private _physicsEngine;
  108962. private _originTop;
  108963. private _originDirection;
  108964. private _tickCallback;
  108965. private _cylinder;
  108966. private _cylinderPosition;
  108967. private _dataFetched;
  108968. /**
  108969. * Initializes the physics updraft event
  108970. * @param _scene BabylonJS scene
  108971. * @param _origin The origin position of the updraft
  108972. * @param _options The options for the updraft event
  108973. */
  108974. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  108975. /**
  108976. * Returns the data related to the updraft event (cylinder).
  108977. * @returns A physics updraft event
  108978. */
  108979. getData(): PhysicsUpdraftEventData;
  108980. /**
  108981. * Enables the updraft.
  108982. */
  108983. enable(): void;
  108984. /**
  108985. * Disables the updraft.
  108986. */
  108987. disable(): void;
  108988. /**
  108989. * Disposes the cylinder.
  108990. * @param force Specifies if the updraft should be disposed by force
  108991. */
  108992. dispose(force?: boolean): void;
  108993. private getImpostorForceAndContactPoint;
  108994. private _tick;
  108995. /*** Helpers ***/
  108996. private _prepareCylinder;
  108997. private _intersectsWithCylinder;
  108998. }
  108999. /**
  109000. * Represents a physics vortex event
  109001. */
  109002. class PhysicsVortexEvent {
  109003. private _scene;
  109004. private _origin;
  109005. private _options;
  109006. private _physicsEngine;
  109007. private _originTop;
  109008. private _tickCallback;
  109009. private _cylinder;
  109010. private _cylinderPosition;
  109011. private _dataFetched;
  109012. /**
  109013. * Initializes the physics vortex event
  109014. * @param _scene The BabylonJS scene
  109015. * @param _origin The origin position of the vortex
  109016. * @param _options The options for the vortex event
  109017. */
  109018. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  109019. /**
  109020. * Returns the data related to the vortex event (cylinder).
  109021. * @returns The physics vortex event data
  109022. */
  109023. getData(): PhysicsVortexEventData;
  109024. /**
  109025. * Enables the vortex.
  109026. */
  109027. enable(): void;
  109028. /**
  109029. * Disables the cortex.
  109030. */
  109031. disable(): void;
  109032. /**
  109033. * Disposes the sphere.
  109034. * @param force
  109035. */
  109036. dispose(force?: boolean): void;
  109037. private getImpostorForceAndContactPoint;
  109038. private _tick;
  109039. /*** Helpers ***/
  109040. private _prepareCylinder;
  109041. private _intersectsWithCylinder;
  109042. }
  109043. /**
  109044. * Options fot the radial explosion event
  109045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109046. */
  109047. export class PhysicsRadialExplosionEventOptions {
  109048. /**
  109049. * The radius of the sphere for the radial explosion.
  109050. */
  109051. radius: number;
  109052. /**
  109053. * The strenth of the explosion.
  109054. */
  109055. strength: number;
  109056. /**
  109057. * The strenght of the force in correspondence to the distance of the affected object
  109058. */
  109059. falloff: PhysicsRadialImpulseFalloff;
  109060. /**
  109061. * Sphere options for the radial explosion.
  109062. */
  109063. sphere: {
  109064. segments: number;
  109065. diameter: number;
  109066. };
  109067. }
  109068. /**
  109069. * Options fot the updraft event
  109070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109071. */
  109072. export class PhysicsUpdraftEventOptions {
  109073. /**
  109074. * The radius of the cylinder for the vortex
  109075. */
  109076. radius: number;
  109077. /**
  109078. * The strenth of the updraft.
  109079. */
  109080. strength: number;
  109081. /**
  109082. * The height of the cylinder for the updraft.
  109083. */
  109084. height: number;
  109085. /**
  109086. * The mode for the the updraft.
  109087. */
  109088. updraftMode: PhysicsUpdraftMode;
  109089. }
  109090. /**
  109091. * Options fot the vortex event
  109092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109093. */
  109094. export class PhysicsVortexEventOptions {
  109095. /**
  109096. * The radius of the cylinder for the vortex
  109097. */
  109098. radius: number;
  109099. /**
  109100. * The strenth of the vortex.
  109101. */
  109102. strength: number;
  109103. /**
  109104. * The height of the cylinder for the vortex.
  109105. */
  109106. height: number;
  109107. /**
  109108. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  109109. */
  109110. centripetalForceThreshold: number;
  109111. /**
  109112. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  109113. */
  109114. centripetalForceMultiplier: number;
  109115. /**
  109116. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  109117. */
  109118. centrifugalForceMultiplier: number;
  109119. /**
  109120. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  109121. */
  109122. updraftForceMultiplier: number;
  109123. }
  109124. /**
  109125. * The strenght of the force in correspondence to the distance of the affected object
  109126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109127. */
  109128. export enum PhysicsRadialImpulseFalloff {
  109129. /** Defines that impulse is constant in strength across it's whole radius */
  109130. Constant = 0,
  109131. /** Defines that impulse gets weaker if it's further from the origin */
  109132. Linear = 1
  109133. }
  109134. /**
  109135. * The strength of the force in correspondence to the distance of the affected object
  109136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109137. */
  109138. export enum PhysicsUpdraftMode {
  109139. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  109140. Center = 0,
  109141. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  109142. Perpendicular = 1
  109143. }
  109144. /**
  109145. * Interface for a physics force and contact point
  109146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109147. */
  109148. export interface PhysicsForceAndContactPoint {
  109149. /**
  109150. * The force applied at the contact point
  109151. */
  109152. force: Vector3;
  109153. /**
  109154. * The contact point
  109155. */
  109156. contactPoint: Vector3;
  109157. }
  109158. /**
  109159. * Interface for radial explosion event data
  109160. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109161. */
  109162. export interface PhysicsRadialExplosionEventData {
  109163. /**
  109164. * A sphere used for the radial explosion event
  109165. */
  109166. sphere: Mesh;
  109167. }
  109168. /**
  109169. * Interface for gravitational field event data
  109170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109171. */
  109172. export interface PhysicsGravitationalFieldEventData {
  109173. /**
  109174. * A sphere mesh used for the gravitational field event
  109175. */
  109176. sphere: Mesh;
  109177. }
  109178. /**
  109179. * Interface for updraft event data
  109180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109181. */
  109182. export interface PhysicsUpdraftEventData {
  109183. /**
  109184. * A cylinder used for the updraft event
  109185. */
  109186. cylinder: Mesh;
  109187. }
  109188. /**
  109189. * Interface for vortex event data
  109190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109191. */
  109192. export interface PhysicsVortexEventData {
  109193. /**
  109194. * A cylinder used for the vortex event
  109195. */
  109196. cylinder: Mesh;
  109197. }
  109198. }
  109199. declare module BABYLON {
  109200. /**
  109201. * AmmoJS Physics plugin
  109202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109203. * @see https://github.com/kripken/ammo.js/
  109204. */
  109205. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  109206. private _useDeltaForWorldStep;
  109207. /**
  109208. * Reference to the Ammo library
  109209. */
  109210. bjsAMMO: any;
  109211. /**
  109212. * Created ammoJS world which physics bodies are added to
  109213. */
  109214. world: any;
  109215. /**
  109216. * Name of the plugin
  109217. */
  109218. name: string;
  109219. private _timeStep;
  109220. private _fixedTimeStep;
  109221. private _maxSteps;
  109222. private _tmpQuaternion;
  109223. private _tmpAmmoTransform;
  109224. private _tmpAmmoQuaternion;
  109225. private _tmpAmmoConcreteContactResultCallback;
  109226. private _collisionConfiguration;
  109227. private _dispatcher;
  109228. private _overlappingPairCache;
  109229. private _solver;
  109230. private _softBodySolver;
  109231. private _tmpAmmoVectorA;
  109232. private _tmpAmmoVectorB;
  109233. private _tmpAmmoVectorC;
  109234. private _tmpAmmoVectorD;
  109235. private _tmpContactCallbackResult;
  109236. private _tmpAmmoVectorRCA;
  109237. private _tmpAmmoVectorRCB;
  109238. private _raycastResult;
  109239. private static readonly DISABLE_COLLISION_FLAG;
  109240. private static readonly KINEMATIC_FLAG;
  109241. private static readonly DISABLE_DEACTIVATION_FLAG;
  109242. /**
  109243. * Initializes the ammoJS plugin
  109244. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109245. * @param ammoInjection can be used to inject your own ammo reference
  109246. */
  109247. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109248. /**
  109249. * Sets the gravity of the physics world (m/(s^2))
  109250. * @param gravity Gravity to set
  109251. */
  109252. setGravity(gravity: Vector3): void;
  109253. /**
  109254. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109255. * @param timeStep timestep to use in seconds
  109256. */
  109257. setTimeStep(timeStep: number): void;
  109258. /**
  109259. * 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)
  109260. * @param fixedTimeStep fixedTimeStep to use in seconds
  109261. */
  109262. setFixedTimeStep(fixedTimeStep: number): void;
  109263. /**
  109264. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109265. * @param maxSteps the maximum number of steps by the physics engine per frame
  109266. */
  109267. setMaxSteps(maxSteps: number): void;
  109268. /**
  109269. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109270. * @returns the current timestep in seconds
  109271. */
  109272. getTimeStep(): number;
  109273. private _isImpostorInContact;
  109274. private _isImpostorPairInContact;
  109275. private _stepSimulation;
  109276. /**
  109277. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109278. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109279. * After the step the babylon meshes are set to the position of the physics imposters
  109280. * @param delta amount of time to step forward
  109281. * @param impostors array of imposters to update before/after the step
  109282. */
  109283. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109284. /**
  109285. * Update babylon mesh to match physics world object
  109286. * @param impostor imposter to match
  109287. */
  109288. private _afterSoftStep;
  109289. /**
  109290. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109291. * @param impostor imposter to match
  109292. */
  109293. private _ropeStep;
  109294. /**
  109295. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  109296. * @param impostor imposter to match
  109297. */
  109298. private _softbodyOrClothStep;
  109299. private _tmpVector;
  109300. private _tmpMatrix;
  109301. /**
  109302. * Applies an impulse on the imposter
  109303. * @param impostor imposter to apply impulse to
  109304. * @param force amount of force to be applied to the imposter
  109305. * @param contactPoint the location to apply the impulse on the imposter
  109306. */
  109307. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109308. /**
  109309. * Applies a force on the imposter
  109310. * @param impostor imposter to apply force
  109311. * @param force amount of force to be applied to the imposter
  109312. * @param contactPoint the location to apply the force on the imposter
  109313. */
  109314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109315. /**
  109316. * Creates a physics body using the plugin
  109317. * @param impostor the imposter to create the physics body on
  109318. */
  109319. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109320. /**
  109321. * Removes the physics body from the imposter and disposes of the body's memory
  109322. * @param impostor imposter to remove the physics body from
  109323. */
  109324. removePhysicsBody(impostor: PhysicsImpostor): void;
  109325. /**
  109326. * Generates a joint
  109327. * @param impostorJoint the imposter joint to create the joint with
  109328. */
  109329. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109330. /**
  109331. * Removes a joint
  109332. * @param impostorJoint the imposter joint to remove the joint from
  109333. */
  109334. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109335. private _addMeshVerts;
  109336. /**
  109337. * Initialise the soft body vertices to match its object's (mesh) vertices
  109338. * Softbody vertices (nodes) are in world space and to match this
  109339. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109340. * @param impostor to create the softbody for
  109341. */
  109342. private _softVertexData;
  109343. /**
  109344. * Create an impostor's soft body
  109345. * @param impostor to create the softbody for
  109346. */
  109347. private _createSoftbody;
  109348. /**
  109349. * Create cloth for an impostor
  109350. * @param impostor to create the softbody for
  109351. */
  109352. private _createCloth;
  109353. /**
  109354. * Create rope for an impostor
  109355. * @param impostor to create the softbody for
  109356. */
  109357. private _createRope;
  109358. private _addHullVerts;
  109359. private _createShape;
  109360. /**
  109361. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109362. * @param impostor imposter containing the physics body and babylon object
  109363. */
  109364. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109365. /**
  109366. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109367. * @param impostor imposter containing the physics body and babylon object
  109368. * @param newPosition new position
  109369. * @param newRotation new rotation
  109370. */
  109371. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109372. /**
  109373. * If this plugin is supported
  109374. * @returns true if its supported
  109375. */
  109376. isSupported(): boolean;
  109377. /**
  109378. * Sets the linear velocity of the physics body
  109379. * @param impostor imposter to set the velocity on
  109380. * @param velocity velocity to set
  109381. */
  109382. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109383. /**
  109384. * Sets the angular velocity of the physics body
  109385. * @param impostor imposter to set the velocity on
  109386. * @param velocity velocity to set
  109387. */
  109388. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109389. /**
  109390. * gets the linear velocity
  109391. * @param impostor imposter to get linear velocity from
  109392. * @returns linear velocity
  109393. */
  109394. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109395. /**
  109396. * gets the angular velocity
  109397. * @param impostor imposter to get angular velocity from
  109398. * @returns angular velocity
  109399. */
  109400. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109401. /**
  109402. * Sets the mass of physics body
  109403. * @param impostor imposter to set the mass on
  109404. * @param mass mass to set
  109405. */
  109406. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109407. /**
  109408. * Gets the mass of the physics body
  109409. * @param impostor imposter to get the mass from
  109410. * @returns mass
  109411. */
  109412. getBodyMass(impostor: PhysicsImpostor): number;
  109413. /**
  109414. * Gets friction of the impostor
  109415. * @param impostor impostor to get friction from
  109416. * @returns friction value
  109417. */
  109418. getBodyFriction(impostor: PhysicsImpostor): number;
  109419. /**
  109420. * Sets friction of the impostor
  109421. * @param impostor impostor to set friction on
  109422. * @param friction friction value
  109423. */
  109424. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109425. /**
  109426. * Gets restitution of the impostor
  109427. * @param impostor impostor to get restitution from
  109428. * @returns restitution value
  109429. */
  109430. getBodyRestitution(impostor: PhysicsImpostor): number;
  109431. /**
  109432. * Sets resitution of the impostor
  109433. * @param impostor impostor to set resitution on
  109434. * @param restitution resitution value
  109435. */
  109436. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109437. /**
  109438. * Gets pressure inside the impostor
  109439. * @param impostor impostor to get pressure from
  109440. * @returns pressure value
  109441. */
  109442. getBodyPressure(impostor: PhysicsImpostor): number;
  109443. /**
  109444. * Sets pressure inside a soft body impostor
  109445. * Cloth and rope must remain 0 pressure
  109446. * @param impostor impostor to set pressure on
  109447. * @param pressure pressure value
  109448. */
  109449. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109450. /**
  109451. * Gets stiffness of the impostor
  109452. * @param impostor impostor to get stiffness from
  109453. * @returns pressure value
  109454. */
  109455. getBodyStiffness(impostor: PhysicsImpostor): number;
  109456. /**
  109457. * Sets stiffness of the impostor
  109458. * @param impostor impostor to set stiffness on
  109459. * @param stiffness stiffness value from 0 to 1
  109460. */
  109461. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109462. /**
  109463. * Gets velocityIterations of the impostor
  109464. * @param impostor impostor to get velocity iterations from
  109465. * @returns velocityIterations value
  109466. */
  109467. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109468. /**
  109469. * Sets velocityIterations of the impostor
  109470. * @param impostor impostor to set velocity iterations on
  109471. * @param velocityIterations velocityIterations value
  109472. */
  109473. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109474. /**
  109475. * Gets positionIterations of the impostor
  109476. * @param impostor impostor to get position iterations from
  109477. * @returns positionIterations value
  109478. */
  109479. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109480. /**
  109481. * Sets positionIterations of the impostor
  109482. * @param impostor impostor to set position on
  109483. * @param positionIterations positionIterations value
  109484. */
  109485. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109486. /**
  109487. * Append an anchor to a cloth object
  109488. * @param impostor is the cloth impostor to add anchor to
  109489. * @param otherImpostor is the rigid impostor to anchor to
  109490. * @param width ratio across width from 0 to 1
  109491. * @param height ratio up height from 0 to 1
  109492. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  109493. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109494. */
  109495. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109496. /**
  109497. * Append an hook to a rope object
  109498. * @param impostor is the rope impostor to add hook to
  109499. * @param otherImpostor is the rigid impostor to hook to
  109500. * @param length ratio along the rope from 0 to 1
  109501. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  109502. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109503. */
  109504. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109505. /**
  109506. * Sleeps the physics body and stops it from being active
  109507. * @param impostor impostor to sleep
  109508. */
  109509. sleepBody(impostor: PhysicsImpostor): void;
  109510. /**
  109511. * Activates the physics body
  109512. * @param impostor impostor to activate
  109513. */
  109514. wakeUpBody(impostor: PhysicsImpostor): void;
  109515. /**
  109516. * Updates the distance parameters of the joint
  109517. * @param joint joint to update
  109518. * @param maxDistance maximum distance of the joint
  109519. * @param minDistance minimum distance of the joint
  109520. */
  109521. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109522. /**
  109523. * Sets a motor on the joint
  109524. * @param joint joint to set motor on
  109525. * @param speed speed of the motor
  109526. * @param maxForce maximum force of the motor
  109527. * @param motorIndex index of the motor
  109528. */
  109529. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109530. /**
  109531. * Sets the motors limit
  109532. * @param joint joint to set limit on
  109533. * @param upperLimit upper limit
  109534. * @param lowerLimit lower limit
  109535. */
  109536. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109537. /**
  109538. * Syncs the position and rotation of a mesh with the impostor
  109539. * @param mesh mesh to sync
  109540. * @param impostor impostor to update the mesh with
  109541. */
  109542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109543. /**
  109544. * Gets the radius of the impostor
  109545. * @param impostor impostor to get radius from
  109546. * @returns the radius
  109547. */
  109548. getRadius(impostor: PhysicsImpostor): number;
  109549. /**
  109550. * Gets the box size of the impostor
  109551. * @param impostor impostor to get box size from
  109552. * @param result the resulting box size
  109553. */
  109554. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109555. /**
  109556. * Disposes of the impostor
  109557. */
  109558. dispose(): void;
  109559. /**
  109560. * Does a raycast in the physics world
  109561. * @param from when should the ray start?
  109562. * @param to when should the ray end?
  109563. * @returns PhysicsRaycastResult
  109564. */
  109565. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109566. }
  109567. }
  109568. declare module BABYLON {
  109569. /** @hidden */
  109570. export var blackAndWhitePixelShader: {
  109571. name: string;
  109572. shader: string;
  109573. };
  109574. }
  109575. declare module BABYLON {
  109576. /**
  109577. * Post process used to render in black and white
  109578. */
  109579. export class BlackAndWhitePostProcess extends PostProcess {
  109580. /**
  109581. * Linear about to convert he result to black and white (default: 1)
  109582. */
  109583. degree: number;
  109584. /**
  109585. * Creates a black and white post process
  109586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109587. * @param name The name of the effect.
  109588. * @param options The required width/height ratio to downsize to before computing the render pass.
  109589. * @param camera The camera to apply the render pass to.
  109590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109591. * @param engine The engine which the post process will be applied. (default: current engine)
  109592. * @param reusable If the post process can be reused on the same frame. (default: false)
  109593. */
  109594. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109595. }
  109596. }
  109597. declare module BABYLON {
  109598. /**
  109599. * This represents a set of one or more post processes in Babylon.
  109600. * A post process can be used to apply a shader to a texture after it is rendered.
  109601. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109602. */
  109603. export class PostProcessRenderEffect {
  109604. private _postProcesses;
  109605. private _getPostProcesses;
  109606. private _singleInstance;
  109607. private _cameras;
  109608. private _indicesForCamera;
  109609. /**
  109610. * Name of the effect
  109611. * @hidden
  109612. */
  109613. _name: string;
  109614. /**
  109615. * Instantiates a post process render effect.
  109616. * A post process can be used to apply a shader to a texture after it is rendered.
  109617. * @param engine The engine the effect is tied to
  109618. * @param name The name of the effect
  109619. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109620. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109621. */
  109622. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109623. /**
  109624. * Checks if all the post processes in the effect are supported.
  109625. */
  109626. readonly isSupported: boolean;
  109627. /**
  109628. * Updates the current state of the effect
  109629. * @hidden
  109630. */
  109631. _update(): void;
  109632. /**
  109633. * Attaches the effect on cameras
  109634. * @param cameras The camera to attach to.
  109635. * @hidden
  109636. */
  109637. _attachCameras(cameras: Camera): void;
  109638. /**
  109639. * Attaches the effect on cameras
  109640. * @param cameras The camera to attach to.
  109641. * @hidden
  109642. */
  109643. _attachCameras(cameras: Camera[]): void;
  109644. /**
  109645. * Detatches the effect on cameras
  109646. * @param cameras The camera to detatch from.
  109647. * @hidden
  109648. */
  109649. _detachCameras(cameras: Camera): void;
  109650. /**
  109651. * Detatches the effect on cameras
  109652. * @param cameras The camera to detatch from.
  109653. * @hidden
  109654. */
  109655. _detachCameras(cameras: Camera[]): void;
  109656. /**
  109657. * Enables the effect on given cameras
  109658. * @param cameras The camera to enable.
  109659. * @hidden
  109660. */
  109661. _enable(cameras: Camera): void;
  109662. /**
  109663. * Enables the effect on given cameras
  109664. * @param cameras The camera to enable.
  109665. * @hidden
  109666. */
  109667. _enable(cameras: Nullable<Camera[]>): void;
  109668. /**
  109669. * Disables the effect on the given cameras
  109670. * @param cameras The camera to disable.
  109671. * @hidden
  109672. */
  109673. _disable(cameras: Camera): void;
  109674. /**
  109675. * Disables the effect on the given cameras
  109676. * @param cameras The camera to disable.
  109677. * @hidden
  109678. */
  109679. _disable(cameras: Nullable<Camera[]>): void;
  109680. /**
  109681. * Gets a list of the post processes contained in the effect.
  109682. * @param camera The camera to get the post processes on.
  109683. * @returns The list of the post processes in the effect.
  109684. */
  109685. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109686. }
  109687. }
  109688. declare module BABYLON {
  109689. /** @hidden */
  109690. export var extractHighlightsPixelShader: {
  109691. name: string;
  109692. shader: string;
  109693. };
  109694. }
  109695. declare module BABYLON {
  109696. /**
  109697. * 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.
  109698. */
  109699. export class ExtractHighlightsPostProcess extends PostProcess {
  109700. /**
  109701. * The luminance threshold, pixels below this value will be set to black.
  109702. */
  109703. threshold: number;
  109704. /** @hidden */
  109705. _exposure: number;
  109706. /**
  109707. * Post process which has the input texture to be used when performing highlight extraction
  109708. * @hidden
  109709. */
  109710. _inputPostProcess: Nullable<PostProcess>;
  109711. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109712. }
  109713. }
  109714. declare module BABYLON {
  109715. /** @hidden */
  109716. export var bloomMergePixelShader: {
  109717. name: string;
  109718. shader: string;
  109719. };
  109720. }
  109721. declare module BABYLON {
  109722. /**
  109723. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109724. */
  109725. export class BloomMergePostProcess extends PostProcess {
  109726. /** Weight of the bloom to be added to the original input. */
  109727. weight: number;
  109728. /**
  109729. * Creates a new instance of @see BloomMergePostProcess
  109730. * @param name The name of the effect.
  109731. * @param originalFromInput Post process which's input will be used for the merge.
  109732. * @param blurred Blurred highlights post process which's output will be used.
  109733. * @param weight Weight of the bloom to be added to the original input.
  109734. * @param options The required width/height ratio to downsize to before computing the render pass.
  109735. * @param camera The camera to apply the render pass to.
  109736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109737. * @param engine The engine which the post process will be applied. (default: current engine)
  109738. * @param reusable If the post process can be reused on the same frame. (default: false)
  109739. * @param textureType Type of textures used when performing the post process. (default: 0)
  109740. * @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)
  109741. */
  109742. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109743. /** Weight of the bloom to be added to the original input. */
  109744. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109745. }
  109746. }
  109747. declare module BABYLON {
  109748. /**
  109749. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  109750. */
  109751. export class BloomEffect extends PostProcessRenderEffect {
  109752. private bloomScale;
  109753. /**
  109754. * @hidden Internal
  109755. */
  109756. _effects: Array<PostProcess>;
  109757. /**
  109758. * @hidden Internal
  109759. */
  109760. _downscale: ExtractHighlightsPostProcess;
  109761. private _blurX;
  109762. private _blurY;
  109763. private _merge;
  109764. /**
  109765. * The luminance threshold to find bright areas of the image to bloom.
  109766. */
  109767. threshold: number;
  109768. /**
  109769. * The strength of the bloom.
  109770. */
  109771. weight: number;
  109772. /**
  109773. * Specifies the size of the bloom blur kernel, relative to the final output size
  109774. */
  109775. kernel: number;
  109776. /**
  109777. * Creates a new instance of @see BloomEffect
  109778. * @param scene The scene the effect belongs to.
  109779. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  109780. * @param bloomKernel The size of the kernel to be used when applying the blur.
  109781. * @param bloomWeight The the strength of bloom.
  109782. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109783. * @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)
  109784. */
  109785. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  109786. /**
  109787. * Disposes each of the internal effects for a given camera.
  109788. * @param camera The camera to dispose the effect on.
  109789. */
  109790. disposeEffects(camera: Camera): void;
  109791. /**
  109792. * @hidden Internal
  109793. */
  109794. _updateEffects(): void;
  109795. /**
  109796. * Internal
  109797. * @returns if all the contained post processes are ready.
  109798. * @hidden
  109799. */
  109800. _isReady(): boolean;
  109801. }
  109802. }
  109803. declare module BABYLON {
  109804. /** @hidden */
  109805. export var chromaticAberrationPixelShader: {
  109806. name: string;
  109807. shader: string;
  109808. };
  109809. }
  109810. declare module BABYLON {
  109811. /**
  109812. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  109813. */
  109814. export class ChromaticAberrationPostProcess extends PostProcess {
  109815. /**
  109816. * The amount of seperation of rgb channels (default: 30)
  109817. */
  109818. aberrationAmount: number;
  109819. /**
  109820. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  109821. */
  109822. radialIntensity: number;
  109823. /**
  109824. * 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))
  109825. */
  109826. direction: Vector2;
  109827. /**
  109828. * 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))
  109829. */
  109830. centerPosition: Vector2;
  109831. /**
  109832. * Creates a new instance ChromaticAberrationPostProcess
  109833. * @param name The name of the effect.
  109834. * @param screenWidth The width of the screen to apply the effect on.
  109835. * @param screenHeight The height of the screen to apply the effect on.
  109836. * @param options The required width/height ratio to downsize to before computing the render pass.
  109837. * @param camera The camera to apply the render pass to.
  109838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109839. * @param engine The engine which the post process will be applied. (default: current engine)
  109840. * @param reusable If the post process can be reused on the same frame. (default: false)
  109841. * @param textureType Type of textures used when performing the post process. (default: 0)
  109842. * @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)
  109843. */
  109844. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109845. }
  109846. }
  109847. declare module BABYLON {
  109848. /** @hidden */
  109849. export var circleOfConfusionPixelShader: {
  109850. name: string;
  109851. shader: string;
  109852. };
  109853. }
  109854. declare module BABYLON {
  109855. /**
  109856. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  109857. */
  109858. export class CircleOfConfusionPostProcess extends PostProcess {
  109859. /**
  109860. * 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.
  109861. */
  109862. lensSize: number;
  109863. /**
  109864. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109865. */
  109866. fStop: number;
  109867. /**
  109868. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109869. */
  109870. focusDistance: number;
  109871. /**
  109872. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  109873. */
  109874. focalLength: number;
  109875. private _depthTexture;
  109876. /**
  109877. * Creates a new instance CircleOfConfusionPostProcess
  109878. * @param name The name of the effect.
  109879. * @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.
  109880. * @param options The required width/height ratio to downsize to before computing the render pass.
  109881. * @param camera The camera to apply the render pass to.
  109882. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109883. * @param engine The engine which the post process will be applied. (default: current engine)
  109884. * @param reusable If the post process can be reused on the same frame. (default: false)
  109885. * @param textureType Type of textures used when performing the post process. (default: 0)
  109886. * @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)
  109887. */
  109888. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109889. /**
  109890. * 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.
  109891. */
  109892. depthTexture: RenderTargetTexture;
  109893. }
  109894. }
  109895. declare module BABYLON {
  109896. /** @hidden */
  109897. export var colorCorrectionPixelShader: {
  109898. name: string;
  109899. shader: string;
  109900. };
  109901. }
  109902. declare module BABYLON {
  109903. /**
  109904. *
  109905. * This post-process allows the modification of rendered colors by using
  109906. * a 'look-up table' (LUT). This effect is also called Color Grading.
  109907. *
  109908. * The object needs to be provided an url to a texture containing the color
  109909. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  109910. * Use an image editing software to tweak the LUT to match your needs.
  109911. *
  109912. * For an example of a color LUT, see here:
  109913. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  109914. * For explanations on color grading, see here:
  109915. * @see http://udn.epicgames.com/Three/ColorGrading.html
  109916. *
  109917. */
  109918. export class ColorCorrectionPostProcess extends PostProcess {
  109919. private _colorTableTexture;
  109920. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109921. }
  109922. }
  109923. declare module BABYLON {
  109924. /** @hidden */
  109925. export var convolutionPixelShader: {
  109926. name: string;
  109927. shader: string;
  109928. };
  109929. }
  109930. declare module BABYLON {
  109931. /**
  109932. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  109933. * input texture to perform effects such as edge detection or sharpening
  109934. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109935. */
  109936. export class ConvolutionPostProcess extends PostProcess {
  109937. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109938. kernel: number[];
  109939. /**
  109940. * Creates a new instance ConvolutionPostProcess
  109941. * @param name The name of the effect.
  109942. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  109943. * @param options The required width/height ratio to downsize to before computing the render pass.
  109944. * @param camera The camera to apply the render pass to.
  109945. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109946. * @param engine The engine which the post process will be applied. (default: current engine)
  109947. * @param reusable If the post process can be reused on the same frame. (default: false)
  109948. * @param textureType Type of textures used when performing the post process. (default: 0)
  109949. */
  109950. constructor(name: string,
  109951. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109952. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109953. /**
  109954. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109955. */
  109956. static EdgeDetect0Kernel: number[];
  109957. /**
  109958. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109959. */
  109960. static EdgeDetect1Kernel: number[];
  109961. /**
  109962. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109963. */
  109964. static EdgeDetect2Kernel: number[];
  109965. /**
  109966. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109967. */
  109968. static SharpenKernel: number[];
  109969. /**
  109970. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109971. */
  109972. static EmbossKernel: number[];
  109973. /**
  109974. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109975. */
  109976. static GaussianKernel: number[];
  109977. }
  109978. }
  109979. declare module BABYLON {
  109980. /**
  109981. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  109982. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  109983. * based on samples that have a large difference in distance than the center pixel.
  109984. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  109985. */
  109986. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  109987. direction: Vector2;
  109988. /**
  109989. * Creates a new instance CircleOfConfusionPostProcess
  109990. * @param name The name of the effect.
  109991. * @param scene The scene the effect belongs to.
  109992. * @param direction The direction the blur should be applied.
  109993. * @param kernel The size of the kernel used to blur.
  109994. * @param options The required width/height ratio to downsize to before computing the render pass.
  109995. * @param camera The camera to apply the render pass to.
  109996. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  109997. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  109998. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109999. * @param engine The engine which the post process will be applied. (default: current engine)
  110000. * @param reusable If the post process can be reused on the same frame. (default: false)
  110001. * @param textureType Type of textures used when performing the post process. (default: 0)
  110002. * @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)
  110003. */
  110004. 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);
  110005. }
  110006. }
  110007. declare module BABYLON {
  110008. /** @hidden */
  110009. export var depthOfFieldMergePixelShader: {
  110010. name: string;
  110011. shader: string;
  110012. };
  110013. }
  110014. declare module BABYLON {
  110015. /**
  110016. * Options to be set when merging outputs from the default pipeline.
  110017. */
  110018. export class DepthOfFieldMergePostProcessOptions {
  110019. /**
  110020. * The original image to merge on top of
  110021. */
  110022. originalFromInput: PostProcess;
  110023. /**
  110024. * Parameters to perform the merge of the depth of field effect
  110025. */
  110026. depthOfField?: {
  110027. circleOfConfusion: PostProcess;
  110028. blurSteps: Array<PostProcess>;
  110029. };
  110030. /**
  110031. * Parameters to perform the merge of bloom effect
  110032. */
  110033. bloom?: {
  110034. blurred: PostProcess;
  110035. weight: number;
  110036. };
  110037. }
  110038. /**
  110039. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  110040. */
  110041. export class DepthOfFieldMergePostProcess extends PostProcess {
  110042. private blurSteps;
  110043. /**
  110044. * Creates a new instance of DepthOfFieldMergePostProcess
  110045. * @param name The name of the effect.
  110046. * @param originalFromInput Post process which's input will be used for the merge.
  110047. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  110048. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  110049. * @param options The required width/height ratio to downsize to before computing the render pass.
  110050. * @param camera The camera to apply the render pass to.
  110051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110052. * @param engine The engine which the post process will be applied. (default: current engine)
  110053. * @param reusable If the post process can be reused on the same frame. (default: false)
  110054. * @param textureType Type of textures used when performing the post process. (default: 0)
  110055. * @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)
  110056. */
  110057. 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);
  110058. /**
  110059. * Updates the effect with the current post process compile time values and recompiles the shader.
  110060. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  110061. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  110062. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  110063. * @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
  110064. * @param onCompiled Called when the shader has been compiled.
  110065. * @param onError Called if there is an error when compiling a shader.
  110066. */
  110067. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  110068. }
  110069. }
  110070. declare module BABYLON {
  110071. /**
  110072. * Specifies the level of max blur that should be applied when using the depth of field effect
  110073. */
  110074. export enum DepthOfFieldEffectBlurLevel {
  110075. /**
  110076. * Subtle blur
  110077. */
  110078. Low = 0,
  110079. /**
  110080. * Medium blur
  110081. */
  110082. Medium = 1,
  110083. /**
  110084. * Large blur
  110085. */
  110086. High = 2
  110087. }
  110088. /**
  110089. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  110090. */
  110091. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  110092. private _circleOfConfusion;
  110093. /**
  110094. * @hidden Internal, blurs from high to low
  110095. */
  110096. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  110097. private _depthOfFieldBlurY;
  110098. private _dofMerge;
  110099. /**
  110100. * @hidden Internal post processes in depth of field effect
  110101. */
  110102. _effects: Array<PostProcess>;
  110103. /**
  110104. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  110105. */
  110106. focalLength: number;
  110107. /**
  110108. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110109. */
  110110. fStop: number;
  110111. /**
  110112. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110113. */
  110114. focusDistance: number;
  110115. /**
  110116. * 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.
  110117. */
  110118. lensSize: number;
  110119. /**
  110120. * Creates a new instance DepthOfFieldEffect
  110121. * @param scene The scene the effect belongs to.
  110122. * @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.
  110123. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110124. * @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)
  110125. */
  110126. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  110127. /**
  110128. * 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.
  110129. */
  110130. depthTexture: RenderTargetTexture;
  110131. /**
  110132. * Disposes each of the internal effects for a given camera.
  110133. * @param camera The camera to dispose the effect on.
  110134. */
  110135. disposeEffects(camera: Camera): void;
  110136. /**
  110137. * @hidden Internal
  110138. */
  110139. _updateEffects(): void;
  110140. /**
  110141. * Internal
  110142. * @returns if all the contained post processes are ready.
  110143. * @hidden
  110144. */
  110145. _isReady(): boolean;
  110146. }
  110147. }
  110148. declare module BABYLON {
  110149. /** @hidden */
  110150. export var displayPassPixelShader: {
  110151. name: string;
  110152. shader: string;
  110153. };
  110154. }
  110155. declare module BABYLON {
  110156. /**
  110157. * DisplayPassPostProcess which produces an output the same as it's input
  110158. */
  110159. export class DisplayPassPostProcess extends PostProcess {
  110160. /**
  110161. * Creates the DisplayPassPostProcess
  110162. * @param name The name of the effect.
  110163. * @param options The required width/height ratio to downsize to before computing the render pass.
  110164. * @param camera The camera to apply the render pass to.
  110165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110166. * @param engine The engine which the post process will be applied. (default: current engine)
  110167. * @param reusable If the post process can be reused on the same frame. (default: false)
  110168. */
  110169. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110170. }
  110171. }
  110172. declare module BABYLON {
  110173. /** @hidden */
  110174. export var filterPixelShader: {
  110175. name: string;
  110176. shader: string;
  110177. };
  110178. }
  110179. declare module BABYLON {
  110180. /**
  110181. * Applies a kernel filter to the image
  110182. */
  110183. export class FilterPostProcess extends PostProcess {
  110184. /** The matrix to be applied to the image */
  110185. kernelMatrix: Matrix;
  110186. /**
  110187. *
  110188. * @param name The name of the effect.
  110189. * @param kernelMatrix The matrix to be applied to the image
  110190. * @param options The required width/height ratio to downsize to before computing the render pass.
  110191. * @param camera The camera to apply the render pass to.
  110192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110193. * @param engine The engine which the post process will be applied. (default: current engine)
  110194. * @param reusable If the post process can be reused on the same frame. (default: false)
  110195. */
  110196. constructor(name: string,
  110197. /** The matrix to be applied to the image */
  110198. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110199. }
  110200. }
  110201. declare module BABYLON {
  110202. /** @hidden */
  110203. export var fxaaPixelShader: {
  110204. name: string;
  110205. shader: string;
  110206. };
  110207. }
  110208. declare module BABYLON {
  110209. /** @hidden */
  110210. export var fxaaVertexShader: {
  110211. name: string;
  110212. shader: string;
  110213. };
  110214. }
  110215. declare module BABYLON {
  110216. /**
  110217. * Fxaa post process
  110218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  110219. */
  110220. export class FxaaPostProcess extends PostProcess {
  110221. /** @hidden */
  110222. texelWidth: number;
  110223. /** @hidden */
  110224. texelHeight: number;
  110225. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110226. private _getDefines;
  110227. }
  110228. }
  110229. declare module BABYLON {
  110230. /** @hidden */
  110231. export var grainPixelShader: {
  110232. name: string;
  110233. shader: string;
  110234. };
  110235. }
  110236. declare module BABYLON {
  110237. /**
  110238. * The GrainPostProcess adds noise to the image at mid luminance levels
  110239. */
  110240. export class GrainPostProcess extends PostProcess {
  110241. /**
  110242. * The intensity of the grain added (default: 30)
  110243. */
  110244. intensity: number;
  110245. /**
  110246. * If the grain should be randomized on every frame
  110247. */
  110248. animated: boolean;
  110249. /**
  110250. * Creates a new instance of @see GrainPostProcess
  110251. * @param name The name of the effect.
  110252. * @param options The required width/height ratio to downsize to before computing the render pass.
  110253. * @param camera The camera to apply the render pass to.
  110254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110255. * @param engine The engine which the post process will be applied. (default: current engine)
  110256. * @param reusable If the post process can be reused on the same frame. (default: false)
  110257. * @param textureType Type of textures used when performing the post process. (default: 0)
  110258. * @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)
  110259. */
  110260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110261. }
  110262. }
  110263. declare module BABYLON {
  110264. /** @hidden */
  110265. export var highlightsPixelShader: {
  110266. name: string;
  110267. shader: string;
  110268. };
  110269. }
  110270. declare module BABYLON {
  110271. /**
  110272. * Extracts highlights from the image
  110273. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110274. */
  110275. export class HighlightsPostProcess extends PostProcess {
  110276. /**
  110277. * Extracts highlights from the image
  110278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110279. * @param name The name of the effect.
  110280. * @param options The required width/height ratio to downsize to before computing the render pass.
  110281. * @param camera The camera to apply the render pass to.
  110282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110283. * @param engine The engine which the post process will be applied. (default: current engine)
  110284. * @param reusable If the post process can be reused on the same frame. (default: false)
  110285. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110286. */
  110287. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110288. }
  110289. }
  110290. declare module BABYLON {
  110291. /** @hidden */
  110292. export var mrtFragmentDeclaration: {
  110293. name: string;
  110294. shader: string;
  110295. };
  110296. }
  110297. declare module BABYLON {
  110298. /** @hidden */
  110299. export var geometryPixelShader: {
  110300. name: string;
  110301. shader: string;
  110302. };
  110303. }
  110304. declare module BABYLON {
  110305. /** @hidden */
  110306. export var geometryVertexShader: {
  110307. name: string;
  110308. shader: string;
  110309. };
  110310. }
  110311. declare module BABYLON {
  110312. /**
  110313. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110314. */
  110315. export class GeometryBufferRenderer {
  110316. /**
  110317. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110318. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110319. */
  110320. static readonly POSITION_TEXTURE_TYPE: number;
  110321. /**
  110322. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110323. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110324. */
  110325. static readonly VELOCITY_TEXTURE_TYPE: number;
  110326. /**
  110327. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110328. * in order to compute objects velocities when enableVelocity is set to "true"
  110329. * @hidden
  110330. */
  110331. _previousTransformationMatrices: {
  110332. [index: number]: Matrix;
  110333. };
  110334. private _scene;
  110335. private _multiRenderTarget;
  110336. private _ratio;
  110337. private _enablePosition;
  110338. private _enableVelocity;
  110339. private _positionIndex;
  110340. private _velocityIndex;
  110341. protected _effect: Effect;
  110342. protected _cachedDefines: string;
  110343. /**
  110344. * Set the render list (meshes to be rendered) used in the G buffer.
  110345. */
  110346. renderList: Mesh[];
  110347. /**
  110348. * Gets wether or not G buffer are supported by the running hardware.
  110349. * This requires draw buffer supports
  110350. */
  110351. readonly isSupported: boolean;
  110352. /**
  110353. * Returns the index of the given texture type in the G-Buffer textures array
  110354. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110355. * @returns the index of the given texture type in the G-Buffer textures array
  110356. */
  110357. getTextureIndex(textureType: number): number;
  110358. /**
  110359. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110360. */
  110361. /**
  110362. * Sets whether or not objects positions are enabled for the G buffer.
  110363. */
  110364. enablePosition: boolean;
  110365. /**
  110366. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110367. */
  110368. /**
  110369. * Sets wether or not objects velocities are enabled for the G buffer.
  110370. */
  110371. enableVelocity: boolean;
  110372. /**
  110373. * Gets the scene associated with the buffer.
  110374. */
  110375. readonly scene: Scene;
  110376. /**
  110377. * Gets the ratio used by the buffer during its creation.
  110378. * How big is the buffer related to the main canvas.
  110379. */
  110380. readonly ratio: number;
  110381. /** @hidden */
  110382. static _SceneComponentInitialization: (scene: Scene) => void;
  110383. /**
  110384. * Creates a new G Buffer for the scene
  110385. * @param scene The scene the buffer belongs to
  110386. * @param ratio How big is the buffer related to the main canvas.
  110387. */
  110388. constructor(scene: Scene, ratio?: number);
  110389. /**
  110390. * Checks wether everything is ready to render a submesh to the G buffer.
  110391. * @param subMesh the submesh to check readiness for
  110392. * @param useInstances is the mesh drawn using instance or not
  110393. * @returns true if ready otherwise false
  110394. */
  110395. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110396. /**
  110397. * Gets the current underlying G Buffer.
  110398. * @returns the buffer
  110399. */
  110400. getGBuffer(): MultiRenderTarget;
  110401. /**
  110402. * Gets the number of samples used to render the buffer (anti aliasing).
  110403. */
  110404. /**
  110405. * Sets the number of samples used to render the buffer (anti aliasing).
  110406. */
  110407. samples: number;
  110408. /**
  110409. * Disposes the renderer and frees up associated resources.
  110410. */
  110411. dispose(): void;
  110412. protected _createRenderTargets(): void;
  110413. }
  110414. }
  110415. declare module BABYLON {
  110416. interface Scene {
  110417. /** @hidden (Backing field) */
  110418. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110419. /**
  110420. * Gets or Sets the current geometry buffer associated to the scene.
  110421. */
  110422. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110423. /**
  110424. * Enables a GeometryBufferRender and associates it with the scene
  110425. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110426. * @returns the GeometryBufferRenderer
  110427. */
  110428. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110429. /**
  110430. * Disables the GeometryBufferRender associated with the scene
  110431. */
  110432. disableGeometryBufferRenderer(): void;
  110433. }
  110434. /**
  110435. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110436. * in several rendering techniques.
  110437. */
  110438. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110439. /**
  110440. * The component name helpful to identify the component in the list of scene components.
  110441. */
  110442. readonly name: string;
  110443. /**
  110444. * The scene the component belongs to.
  110445. */
  110446. scene: Scene;
  110447. /**
  110448. * Creates a new instance of the component for the given scene
  110449. * @param scene Defines the scene to register the component in
  110450. */
  110451. constructor(scene: Scene);
  110452. /**
  110453. * Registers the component in a given scene
  110454. */
  110455. register(): void;
  110456. /**
  110457. * Rebuilds the elements related to this component in case of
  110458. * context lost for instance.
  110459. */
  110460. rebuild(): void;
  110461. /**
  110462. * Disposes the component and the associated ressources
  110463. */
  110464. dispose(): void;
  110465. private _gatherRenderTargets;
  110466. }
  110467. }
  110468. declare module BABYLON {
  110469. /** @hidden */
  110470. export var motionBlurPixelShader: {
  110471. name: string;
  110472. shader: string;
  110473. };
  110474. }
  110475. declare module BABYLON {
  110476. /**
  110477. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110478. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110479. * As an example, all you have to do is to create the post-process:
  110480. * var mb = new BABYLON.MotionBlurPostProcess(
  110481. * 'mb', // The name of the effect.
  110482. * scene, // The scene containing the objects to blur according to their velocity.
  110483. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110484. * camera // The camera to apply the render pass to.
  110485. * );
  110486. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110487. */
  110488. export class MotionBlurPostProcess extends PostProcess {
  110489. /**
  110490. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110491. */
  110492. motionStrength: number;
  110493. /**
  110494. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110495. */
  110496. /**
  110497. * Sets the number of iterations to be used for motion blur quality
  110498. */
  110499. motionBlurSamples: number;
  110500. private _motionBlurSamples;
  110501. private _geometryBufferRenderer;
  110502. /**
  110503. * Creates a new instance MotionBlurPostProcess
  110504. * @param name The name of the effect.
  110505. * @param scene The scene containing the objects to blur according to their velocity.
  110506. * @param options The required width/height ratio to downsize to before computing the render pass.
  110507. * @param camera The camera to apply the render pass to.
  110508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110509. * @param engine The engine which the post process will be applied. (default: current engine)
  110510. * @param reusable If the post process can be reused on the same frame. (default: false)
  110511. * @param textureType Type of textures used when performing the post process. (default: 0)
  110512. * @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)
  110513. */
  110514. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110515. /**
  110516. * Disposes the post process.
  110517. * @param camera The camera to dispose the post process on.
  110518. */
  110519. dispose(camera?: Camera): void;
  110520. }
  110521. }
  110522. declare module BABYLON {
  110523. /** @hidden */
  110524. export var refractionPixelShader: {
  110525. name: string;
  110526. shader: string;
  110527. };
  110528. }
  110529. declare module BABYLON {
  110530. /**
  110531. * Post process which applies a refractin texture
  110532. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110533. */
  110534. export class RefractionPostProcess extends PostProcess {
  110535. /** the base color of the refraction (used to taint the rendering) */
  110536. color: Color3;
  110537. /** simulated refraction depth */
  110538. depth: number;
  110539. /** the coefficient of the base color (0 to remove base color tainting) */
  110540. colorLevel: number;
  110541. private _refTexture;
  110542. private _ownRefractionTexture;
  110543. /**
  110544. * Gets or sets the refraction texture
  110545. * Please note that you are responsible for disposing the texture if you set it manually
  110546. */
  110547. refractionTexture: Texture;
  110548. /**
  110549. * Initializes the RefractionPostProcess
  110550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110551. * @param name The name of the effect.
  110552. * @param refractionTextureUrl Url of the refraction texture to use
  110553. * @param color the base color of the refraction (used to taint the rendering)
  110554. * @param depth simulated refraction depth
  110555. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110556. * @param camera The camera to apply the render pass to.
  110557. * @param options The required width/height ratio to downsize to before computing the render pass.
  110558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110559. * @param engine The engine which the post process will be applied. (default: current engine)
  110560. * @param reusable If the post process can be reused on the same frame. (default: false)
  110561. */
  110562. constructor(name: string, refractionTextureUrl: string,
  110563. /** the base color of the refraction (used to taint the rendering) */
  110564. color: Color3,
  110565. /** simulated refraction depth */
  110566. depth: number,
  110567. /** the coefficient of the base color (0 to remove base color tainting) */
  110568. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110569. /**
  110570. * Disposes of the post process
  110571. * @param camera Camera to dispose post process on
  110572. */
  110573. dispose(camera: Camera): void;
  110574. }
  110575. }
  110576. declare module BABYLON {
  110577. /** @hidden */
  110578. export var sharpenPixelShader: {
  110579. name: string;
  110580. shader: string;
  110581. };
  110582. }
  110583. declare module BABYLON {
  110584. /**
  110585. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110586. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110587. */
  110588. export class SharpenPostProcess extends PostProcess {
  110589. /**
  110590. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110591. */
  110592. colorAmount: number;
  110593. /**
  110594. * How much sharpness should be applied (default: 0.3)
  110595. */
  110596. edgeAmount: number;
  110597. /**
  110598. * Creates a new instance ConvolutionPostProcess
  110599. * @param name The name of the effect.
  110600. * @param options The required width/height ratio to downsize to before computing the render pass.
  110601. * @param camera The camera to apply the render pass to.
  110602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110603. * @param engine The engine which the post process will be applied. (default: current engine)
  110604. * @param reusable If the post process can be reused on the same frame. (default: false)
  110605. * @param textureType Type of textures used when performing the post process. (default: 0)
  110606. * @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)
  110607. */
  110608. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110609. }
  110610. }
  110611. declare module BABYLON {
  110612. /**
  110613. * PostProcessRenderPipeline
  110614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110615. */
  110616. export class PostProcessRenderPipeline {
  110617. private engine;
  110618. private _renderEffects;
  110619. private _renderEffectsForIsolatedPass;
  110620. /**
  110621. * List of inspectable custom properties (used by the Inspector)
  110622. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110623. */
  110624. inspectableCustomProperties: IInspectable[];
  110625. /**
  110626. * @hidden
  110627. */
  110628. protected _cameras: Camera[];
  110629. /** @hidden */
  110630. _name: string;
  110631. /**
  110632. * Gets pipeline name
  110633. */
  110634. readonly name: string;
  110635. /**
  110636. * Initializes a PostProcessRenderPipeline
  110637. * @param engine engine to add the pipeline to
  110638. * @param name name of the pipeline
  110639. */
  110640. constructor(engine: Engine, name: string);
  110641. /**
  110642. * Gets the class name
  110643. * @returns "PostProcessRenderPipeline"
  110644. */
  110645. getClassName(): string;
  110646. /**
  110647. * If all the render effects in the pipeline are supported
  110648. */
  110649. readonly isSupported: boolean;
  110650. /**
  110651. * Adds an effect to the pipeline
  110652. * @param renderEffect the effect to add
  110653. */
  110654. addEffect(renderEffect: PostProcessRenderEffect): void;
  110655. /** @hidden */
  110656. _rebuild(): void;
  110657. /** @hidden */
  110658. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110659. /** @hidden */
  110660. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110661. /** @hidden */
  110662. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110663. /** @hidden */
  110664. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110665. /** @hidden */
  110666. _attachCameras(cameras: Camera, unique: boolean): void;
  110667. /** @hidden */
  110668. _attachCameras(cameras: Camera[], unique: boolean): void;
  110669. /** @hidden */
  110670. _detachCameras(cameras: Camera): void;
  110671. /** @hidden */
  110672. _detachCameras(cameras: Nullable<Camera[]>): void;
  110673. /** @hidden */
  110674. _update(): void;
  110675. /** @hidden */
  110676. _reset(): void;
  110677. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110678. /**
  110679. * Disposes of the pipeline
  110680. */
  110681. dispose(): void;
  110682. }
  110683. }
  110684. declare module BABYLON {
  110685. /**
  110686. * PostProcessRenderPipelineManager class
  110687. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110688. */
  110689. export class PostProcessRenderPipelineManager {
  110690. private _renderPipelines;
  110691. /**
  110692. * Initializes a PostProcessRenderPipelineManager
  110693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110694. */
  110695. constructor();
  110696. /**
  110697. * Gets the list of supported render pipelines
  110698. */
  110699. readonly supportedPipelines: PostProcessRenderPipeline[];
  110700. /**
  110701. * Adds a pipeline to the manager
  110702. * @param renderPipeline The pipeline to add
  110703. */
  110704. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110705. /**
  110706. * Attaches a camera to the pipeline
  110707. * @param renderPipelineName The name of the pipeline to attach to
  110708. * @param cameras the camera to attach
  110709. * @param unique if the camera can be attached multiple times to the pipeline
  110710. */
  110711. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110712. /**
  110713. * Detaches a camera from the pipeline
  110714. * @param renderPipelineName The name of the pipeline to detach from
  110715. * @param cameras the camera to detach
  110716. */
  110717. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110718. /**
  110719. * Enables an effect by name on a pipeline
  110720. * @param renderPipelineName the name of the pipeline to enable the effect in
  110721. * @param renderEffectName the name of the effect to enable
  110722. * @param cameras the cameras that the effect should be enabled on
  110723. */
  110724. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110725. /**
  110726. * Disables an effect by name on a pipeline
  110727. * @param renderPipelineName the name of the pipeline to disable the effect in
  110728. * @param renderEffectName the name of the effect to disable
  110729. * @param cameras the cameras that the effect should be disabled on
  110730. */
  110731. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110732. /**
  110733. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110734. */
  110735. update(): void;
  110736. /** @hidden */
  110737. _rebuild(): void;
  110738. /**
  110739. * Disposes of the manager and pipelines
  110740. */
  110741. dispose(): void;
  110742. }
  110743. }
  110744. declare module BABYLON {
  110745. interface Scene {
  110746. /** @hidden (Backing field) */
  110747. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110748. /**
  110749. * Gets the postprocess render pipeline manager
  110750. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110751. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110752. */
  110753. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110754. }
  110755. /**
  110756. * Defines the Render Pipeline scene component responsible to rendering pipelines
  110757. */
  110758. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  110759. /**
  110760. * The component name helpfull to identify the component in the list of scene components.
  110761. */
  110762. readonly name: string;
  110763. /**
  110764. * The scene the component belongs to.
  110765. */
  110766. scene: Scene;
  110767. /**
  110768. * Creates a new instance of the component for the given scene
  110769. * @param scene Defines the scene to register the component in
  110770. */
  110771. constructor(scene: Scene);
  110772. /**
  110773. * Registers the component in a given scene
  110774. */
  110775. register(): void;
  110776. /**
  110777. * Rebuilds the elements related to this component in case of
  110778. * context lost for instance.
  110779. */
  110780. rebuild(): void;
  110781. /**
  110782. * Disposes the component and the associated ressources
  110783. */
  110784. dispose(): void;
  110785. private _gatherRenderTargets;
  110786. }
  110787. }
  110788. declare module BABYLON {
  110789. /**
  110790. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  110791. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110792. */
  110793. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110794. private _scene;
  110795. private _camerasToBeAttached;
  110796. /**
  110797. * ID of the sharpen post process,
  110798. */
  110799. private readonly SharpenPostProcessId;
  110800. /**
  110801. * @ignore
  110802. * ID of the image processing post process;
  110803. */
  110804. readonly ImageProcessingPostProcessId: string;
  110805. /**
  110806. * @ignore
  110807. * ID of the Fast Approximate Anti-Aliasing post process;
  110808. */
  110809. readonly FxaaPostProcessId: string;
  110810. /**
  110811. * ID of the chromatic aberration post process,
  110812. */
  110813. private readonly ChromaticAberrationPostProcessId;
  110814. /**
  110815. * ID of the grain post process
  110816. */
  110817. private readonly GrainPostProcessId;
  110818. /**
  110819. * Sharpen post process which will apply a sharpen convolution to enhance edges
  110820. */
  110821. sharpen: SharpenPostProcess;
  110822. private _sharpenEffect;
  110823. private bloom;
  110824. /**
  110825. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  110826. */
  110827. depthOfField: DepthOfFieldEffect;
  110828. /**
  110829. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110830. */
  110831. fxaa: FxaaPostProcess;
  110832. /**
  110833. * Image post processing pass used to perform operations such as tone mapping or color grading.
  110834. */
  110835. imageProcessing: ImageProcessingPostProcess;
  110836. /**
  110837. * Chromatic aberration post process which will shift rgb colors in the image
  110838. */
  110839. chromaticAberration: ChromaticAberrationPostProcess;
  110840. private _chromaticAberrationEffect;
  110841. /**
  110842. * Grain post process which add noise to the image
  110843. */
  110844. grain: GrainPostProcess;
  110845. private _grainEffect;
  110846. /**
  110847. * Glow post process which adds a glow to emissive areas of the image
  110848. */
  110849. private _glowLayer;
  110850. /**
  110851. * Animations which can be used to tweak settings over a period of time
  110852. */
  110853. animations: Animation[];
  110854. private _imageProcessingConfigurationObserver;
  110855. private _sharpenEnabled;
  110856. private _bloomEnabled;
  110857. private _depthOfFieldEnabled;
  110858. private _depthOfFieldBlurLevel;
  110859. private _fxaaEnabled;
  110860. private _imageProcessingEnabled;
  110861. private _defaultPipelineTextureType;
  110862. private _bloomScale;
  110863. private _chromaticAberrationEnabled;
  110864. private _grainEnabled;
  110865. private _buildAllowed;
  110866. /**
  110867. * Gets active scene
  110868. */
  110869. readonly scene: Scene;
  110870. /**
  110871. * Enable or disable the sharpen process from the pipeline
  110872. */
  110873. sharpenEnabled: boolean;
  110874. private _resizeObserver;
  110875. private _hardwareScaleLevel;
  110876. private _bloomKernel;
  110877. /**
  110878. * Specifies the size of the bloom blur kernel, relative to the final output size
  110879. */
  110880. bloomKernel: number;
  110881. /**
  110882. * Specifies the weight of the bloom in the final rendering
  110883. */
  110884. private _bloomWeight;
  110885. /**
  110886. * Specifies the luma threshold for the area that will be blurred by the bloom
  110887. */
  110888. private _bloomThreshold;
  110889. private _hdr;
  110890. /**
  110891. * The strength of the bloom.
  110892. */
  110893. bloomWeight: number;
  110894. /**
  110895. * The strength of the bloom.
  110896. */
  110897. bloomThreshold: number;
  110898. /**
  110899. * The scale of the bloom, lower value will provide better performance.
  110900. */
  110901. bloomScale: number;
  110902. /**
  110903. * Enable or disable the bloom from the pipeline
  110904. */
  110905. bloomEnabled: boolean;
  110906. private _rebuildBloom;
  110907. /**
  110908. * If the depth of field is enabled.
  110909. */
  110910. depthOfFieldEnabled: boolean;
  110911. /**
  110912. * Blur level of the depth of field effect. (Higher blur will effect performance)
  110913. */
  110914. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  110915. /**
  110916. * If the anti aliasing is enabled.
  110917. */
  110918. fxaaEnabled: boolean;
  110919. private _samples;
  110920. /**
  110921. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110922. */
  110923. samples: number;
  110924. /**
  110925. * If image processing is enabled.
  110926. */
  110927. imageProcessingEnabled: boolean;
  110928. /**
  110929. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  110930. */
  110931. glowLayerEnabled: boolean;
  110932. /**
  110933. * Enable or disable the chromaticAberration process from the pipeline
  110934. */
  110935. chromaticAberrationEnabled: boolean;
  110936. /**
  110937. * Enable or disable the grain process from the pipeline
  110938. */
  110939. grainEnabled: boolean;
  110940. /**
  110941. * @constructor
  110942. * @param name - The rendering pipeline name (default: "")
  110943. * @param hdr - If high dynamic range textures should be used (default: true)
  110944. * @param scene - The scene linked to this pipeline (default: the last created scene)
  110945. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  110946. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  110947. */
  110948. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  110949. /**
  110950. * Get the class name
  110951. * @returns "DefaultRenderingPipeline"
  110952. */
  110953. getClassName(): string;
  110954. /**
  110955. * Force the compilation of the entire pipeline.
  110956. */
  110957. prepare(): void;
  110958. private _hasCleared;
  110959. private _prevPostProcess;
  110960. private _prevPrevPostProcess;
  110961. private _setAutoClearAndTextureSharing;
  110962. private _depthOfFieldSceneObserver;
  110963. private _buildPipeline;
  110964. private _disposePostProcesses;
  110965. /**
  110966. * Adds a camera to the pipeline
  110967. * @param camera the camera to be added
  110968. */
  110969. addCamera(camera: Camera): void;
  110970. /**
  110971. * Removes a camera from the pipeline
  110972. * @param camera the camera to remove
  110973. */
  110974. removeCamera(camera: Camera): void;
  110975. /**
  110976. * Dispose of the pipeline and stop all post processes
  110977. */
  110978. dispose(): void;
  110979. /**
  110980. * Serialize the rendering pipeline (Used when exporting)
  110981. * @returns the serialized object
  110982. */
  110983. serialize(): any;
  110984. /**
  110985. * Parse the serialized pipeline
  110986. * @param source Source pipeline.
  110987. * @param scene The scene to load the pipeline to.
  110988. * @param rootUrl The URL of the serialized pipeline.
  110989. * @returns An instantiated pipeline from the serialized object.
  110990. */
  110991. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  110992. }
  110993. }
  110994. declare module BABYLON {
  110995. /** @hidden */
  110996. export var lensHighlightsPixelShader: {
  110997. name: string;
  110998. shader: string;
  110999. };
  111000. }
  111001. declare module BABYLON {
  111002. /** @hidden */
  111003. export var depthOfFieldPixelShader: {
  111004. name: string;
  111005. shader: string;
  111006. };
  111007. }
  111008. declare module BABYLON {
  111009. /**
  111010. * BABYLON.JS Chromatic Aberration GLSL Shader
  111011. * Author: Olivier Guyot
  111012. * Separates very slightly R, G and B colors on the edges of the screen
  111013. * Inspired by Francois Tarlier & Martins Upitis
  111014. */
  111015. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  111016. /**
  111017. * @ignore
  111018. * The chromatic aberration PostProcess id in the pipeline
  111019. */
  111020. LensChromaticAberrationEffect: string;
  111021. /**
  111022. * @ignore
  111023. * The highlights enhancing PostProcess id in the pipeline
  111024. */
  111025. HighlightsEnhancingEffect: string;
  111026. /**
  111027. * @ignore
  111028. * The depth-of-field PostProcess id in the pipeline
  111029. */
  111030. LensDepthOfFieldEffect: string;
  111031. private _scene;
  111032. private _depthTexture;
  111033. private _grainTexture;
  111034. private _chromaticAberrationPostProcess;
  111035. private _highlightsPostProcess;
  111036. private _depthOfFieldPostProcess;
  111037. private _edgeBlur;
  111038. private _grainAmount;
  111039. private _chromaticAberration;
  111040. private _distortion;
  111041. private _highlightsGain;
  111042. private _highlightsThreshold;
  111043. private _dofDistance;
  111044. private _dofAperture;
  111045. private _dofDarken;
  111046. private _dofPentagon;
  111047. private _blurNoise;
  111048. /**
  111049. * @constructor
  111050. *
  111051. * Effect parameters are as follow:
  111052. * {
  111053. * chromatic_aberration: number; // from 0 to x (1 for realism)
  111054. * edge_blur: number; // from 0 to x (1 for realism)
  111055. * distortion: number; // from 0 to x (1 for realism)
  111056. * grain_amount: number; // from 0 to 1
  111057. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  111058. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  111059. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  111060. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  111061. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  111062. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  111063. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  111064. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  111065. * }
  111066. * Note: if an effect parameter is unset, effect is disabled
  111067. *
  111068. * @param name The rendering pipeline name
  111069. * @param parameters - An object containing all parameters (see above)
  111070. * @param scene The scene linked to this pipeline
  111071. * @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)
  111072. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111073. */
  111074. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  111075. /**
  111076. * Get the class name
  111077. * @returns "LensRenderingPipeline"
  111078. */
  111079. getClassName(): string;
  111080. /**
  111081. * Gets associated scene
  111082. */
  111083. readonly scene: Scene;
  111084. /**
  111085. * Gets or sets the edge blur
  111086. */
  111087. edgeBlur: number;
  111088. /**
  111089. * Gets or sets the grain amount
  111090. */
  111091. grainAmount: number;
  111092. /**
  111093. * Gets or sets the chromatic aberration amount
  111094. */
  111095. chromaticAberration: number;
  111096. /**
  111097. * Gets or sets the depth of field aperture
  111098. */
  111099. dofAperture: number;
  111100. /**
  111101. * Gets or sets the edge distortion
  111102. */
  111103. edgeDistortion: number;
  111104. /**
  111105. * Gets or sets the depth of field distortion
  111106. */
  111107. dofDistortion: number;
  111108. /**
  111109. * Gets or sets the darken out of focus amount
  111110. */
  111111. darkenOutOfFocus: number;
  111112. /**
  111113. * Gets or sets a boolean indicating if blur noise is enabled
  111114. */
  111115. blurNoise: boolean;
  111116. /**
  111117. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  111118. */
  111119. pentagonBokeh: boolean;
  111120. /**
  111121. * Gets or sets the highlight grain amount
  111122. */
  111123. highlightsGain: number;
  111124. /**
  111125. * Gets or sets the highlight threshold
  111126. */
  111127. highlightsThreshold: number;
  111128. /**
  111129. * Sets the amount of blur at the edges
  111130. * @param amount blur amount
  111131. */
  111132. setEdgeBlur(amount: number): void;
  111133. /**
  111134. * Sets edge blur to 0
  111135. */
  111136. disableEdgeBlur(): void;
  111137. /**
  111138. * Sets the amout of grain
  111139. * @param amount Amount of grain
  111140. */
  111141. setGrainAmount(amount: number): void;
  111142. /**
  111143. * Set grain amount to 0
  111144. */
  111145. disableGrain(): void;
  111146. /**
  111147. * Sets the chromatic aberration amount
  111148. * @param amount amount of chromatic aberration
  111149. */
  111150. setChromaticAberration(amount: number): void;
  111151. /**
  111152. * Sets chromatic aberration amount to 0
  111153. */
  111154. disableChromaticAberration(): void;
  111155. /**
  111156. * Sets the EdgeDistortion amount
  111157. * @param amount amount of EdgeDistortion
  111158. */
  111159. setEdgeDistortion(amount: number): void;
  111160. /**
  111161. * Sets edge distortion to 0
  111162. */
  111163. disableEdgeDistortion(): void;
  111164. /**
  111165. * Sets the FocusDistance amount
  111166. * @param amount amount of FocusDistance
  111167. */
  111168. setFocusDistance(amount: number): void;
  111169. /**
  111170. * Disables depth of field
  111171. */
  111172. disableDepthOfField(): void;
  111173. /**
  111174. * Sets the Aperture amount
  111175. * @param amount amount of Aperture
  111176. */
  111177. setAperture(amount: number): void;
  111178. /**
  111179. * Sets the DarkenOutOfFocus amount
  111180. * @param amount amount of DarkenOutOfFocus
  111181. */
  111182. setDarkenOutOfFocus(amount: number): void;
  111183. private _pentagonBokehIsEnabled;
  111184. /**
  111185. * Creates a pentagon bokeh effect
  111186. */
  111187. enablePentagonBokeh(): void;
  111188. /**
  111189. * Disables the pentagon bokeh effect
  111190. */
  111191. disablePentagonBokeh(): void;
  111192. /**
  111193. * Enables noise blur
  111194. */
  111195. enableNoiseBlur(): void;
  111196. /**
  111197. * Disables noise blur
  111198. */
  111199. disableNoiseBlur(): void;
  111200. /**
  111201. * Sets the HighlightsGain amount
  111202. * @param amount amount of HighlightsGain
  111203. */
  111204. setHighlightsGain(amount: number): void;
  111205. /**
  111206. * Sets the HighlightsThreshold amount
  111207. * @param amount amount of HighlightsThreshold
  111208. */
  111209. setHighlightsThreshold(amount: number): void;
  111210. /**
  111211. * Disables highlights
  111212. */
  111213. disableHighlights(): void;
  111214. /**
  111215. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  111216. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  111217. */
  111218. dispose(disableDepthRender?: boolean): void;
  111219. private _createChromaticAberrationPostProcess;
  111220. private _createHighlightsPostProcess;
  111221. private _createDepthOfFieldPostProcess;
  111222. private _createGrainTexture;
  111223. }
  111224. }
  111225. declare module BABYLON {
  111226. /** @hidden */
  111227. export var ssao2PixelShader: {
  111228. name: string;
  111229. shader: string;
  111230. };
  111231. }
  111232. declare module BABYLON {
  111233. /** @hidden */
  111234. export var ssaoCombinePixelShader: {
  111235. name: string;
  111236. shader: string;
  111237. };
  111238. }
  111239. declare module BABYLON {
  111240. /**
  111241. * Render pipeline to produce ssao effect
  111242. */
  111243. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  111244. /**
  111245. * @ignore
  111246. * The PassPostProcess id in the pipeline that contains the original scene color
  111247. */
  111248. SSAOOriginalSceneColorEffect: string;
  111249. /**
  111250. * @ignore
  111251. * The SSAO PostProcess id in the pipeline
  111252. */
  111253. SSAORenderEffect: string;
  111254. /**
  111255. * @ignore
  111256. * The horizontal blur PostProcess id in the pipeline
  111257. */
  111258. SSAOBlurHRenderEffect: string;
  111259. /**
  111260. * @ignore
  111261. * The vertical blur PostProcess id in the pipeline
  111262. */
  111263. SSAOBlurVRenderEffect: string;
  111264. /**
  111265. * @ignore
  111266. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111267. */
  111268. SSAOCombineRenderEffect: string;
  111269. /**
  111270. * The output strength of the SSAO post-process. Default value is 1.0.
  111271. */
  111272. totalStrength: number;
  111273. /**
  111274. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  111275. */
  111276. maxZ: number;
  111277. /**
  111278. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  111279. */
  111280. minZAspect: number;
  111281. private _samples;
  111282. /**
  111283. * Number of samples used for the SSAO calculations. Default value is 8
  111284. */
  111285. samples: number;
  111286. private _textureSamples;
  111287. /**
  111288. * Number of samples to use for antialiasing
  111289. */
  111290. textureSamples: number;
  111291. /**
  111292. * Ratio object used for SSAO ratio and blur ratio
  111293. */
  111294. private _ratio;
  111295. /**
  111296. * Dynamically generated sphere sampler.
  111297. */
  111298. private _sampleSphere;
  111299. /**
  111300. * Blur filter offsets
  111301. */
  111302. private _samplerOffsets;
  111303. private _expensiveBlur;
  111304. /**
  111305. * If bilateral blur should be used
  111306. */
  111307. expensiveBlur: boolean;
  111308. /**
  111309. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111310. */
  111311. radius: number;
  111312. /**
  111313. * The base color of the SSAO post-process
  111314. * The final result is "base + ssao" between [0, 1]
  111315. */
  111316. base: number;
  111317. /**
  111318. * Support test.
  111319. */
  111320. static readonly IsSupported: boolean;
  111321. private _scene;
  111322. private _depthTexture;
  111323. private _normalTexture;
  111324. private _randomTexture;
  111325. private _originalColorPostProcess;
  111326. private _ssaoPostProcess;
  111327. private _blurHPostProcess;
  111328. private _blurVPostProcess;
  111329. private _ssaoCombinePostProcess;
  111330. private _firstUpdate;
  111331. /**
  111332. * Gets active scene
  111333. */
  111334. readonly scene: Scene;
  111335. /**
  111336. * @constructor
  111337. * @param name The rendering pipeline name
  111338. * @param scene The scene linked to this pipeline
  111339. * @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 }
  111340. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111341. */
  111342. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111343. /**
  111344. * Get the class name
  111345. * @returns "SSAO2RenderingPipeline"
  111346. */
  111347. getClassName(): string;
  111348. /**
  111349. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111350. */
  111351. dispose(disableGeometryBufferRenderer?: boolean): void;
  111352. private _createBlurPostProcess;
  111353. /** @hidden */
  111354. _rebuild(): void;
  111355. private _bits;
  111356. private _radicalInverse_VdC;
  111357. private _hammersley;
  111358. private _hemisphereSample_uniform;
  111359. private _generateHemisphere;
  111360. private _createSSAOPostProcess;
  111361. private _createSSAOCombinePostProcess;
  111362. private _createRandomTexture;
  111363. /**
  111364. * Serialize the rendering pipeline (Used when exporting)
  111365. * @returns the serialized object
  111366. */
  111367. serialize(): any;
  111368. /**
  111369. * Parse the serialized pipeline
  111370. * @param source Source pipeline.
  111371. * @param scene The scene to load the pipeline to.
  111372. * @param rootUrl The URL of the serialized pipeline.
  111373. * @returns An instantiated pipeline from the serialized object.
  111374. */
  111375. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111376. }
  111377. }
  111378. declare module BABYLON {
  111379. /** @hidden */
  111380. export var ssaoPixelShader: {
  111381. name: string;
  111382. shader: string;
  111383. };
  111384. }
  111385. declare module BABYLON {
  111386. /**
  111387. * Render pipeline to produce ssao effect
  111388. */
  111389. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111390. /**
  111391. * @ignore
  111392. * The PassPostProcess id in the pipeline that contains the original scene color
  111393. */
  111394. SSAOOriginalSceneColorEffect: string;
  111395. /**
  111396. * @ignore
  111397. * The SSAO PostProcess id in the pipeline
  111398. */
  111399. SSAORenderEffect: string;
  111400. /**
  111401. * @ignore
  111402. * The horizontal blur PostProcess id in the pipeline
  111403. */
  111404. SSAOBlurHRenderEffect: string;
  111405. /**
  111406. * @ignore
  111407. * The vertical blur PostProcess id in the pipeline
  111408. */
  111409. SSAOBlurVRenderEffect: string;
  111410. /**
  111411. * @ignore
  111412. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111413. */
  111414. SSAOCombineRenderEffect: string;
  111415. /**
  111416. * The output strength of the SSAO post-process. Default value is 1.0.
  111417. */
  111418. totalStrength: number;
  111419. /**
  111420. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111421. */
  111422. radius: number;
  111423. /**
  111424. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111425. * Must not be equal to fallOff and superior to fallOff.
  111426. * Default value is 0.0075
  111427. */
  111428. area: number;
  111429. /**
  111430. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111431. * Must not be equal to area and inferior to area.
  111432. * Default value is 0.000001
  111433. */
  111434. fallOff: number;
  111435. /**
  111436. * The base color of the SSAO post-process
  111437. * The final result is "base + ssao" between [0, 1]
  111438. */
  111439. base: number;
  111440. private _scene;
  111441. private _depthTexture;
  111442. private _randomTexture;
  111443. private _originalColorPostProcess;
  111444. private _ssaoPostProcess;
  111445. private _blurHPostProcess;
  111446. private _blurVPostProcess;
  111447. private _ssaoCombinePostProcess;
  111448. private _firstUpdate;
  111449. /**
  111450. * Gets active scene
  111451. */
  111452. readonly scene: Scene;
  111453. /**
  111454. * @constructor
  111455. * @param name - The rendering pipeline name
  111456. * @param scene - The scene linked to this pipeline
  111457. * @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 }
  111458. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111459. */
  111460. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111461. /**
  111462. * Get the class name
  111463. * @returns "SSAORenderingPipeline"
  111464. */
  111465. getClassName(): string;
  111466. /**
  111467. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111468. */
  111469. dispose(disableDepthRender?: boolean): void;
  111470. private _createBlurPostProcess;
  111471. /** @hidden */
  111472. _rebuild(): void;
  111473. private _createSSAOPostProcess;
  111474. private _createSSAOCombinePostProcess;
  111475. private _createRandomTexture;
  111476. }
  111477. }
  111478. declare module BABYLON {
  111479. /** @hidden */
  111480. export var standardPixelShader: {
  111481. name: string;
  111482. shader: string;
  111483. };
  111484. }
  111485. declare module BABYLON {
  111486. /**
  111487. * Standard rendering pipeline
  111488. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111489. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111490. */
  111491. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111492. /**
  111493. * Public members
  111494. */
  111495. /**
  111496. * Post-process which contains the original scene color before the pipeline applies all the effects
  111497. */
  111498. originalPostProcess: Nullable<PostProcess>;
  111499. /**
  111500. * Post-process used to down scale an image x4
  111501. */
  111502. downSampleX4PostProcess: Nullable<PostProcess>;
  111503. /**
  111504. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111505. */
  111506. brightPassPostProcess: Nullable<PostProcess>;
  111507. /**
  111508. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111509. */
  111510. blurHPostProcesses: PostProcess[];
  111511. /**
  111512. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111513. */
  111514. blurVPostProcesses: PostProcess[];
  111515. /**
  111516. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111517. */
  111518. textureAdderPostProcess: Nullable<PostProcess>;
  111519. /**
  111520. * Post-process used to create volumetric lighting effect
  111521. */
  111522. volumetricLightPostProcess: Nullable<PostProcess>;
  111523. /**
  111524. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111525. */
  111526. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111527. /**
  111528. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111529. */
  111530. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111531. /**
  111532. * Post-process used to merge the volumetric light effect and the real scene color
  111533. */
  111534. volumetricLightMergePostProces: Nullable<PostProcess>;
  111535. /**
  111536. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111537. */
  111538. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111539. /**
  111540. * Base post-process used to calculate the average luminance of the final image for HDR
  111541. */
  111542. luminancePostProcess: Nullable<PostProcess>;
  111543. /**
  111544. * Post-processes used to create down sample post-processes in order to get
  111545. * the average luminance of the final image for HDR
  111546. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111547. */
  111548. luminanceDownSamplePostProcesses: PostProcess[];
  111549. /**
  111550. * Post-process used to create a HDR effect (light adaptation)
  111551. */
  111552. hdrPostProcess: Nullable<PostProcess>;
  111553. /**
  111554. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111555. */
  111556. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111557. /**
  111558. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111559. */
  111560. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111561. /**
  111562. * Post-process used to merge the final HDR post-process and the real scene color
  111563. */
  111564. hdrFinalPostProcess: Nullable<PostProcess>;
  111565. /**
  111566. * Post-process used to create a lens flare effect
  111567. */
  111568. lensFlarePostProcess: Nullable<PostProcess>;
  111569. /**
  111570. * Post-process that merges the result of the lens flare post-process and the real scene color
  111571. */
  111572. lensFlareComposePostProcess: Nullable<PostProcess>;
  111573. /**
  111574. * Post-process used to create a motion blur effect
  111575. */
  111576. motionBlurPostProcess: Nullable<PostProcess>;
  111577. /**
  111578. * Post-process used to create a depth of field effect
  111579. */
  111580. depthOfFieldPostProcess: Nullable<PostProcess>;
  111581. /**
  111582. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111583. */
  111584. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111585. /**
  111586. * Represents the brightness threshold in order to configure the illuminated surfaces
  111587. */
  111588. brightThreshold: number;
  111589. /**
  111590. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111591. */
  111592. blurWidth: number;
  111593. /**
  111594. * Sets if the blur for highlighted surfaces must be only horizontal
  111595. */
  111596. horizontalBlur: boolean;
  111597. /**
  111598. * Sets the overall exposure used by the pipeline
  111599. */
  111600. exposure: number;
  111601. /**
  111602. * Texture used typically to simulate "dirty" on camera lens
  111603. */
  111604. lensTexture: Nullable<Texture>;
  111605. /**
  111606. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111607. */
  111608. volumetricLightCoefficient: number;
  111609. /**
  111610. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111611. */
  111612. volumetricLightPower: number;
  111613. /**
  111614. * Used the set the blur intensity to smooth the volumetric lights
  111615. */
  111616. volumetricLightBlurScale: number;
  111617. /**
  111618. * Light (spot or directional) used to generate the volumetric lights rays
  111619. * The source light must have a shadow generate so the pipeline can get its
  111620. * depth map
  111621. */
  111622. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111623. /**
  111624. * For eye adaptation, represents the minimum luminance the eye can see
  111625. */
  111626. hdrMinimumLuminance: number;
  111627. /**
  111628. * For eye adaptation, represents the decrease luminance speed
  111629. */
  111630. hdrDecreaseRate: number;
  111631. /**
  111632. * For eye adaptation, represents the increase luminance speed
  111633. */
  111634. hdrIncreaseRate: number;
  111635. /**
  111636. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111637. */
  111638. lensColorTexture: Nullable<Texture>;
  111639. /**
  111640. * The overall strengh for the lens flare effect
  111641. */
  111642. lensFlareStrength: number;
  111643. /**
  111644. * Dispersion coefficient for lens flare ghosts
  111645. */
  111646. lensFlareGhostDispersal: number;
  111647. /**
  111648. * Main lens flare halo width
  111649. */
  111650. lensFlareHaloWidth: number;
  111651. /**
  111652. * Based on the lens distortion effect, defines how much the lens flare result
  111653. * is distorted
  111654. */
  111655. lensFlareDistortionStrength: number;
  111656. /**
  111657. * Lens star texture must be used to simulate rays on the flares and is available
  111658. * in the documentation
  111659. */
  111660. lensStarTexture: Nullable<Texture>;
  111661. /**
  111662. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111663. * flare effect by taking account of the dirt texture
  111664. */
  111665. lensFlareDirtTexture: Nullable<Texture>;
  111666. /**
  111667. * Represents the focal length for the depth of field effect
  111668. */
  111669. depthOfFieldDistance: number;
  111670. /**
  111671. * Represents the blur intensity for the blurred part of the depth of field effect
  111672. */
  111673. depthOfFieldBlurWidth: number;
  111674. /**
  111675. * For motion blur, defines how much the image is blurred by the movement
  111676. */
  111677. motionStrength: number;
  111678. /**
  111679. * List of animations for the pipeline (IAnimatable implementation)
  111680. */
  111681. animations: Animation[];
  111682. /**
  111683. * Private members
  111684. */
  111685. private _scene;
  111686. private _currentDepthOfFieldSource;
  111687. private _basePostProcess;
  111688. private _hdrCurrentLuminance;
  111689. private _floatTextureType;
  111690. private _ratio;
  111691. private _bloomEnabled;
  111692. private _depthOfFieldEnabled;
  111693. private _vlsEnabled;
  111694. private _lensFlareEnabled;
  111695. private _hdrEnabled;
  111696. private _motionBlurEnabled;
  111697. private _fxaaEnabled;
  111698. private _motionBlurSamples;
  111699. private _volumetricLightStepsCount;
  111700. private _samples;
  111701. /**
  111702. * @ignore
  111703. * Specifies if the bloom pipeline is enabled
  111704. */
  111705. BloomEnabled: boolean;
  111706. /**
  111707. * @ignore
  111708. * Specifies if the depth of field pipeline is enabed
  111709. */
  111710. DepthOfFieldEnabled: boolean;
  111711. /**
  111712. * @ignore
  111713. * Specifies if the lens flare pipeline is enabed
  111714. */
  111715. LensFlareEnabled: boolean;
  111716. /**
  111717. * @ignore
  111718. * Specifies if the HDR pipeline is enabled
  111719. */
  111720. HDREnabled: boolean;
  111721. /**
  111722. * @ignore
  111723. * Specifies if the volumetric lights scattering effect is enabled
  111724. */
  111725. VLSEnabled: boolean;
  111726. /**
  111727. * @ignore
  111728. * Specifies if the motion blur effect is enabled
  111729. */
  111730. MotionBlurEnabled: boolean;
  111731. /**
  111732. * Specifies if anti-aliasing is enabled
  111733. */
  111734. fxaaEnabled: boolean;
  111735. /**
  111736. * Specifies the number of steps used to calculate the volumetric lights
  111737. * Typically in interval [50, 200]
  111738. */
  111739. volumetricLightStepsCount: number;
  111740. /**
  111741. * Specifies the number of samples used for the motion blur effect
  111742. * Typically in interval [16, 64]
  111743. */
  111744. motionBlurSamples: number;
  111745. /**
  111746. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111747. */
  111748. samples: number;
  111749. /**
  111750. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111751. * @constructor
  111752. * @param name The rendering pipeline name
  111753. * @param scene The scene linked to this pipeline
  111754. * @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)
  111755. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  111756. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111757. */
  111758. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  111759. private _buildPipeline;
  111760. private _createDownSampleX4PostProcess;
  111761. private _createBrightPassPostProcess;
  111762. private _createBlurPostProcesses;
  111763. private _createTextureAdderPostProcess;
  111764. private _createVolumetricLightPostProcess;
  111765. private _createLuminancePostProcesses;
  111766. private _createHdrPostProcess;
  111767. private _createLensFlarePostProcess;
  111768. private _createDepthOfFieldPostProcess;
  111769. private _createMotionBlurPostProcess;
  111770. private _getDepthTexture;
  111771. private _disposePostProcesses;
  111772. /**
  111773. * Dispose of the pipeline and stop all post processes
  111774. */
  111775. dispose(): void;
  111776. /**
  111777. * Serialize the rendering pipeline (Used when exporting)
  111778. * @returns the serialized object
  111779. */
  111780. serialize(): any;
  111781. /**
  111782. * Parse the serialized pipeline
  111783. * @param source Source pipeline.
  111784. * @param scene The scene to load the pipeline to.
  111785. * @param rootUrl The URL of the serialized pipeline.
  111786. * @returns An instantiated pipeline from the serialized object.
  111787. */
  111788. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  111789. /**
  111790. * Luminance steps
  111791. */
  111792. static LuminanceSteps: number;
  111793. }
  111794. }
  111795. declare module BABYLON {
  111796. /** @hidden */
  111797. export var tonemapPixelShader: {
  111798. name: string;
  111799. shader: string;
  111800. };
  111801. }
  111802. declare module BABYLON {
  111803. /** Defines operator used for tonemapping */
  111804. export enum TonemappingOperator {
  111805. /** Hable */
  111806. Hable = 0,
  111807. /** Reinhard */
  111808. Reinhard = 1,
  111809. /** HejiDawson */
  111810. HejiDawson = 2,
  111811. /** Photographic */
  111812. Photographic = 3
  111813. }
  111814. /**
  111815. * Defines a post process to apply tone mapping
  111816. */
  111817. export class TonemapPostProcess extends PostProcess {
  111818. private _operator;
  111819. /** Defines the required exposure adjustement */
  111820. exposureAdjustment: number;
  111821. /**
  111822. * Creates a new TonemapPostProcess
  111823. * @param name defines the name of the postprocess
  111824. * @param _operator defines the operator to use
  111825. * @param exposureAdjustment defines the required exposure adjustement
  111826. * @param camera defines the camera to use (can be null)
  111827. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  111828. * @param engine defines the hosting engine (can be ignore if camera is set)
  111829. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  111830. */
  111831. constructor(name: string, _operator: TonemappingOperator,
  111832. /** Defines the required exposure adjustement */
  111833. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  111834. }
  111835. }
  111836. declare module BABYLON {
  111837. /** @hidden */
  111838. export var depthVertexShader: {
  111839. name: string;
  111840. shader: string;
  111841. };
  111842. }
  111843. declare module BABYLON {
  111844. /** @hidden */
  111845. export var volumetricLightScatteringPixelShader: {
  111846. name: string;
  111847. shader: string;
  111848. };
  111849. }
  111850. declare module BABYLON {
  111851. /** @hidden */
  111852. export var volumetricLightScatteringPassPixelShader: {
  111853. name: string;
  111854. shader: string;
  111855. };
  111856. }
  111857. declare module BABYLON {
  111858. /**
  111859. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  111860. */
  111861. export class VolumetricLightScatteringPostProcess extends PostProcess {
  111862. private _volumetricLightScatteringPass;
  111863. private _volumetricLightScatteringRTT;
  111864. private _viewPort;
  111865. private _screenCoordinates;
  111866. private _cachedDefines;
  111867. /**
  111868. * If not undefined, the mesh position is computed from the attached node position
  111869. */
  111870. attachedNode: {
  111871. position: Vector3;
  111872. };
  111873. /**
  111874. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  111875. */
  111876. customMeshPosition: Vector3;
  111877. /**
  111878. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  111879. */
  111880. useCustomMeshPosition: boolean;
  111881. /**
  111882. * If the post-process should inverse the light scattering direction
  111883. */
  111884. invert: boolean;
  111885. /**
  111886. * The internal mesh used by the post-process
  111887. */
  111888. mesh: Mesh;
  111889. /**
  111890. * @hidden
  111891. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  111892. */
  111893. useDiffuseColor: boolean;
  111894. /**
  111895. * Array containing the excluded meshes not rendered in the internal pass
  111896. */
  111897. excludedMeshes: AbstractMesh[];
  111898. /**
  111899. * Controls the overall intensity of the post-process
  111900. */
  111901. exposure: number;
  111902. /**
  111903. * Dissipates each sample's contribution in range [0, 1]
  111904. */
  111905. decay: number;
  111906. /**
  111907. * Controls the overall intensity of each sample
  111908. */
  111909. weight: number;
  111910. /**
  111911. * Controls the density of each sample
  111912. */
  111913. density: number;
  111914. /**
  111915. * @constructor
  111916. * @param name The post-process name
  111917. * @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)
  111918. * @param camera The camera that the post-process will be attached to
  111919. * @param mesh The mesh used to create the light scattering
  111920. * @param samples The post-process quality, default 100
  111921. * @param samplingModeThe post-process filtering mode
  111922. * @param engine The babylon engine
  111923. * @param reusable If the post-process is reusable
  111924. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  111925. */
  111926. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  111927. /**
  111928. * Returns the string "VolumetricLightScatteringPostProcess"
  111929. * @returns "VolumetricLightScatteringPostProcess"
  111930. */
  111931. getClassName(): string;
  111932. private _isReady;
  111933. /**
  111934. * Sets the new light position for light scattering effect
  111935. * @param position The new custom light position
  111936. */
  111937. setCustomMeshPosition(position: Vector3): void;
  111938. /**
  111939. * Returns the light position for light scattering effect
  111940. * @return Vector3 The custom light position
  111941. */
  111942. getCustomMeshPosition(): Vector3;
  111943. /**
  111944. * Disposes the internal assets and detaches the post-process from the camera
  111945. */
  111946. dispose(camera: Camera): void;
  111947. /**
  111948. * Returns the render target texture used by the post-process
  111949. * @return the render target texture used by the post-process
  111950. */
  111951. getPass(): RenderTargetTexture;
  111952. private _meshExcluded;
  111953. private _createPass;
  111954. private _updateMeshScreenCoordinates;
  111955. /**
  111956. * Creates a default mesh for the Volumeric Light Scattering post-process
  111957. * @param name The mesh name
  111958. * @param scene The scene where to create the mesh
  111959. * @return the default mesh
  111960. */
  111961. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  111962. }
  111963. }
  111964. declare module BABYLON {
  111965. interface Scene {
  111966. /** @hidden (Backing field) */
  111967. _boundingBoxRenderer: BoundingBoxRenderer;
  111968. /** @hidden (Backing field) */
  111969. _forceShowBoundingBoxes: boolean;
  111970. /**
  111971. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  111972. */
  111973. forceShowBoundingBoxes: boolean;
  111974. /**
  111975. * Gets the bounding box renderer associated with the scene
  111976. * @returns a BoundingBoxRenderer
  111977. */
  111978. getBoundingBoxRenderer(): BoundingBoxRenderer;
  111979. }
  111980. interface AbstractMesh {
  111981. /** @hidden (Backing field) */
  111982. _showBoundingBox: boolean;
  111983. /**
  111984. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  111985. */
  111986. showBoundingBox: boolean;
  111987. }
  111988. /**
  111989. * Component responsible of rendering the bounding box of the meshes in a scene.
  111990. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  111991. */
  111992. export class BoundingBoxRenderer implements ISceneComponent {
  111993. /**
  111994. * The component name helpfull to identify the component in the list of scene components.
  111995. */
  111996. readonly name: string;
  111997. /**
  111998. * The scene the component belongs to.
  111999. */
  112000. scene: Scene;
  112001. /**
  112002. * Color of the bounding box lines placed in front of an object
  112003. */
  112004. frontColor: Color3;
  112005. /**
  112006. * Color of the bounding box lines placed behind an object
  112007. */
  112008. backColor: Color3;
  112009. /**
  112010. * Defines if the renderer should show the back lines or not
  112011. */
  112012. showBackLines: boolean;
  112013. /**
  112014. * @hidden
  112015. */
  112016. renderList: SmartArray<BoundingBox>;
  112017. private _colorShader;
  112018. private _vertexBuffers;
  112019. private _indexBuffer;
  112020. /**
  112021. * Instantiates a new bounding box renderer in a scene.
  112022. * @param scene the scene the renderer renders in
  112023. */
  112024. constructor(scene: Scene);
  112025. /**
  112026. * Registers the component in a given scene
  112027. */
  112028. register(): void;
  112029. private _evaluateSubMesh;
  112030. private _activeMesh;
  112031. private _prepareRessources;
  112032. private _createIndexBuffer;
  112033. /**
  112034. * Rebuilds the elements related to this component in case of
  112035. * context lost for instance.
  112036. */
  112037. rebuild(): void;
  112038. /**
  112039. * @hidden
  112040. */
  112041. reset(): void;
  112042. /**
  112043. * Render the bounding boxes of a specific rendering group
  112044. * @param renderingGroupId defines the rendering group to render
  112045. */
  112046. render(renderingGroupId: number): void;
  112047. /**
  112048. * In case of occlusion queries, we can render the occlusion bounding box through this method
  112049. * @param mesh Define the mesh to render the occlusion bounding box for
  112050. */
  112051. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  112052. /**
  112053. * Dispose and release the resources attached to this renderer.
  112054. */
  112055. dispose(): void;
  112056. }
  112057. }
  112058. declare module BABYLON {
  112059. /** @hidden */
  112060. export var depthPixelShader: {
  112061. name: string;
  112062. shader: string;
  112063. };
  112064. }
  112065. declare module BABYLON {
  112066. /**
  112067. * This represents a depth renderer in Babylon.
  112068. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  112069. */
  112070. export class DepthRenderer {
  112071. private _scene;
  112072. private _depthMap;
  112073. private _effect;
  112074. private _cachedDefines;
  112075. private _camera;
  112076. /**
  112077. * Specifiess that the depth renderer will only be used within
  112078. * the camera it is created for.
  112079. * This can help forcing its rendering during the camera processing.
  112080. */
  112081. useOnlyInActiveCamera: boolean;
  112082. /** @hidden */
  112083. static _SceneComponentInitialization: (scene: Scene) => void;
  112084. /**
  112085. * Instantiates a depth renderer
  112086. * @param scene The scene the renderer belongs to
  112087. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  112088. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  112089. */
  112090. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  112091. /**
  112092. * Creates the depth rendering effect and checks if the effect is ready.
  112093. * @param subMesh The submesh to be used to render the depth map of
  112094. * @param useInstances If multiple world instances should be used
  112095. * @returns if the depth renderer is ready to render the depth map
  112096. */
  112097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112098. /**
  112099. * Gets the texture which the depth map will be written to.
  112100. * @returns The depth map texture
  112101. */
  112102. getDepthMap(): RenderTargetTexture;
  112103. /**
  112104. * Disposes of the depth renderer.
  112105. */
  112106. dispose(): void;
  112107. }
  112108. }
  112109. declare module BABYLON {
  112110. interface Scene {
  112111. /** @hidden (Backing field) */
  112112. _depthRenderer: {
  112113. [id: string]: DepthRenderer;
  112114. };
  112115. /**
  112116. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  112117. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  112118. * @returns the created depth renderer
  112119. */
  112120. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  112121. /**
  112122. * Disables a depth renderer for a given camera
  112123. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  112124. */
  112125. disableDepthRenderer(camera?: Nullable<Camera>): void;
  112126. }
  112127. /**
  112128. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  112129. * in several rendering techniques.
  112130. */
  112131. export class DepthRendererSceneComponent implements ISceneComponent {
  112132. /**
  112133. * The component name helpfull to identify the component in the list of scene components.
  112134. */
  112135. readonly name: string;
  112136. /**
  112137. * The scene the component belongs to.
  112138. */
  112139. scene: Scene;
  112140. /**
  112141. * Creates a new instance of the component for the given scene
  112142. * @param scene Defines the scene to register the component in
  112143. */
  112144. constructor(scene: Scene);
  112145. /**
  112146. * Registers the component in a given scene
  112147. */
  112148. register(): void;
  112149. /**
  112150. * Rebuilds the elements related to this component in case of
  112151. * context lost for instance.
  112152. */
  112153. rebuild(): void;
  112154. /**
  112155. * Disposes the component and the associated ressources
  112156. */
  112157. dispose(): void;
  112158. private _gatherRenderTargets;
  112159. private _gatherActiveCameraRenderTargets;
  112160. }
  112161. }
  112162. declare module BABYLON {
  112163. /** @hidden */
  112164. export var outlinePixelShader: {
  112165. name: string;
  112166. shader: string;
  112167. };
  112168. }
  112169. declare module BABYLON {
  112170. /** @hidden */
  112171. export var outlineVertexShader: {
  112172. name: string;
  112173. shader: string;
  112174. };
  112175. }
  112176. declare module BABYLON {
  112177. interface Scene {
  112178. /** @hidden */
  112179. _outlineRenderer: OutlineRenderer;
  112180. /**
  112181. * Gets the outline renderer associated with the scene
  112182. * @returns a OutlineRenderer
  112183. */
  112184. getOutlineRenderer(): OutlineRenderer;
  112185. }
  112186. interface AbstractMesh {
  112187. /** @hidden (Backing field) */
  112188. _renderOutline: boolean;
  112189. /**
  112190. * Gets or sets a boolean indicating if the outline must be rendered as well
  112191. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  112192. */
  112193. renderOutline: boolean;
  112194. /** @hidden (Backing field) */
  112195. _renderOverlay: boolean;
  112196. /**
  112197. * Gets or sets a boolean indicating if the overlay must be rendered as well
  112198. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  112199. */
  112200. renderOverlay: boolean;
  112201. }
  112202. /**
  112203. * This class is responsible to draw bothe outline/overlay of meshes.
  112204. * It should not be used directly but through the available method on mesh.
  112205. */
  112206. export class OutlineRenderer implements ISceneComponent {
  112207. /**
  112208. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  112209. */
  112210. private static _StencilReference;
  112211. /**
  112212. * The name of the component. Each component must have a unique name.
  112213. */
  112214. name: string;
  112215. /**
  112216. * The scene the component belongs to.
  112217. */
  112218. scene: Scene;
  112219. /**
  112220. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  112221. */
  112222. zOffset: number;
  112223. private _engine;
  112224. private _effect;
  112225. private _cachedDefines;
  112226. private _savedDepthWrite;
  112227. /**
  112228. * Instantiates a new outline renderer. (There could be only one per scene).
  112229. * @param scene Defines the scene it belongs to
  112230. */
  112231. constructor(scene: Scene);
  112232. /**
  112233. * Register the component to one instance of a scene.
  112234. */
  112235. register(): void;
  112236. /**
  112237. * Rebuilds the elements related to this component in case of
  112238. * context lost for instance.
  112239. */
  112240. rebuild(): void;
  112241. /**
  112242. * Disposes the component and the associated ressources.
  112243. */
  112244. dispose(): void;
  112245. /**
  112246. * Renders the outline in the canvas.
  112247. * @param subMesh Defines the sumesh to render
  112248. * @param batch Defines the batch of meshes in case of instances
  112249. * @param useOverlay Defines if the rendering is for the overlay or the outline
  112250. */
  112251. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  112252. /**
  112253. * Returns whether or not the outline renderer is ready for a given submesh.
  112254. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  112255. * @param subMesh Defines the submesh to check readyness for
  112256. * @param useInstances Defines wheter wee are trying to render instances or not
  112257. * @returns true if ready otherwise false
  112258. */
  112259. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112260. private _beforeRenderingMesh;
  112261. private _afterRenderingMesh;
  112262. }
  112263. }
  112264. declare module BABYLON {
  112265. /**
  112266. * Defines the list of states available for a task inside a AssetsManager
  112267. */
  112268. export enum AssetTaskState {
  112269. /**
  112270. * Initialization
  112271. */
  112272. INIT = 0,
  112273. /**
  112274. * Running
  112275. */
  112276. RUNNING = 1,
  112277. /**
  112278. * Done
  112279. */
  112280. DONE = 2,
  112281. /**
  112282. * Error
  112283. */
  112284. ERROR = 3
  112285. }
  112286. /**
  112287. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112288. */
  112289. export abstract class AbstractAssetTask {
  112290. /**
  112291. * Task name
  112292. */ name: string;
  112293. /**
  112294. * Callback called when the task is successful
  112295. */
  112296. onSuccess: (task: any) => void;
  112297. /**
  112298. * Callback called when the task is not successful
  112299. */
  112300. onError: (task: any, message?: string, exception?: any) => void;
  112301. /**
  112302. * Creates a new AssetsManager
  112303. * @param name defines the name of the task
  112304. */
  112305. constructor(
  112306. /**
  112307. * Task name
  112308. */ name: string);
  112309. private _isCompleted;
  112310. private _taskState;
  112311. private _errorObject;
  112312. /**
  112313. * Get if the task is completed
  112314. */
  112315. readonly isCompleted: boolean;
  112316. /**
  112317. * Gets the current state of the task
  112318. */
  112319. readonly taskState: AssetTaskState;
  112320. /**
  112321. * Gets the current error object (if task is in error)
  112322. */
  112323. readonly errorObject: {
  112324. message?: string;
  112325. exception?: any;
  112326. };
  112327. /**
  112328. * Internal only
  112329. * @hidden
  112330. */
  112331. _setErrorObject(message?: string, exception?: any): void;
  112332. /**
  112333. * Execute the current task
  112334. * @param scene defines the scene where you want your assets to be loaded
  112335. * @param onSuccess is a callback called when the task is successfully executed
  112336. * @param onError is a callback called if an error occurs
  112337. */
  112338. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112339. /**
  112340. * Execute the current task
  112341. * @param scene defines the scene where you want your assets to be loaded
  112342. * @param onSuccess is a callback called when the task is successfully executed
  112343. * @param onError is a callback called if an error occurs
  112344. */
  112345. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112346. /**
  112347. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112348. * This can be used with failed tasks that have the reason for failure fixed.
  112349. */
  112350. reset(): void;
  112351. private onErrorCallback;
  112352. private onDoneCallback;
  112353. }
  112354. /**
  112355. * Define the interface used by progress events raised during assets loading
  112356. */
  112357. export interface IAssetsProgressEvent {
  112358. /**
  112359. * Defines the number of remaining tasks to process
  112360. */
  112361. remainingCount: number;
  112362. /**
  112363. * Defines the total number of tasks
  112364. */
  112365. totalCount: number;
  112366. /**
  112367. * Defines the task that was just processed
  112368. */
  112369. task: AbstractAssetTask;
  112370. }
  112371. /**
  112372. * Class used to share progress information about assets loading
  112373. */
  112374. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112375. /**
  112376. * Defines the number of remaining tasks to process
  112377. */
  112378. remainingCount: number;
  112379. /**
  112380. * Defines the total number of tasks
  112381. */
  112382. totalCount: number;
  112383. /**
  112384. * Defines the task that was just processed
  112385. */
  112386. task: AbstractAssetTask;
  112387. /**
  112388. * Creates a AssetsProgressEvent
  112389. * @param remainingCount defines the number of remaining tasks to process
  112390. * @param totalCount defines the total number of tasks
  112391. * @param task defines the task that was just processed
  112392. */
  112393. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112394. }
  112395. /**
  112396. * Define a task used by AssetsManager to load meshes
  112397. */
  112398. export class MeshAssetTask extends AbstractAssetTask {
  112399. /**
  112400. * Defines the name of the task
  112401. */
  112402. name: string;
  112403. /**
  112404. * Defines the list of mesh's names you want to load
  112405. */
  112406. meshesNames: any;
  112407. /**
  112408. * Defines the root url to use as a base to load your meshes and associated resources
  112409. */
  112410. rootUrl: string;
  112411. /**
  112412. * Defines the filename of the scene to load from
  112413. */
  112414. sceneFilename: string;
  112415. /**
  112416. * Gets the list of loaded meshes
  112417. */
  112418. loadedMeshes: Array<AbstractMesh>;
  112419. /**
  112420. * Gets the list of loaded particle systems
  112421. */
  112422. loadedParticleSystems: Array<IParticleSystem>;
  112423. /**
  112424. * Gets the list of loaded skeletons
  112425. */
  112426. loadedSkeletons: Array<Skeleton>;
  112427. /**
  112428. * Gets the list of loaded animation groups
  112429. */
  112430. loadedAnimationGroups: Array<AnimationGroup>;
  112431. /**
  112432. * Callback called when the task is successful
  112433. */
  112434. onSuccess: (task: MeshAssetTask) => void;
  112435. /**
  112436. * Callback called when the task is successful
  112437. */
  112438. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112439. /**
  112440. * Creates a new MeshAssetTask
  112441. * @param name defines the name of the task
  112442. * @param meshesNames defines the list of mesh's names you want to load
  112443. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112444. * @param sceneFilename defines the filename of the scene to load from
  112445. */
  112446. constructor(
  112447. /**
  112448. * Defines the name of the task
  112449. */
  112450. name: string,
  112451. /**
  112452. * Defines the list of mesh's names you want to load
  112453. */
  112454. meshesNames: any,
  112455. /**
  112456. * Defines the root url to use as a base to load your meshes and associated resources
  112457. */
  112458. rootUrl: string,
  112459. /**
  112460. * Defines the filename of the scene to load from
  112461. */
  112462. sceneFilename: string);
  112463. /**
  112464. * Execute the current task
  112465. * @param scene defines the scene where you want your assets to be loaded
  112466. * @param onSuccess is a callback called when the task is successfully executed
  112467. * @param onError is a callback called if an error occurs
  112468. */
  112469. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112470. }
  112471. /**
  112472. * Define a task used by AssetsManager to load text content
  112473. */
  112474. export class TextFileAssetTask extends AbstractAssetTask {
  112475. /**
  112476. * Defines the name of the task
  112477. */
  112478. name: string;
  112479. /**
  112480. * Defines the location of the file to load
  112481. */
  112482. url: string;
  112483. /**
  112484. * Gets the loaded text string
  112485. */
  112486. text: string;
  112487. /**
  112488. * Callback called when the task is successful
  112489. */
  112490. onSuccess: (task: TextFileAssetTask) => void;
  112491. /**
  112492. * Callback called when the task is successful
  112493. */
  112494. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112495. /**
  112496. * Creates a new TextFileAssetTask object
  112497. * @param name defines the name of the task
  112498. * @param url defines the location of the file to load
  112499. */
  112500. constructor(
  112501. /**
  112502. * Defines the name of the task
  112503. */
  112504. name: string,
  112505. /**
  112506. * Defines the location of the file to load
  112507. */
  112508. url: string);
  112509. /**
  112510. * Execute the current task
  112511. * @param scene defines the scene where you want your assets to be loaded
  112512. * @param onSuccess is a callback called when the task is successfully executed
  112513. * @param onError is a callback called if an error occurs
  112514. */
  112515. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112516. }
  112517. /**
  112518. * Define a task used by AssetsManager to load binary data
  112519. */
  112520. export class BinaryFileAssetTask extends AbstractAssetTask {
  112521. /**
  112522. * Defines the name of the task
  112523. */
  112524. name: string;
  112525. /**
  112526. * Defines the location of the file to load
  112527. */
  112528. url: string;
  112529. /**
  112530. * Gets the lodaded data (as an array buffer)
  112531. */
  112532. data: ArrayBuffer;
  112533. /**
  112534. * Callback called when the task is successful
  112535. */
  112536. onSuccess: (task: BinaryFileAssetTask) => void;
  112537. /**
  112538. * Callback called when the task is successful
  112539. */
  112540. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112541. /**
  112542. * Creates a new BinaryFileAssetTask object
  112543. * @param name defines the name of the new task
  112544. * @param url defines the location of the file to load
  112545. */
  112546. constructor(
  112547. /**
  112548. * Defines the name of the task
  112549. */
  112550. name: string,
  112551. /**
  112552. * Defines the location of the file to load
  112553. */
  112554. url: string);
  112555. /**
  112556. * Execute the current task
  112557. * @param scene defines the scene where you want your assets to be loaded
  112558. * @param onSuccess is a callback called when the task is successfully executed
  112559. * @param onError is a callback called if an error occurs
  112560. */
  112561. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112562. }
  112563. /**
  112564. * Define a task used by AssetsManager to load images
  112565. */
  112566. export class ImageAssetTask extends AbstractAssetTask {
  112567. /**
  112568. * Defines the name of the task
  112569. */
  112570. name: string;
  112571. /**
  112572. * Defines the location of the image to load
  112573. */
  112574. url: string;
  112575. /**
  112576. * Gets the loaded images
  112577. */
  112578. image: HTMLImageElement;
  112579. /**
  112580. * Callback called when the task is successful
  112581. */
  112582. onSuccess: (task: ImageAssetTask) => void;
  112583. /**
  112584. * Callback called when the task is successful
  112585. */
  112586. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112587. /**
  112588. * Creates a new ImageAssetTask
  112589. * @param name defines the name of the task
  112590. * @param url defines the location of the image to load
  112591. */
  112592. constructor(
  112593. /**
  112594. * Defines the name of the task
  112595. */
  112596. name: string,
  112597. /**
  112598. * Defines the location of the image to load
  112599. */
  112600. url: string);
  112601. /**
  112602. * Execute the current task
  112603. * @param scene defines the scene where you want your assets to be loaded
  112604. * @param onSuccess is a callback called when the task is successfully executed
  112605. * @param onError is a callback called if an error occurs
  112606. */
  112607. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112608. }
  112609. /**
  112610. * Defines the interface used by texture loading tasks
  112611. */
  112612. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112613. /**
  112614. * Gets the loaded texture
  112615. */
  112616. texture: TEX;
  112617. }
  112618. /**
  112619. * Define a task used by AssetsManager to load 2D textures
  112620. */
  112621. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112622. /**
  112623. * Defines the name of the task
  112624. */
  112625. name: string;
  112626. /**
  112627. * Defines the location of the file to load
  112628. */
  112629. url: string;
  112630. /**
  112631. * Defines if mipmap should not be generated (default is false)
  112632. */
  112633. noMipmap?: boolean | undefined;
  112634. /**
  112635. * Defines if texture must be inverted on Y axis (default is false)
  112636. */
  112637. invertY?: boolean | undefined;
  112638. /**
  112639. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112640. */
  112641. samplingMode: number;
  112642. /**
  112643. * Gets the loaded texture
  112644. */
  112645. texture: Texture;
  112646. /**
  112647. * Callback called when the task is successful
  112648. */
  112649. onSuccess: (task: TextureAssetTask) => void;
  112650. /**
  112651. * Callback called when the task is successful
  112652. */
  112653. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112654. /**
  112655. * Creates a new TextureAssetTask object
  112656. * @param name defines the name of the task
  112657. * @param url defines the location of the file to load
  112658. * @param noMipmap defines if mipmap should not be generated (default is false)
  112659. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112660. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112661. */
  112662. constructor(
  112663. /**
  112664. * Defines the name of the task
  112665. */
  112666. name: string,
  112667. /**
  112668. * Defines the location of the file to load
  112669. */
  112670. url: string,
  112671. /**
  112672. * Defines if mipmap should not be generated (default is false)
  112673. */
  112674. noMipmap?: boolean | undefined,
  112675. /**
  112676. * Defines if texture must be inverted on Y axis (default is false)
  112677. */
  112678. invertY?: boolean | undefined,
  112679. /**
  112680. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112681. */
  112682. samplingMode?: number);
  112683. /**
  112684. * Execute the current task
  112685. * @param scene defines the scene where you want your assets to be loaded
  112686. * @param onSuccess is a callback called when the task is successfully executed
  112687. * @param onError is a callback called if an error occurs
  112688. */
  112689. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112690. }
  112691. /**
  112692. * Define a task used by AssetsManager to load cube textures
  112693. */
  112694. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112695. /**
  112696. * Defines the name of the task
  112697. */
  112698. name: string;
  112699. /**
  112700. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112701. */
  112702. url: string;
  112703. /**
  112704. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112705. */
  112706. extensions?: string[] | undefined;
  112707. /**
  112708. * Defines if mipmaps should not be generated (default is false)
  112709. */
  112710. noMipmap?: boolean | undefined;
  112711. /**
  112712. * Defines the explicit list of files (undefined by default)
  112713. */
  112714. files?: string[] | undefined;
  112715. /**
  112716. * Gets the loaded texture
  112717. */
  112718. texture: CubeTexture;
  112719. /**
  112720. * Callback called when the task is successful
  112721. */
  112722. onSuccess: (task: CubeTextureAssetTask) => void;
  112723. /**
  112724. * Callback called when the task is successful
  112725. */
  112726. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112727. /**
  112728. * Creates a new CubeTextureAssetTask
  112729. * @param name defines the name of the task
  112730. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112731. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112732. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112733. * @param files defines the explicit list of files (undefined by default)
  112734. */
  112735. constructor(
  112736. /**
  112737. * Defines the name of the task
  112738. */
  112739. name: string,
  112740. /**
  112741. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112742. */
  112743. url: string,
  112744. /**
  112745. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112746. */
  112747. extensions?: string[] | undefined,
  112748. /**
  112749. * Defines if mipmaps should not be generated (default is false)
  112750. */
  112751. noMipmap?: boolean | undefined,
  112752. /**
  112753. * Defines the explicit list of files (undefined by default)
  112754. */
  112755. files?: string[] | undefined);
  112756. /**
  112757. * Execute the current task
  112758. * @param scene defines the scene where you want your assets to be loaded
  112759. * @param onSuccess is a callback called when the task is successfully executed
  112760. * @param onError is a callback called if an error occurs
  112761. */
  112762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112763. }
  112764. /**
  112765. * Define a task used by AssetsManager to load HDR cube textures
  112766. */
  112767. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  112768. /**
  112769. * Defines the name of the task
  112770. */
  112771. name: string;
  112772. /**
  112773. * Defines the location of the file to load
  112774. */
  112775. url: string;
  112776. /**
  112777. * Defines the desired size (the more it increases the longer the generation will be)
  112778. */
  112779. size: number;
  112780. /**
  112781. * Defines if mipmaps should not be generated (default is false)
  112782. */
  112783. noMipmap: boolean;
  112784. /**
  112785. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112786. */
  112787. generateHarmonics: boolean;
  112788. /**
  112789. * 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)
  112790. */
  112791. gammaSpace: boolean;
  112792. /**
  112793. * Internal Use Only
  112794. */
  112795. reserved: boolean;
  112796. /**
  112797. * Gets the loaded texture
  112798. */
  112799. texture: HDRCubeTexture;
  112800. /**
  112801. * Callback called when the task is successful
  112802. */
  112803. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  112804. /**
  112805. * Callback called when the task is successful
  112806. */
  112807. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  112808. /**
  112809. * Creates a new HDRCubeTextureAssetTask object
  112810. * @param name defines the name of the task
  112811. * @param url defines the location of the file to load
  112812. * @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.
  112813. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112814. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112815. * @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)
  112816. * @param reserved Internal use only
  112817. */
  112818. constructor(
  112819. /**
  112820. * Defines the name of the task
  112821. */
  112822. name: string,
  112823. /**
  112824. * Defines the location of the file to load
  112825. */
  112826. url: string,
  112827. /**
  112828. * Defines the desired size (the more it increases the longer the generation will be)
  112829. */
  112830. size: number,
  112831. /**
  112832. * Defines if mipmaps should not be generated (default is false)
  112833. */
  112834. noMipmap?: boolean,
  112835. /**
  112836. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112837. */
  112838. generateHarmonics?: boolean,
  112839. /**
  112840. * 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)
  112841. */
  112842. gammaSpace?: boolean,
  112843. /**
  112844. * Internal Use Only
  112845. */
  112846. reserved?: boolean);
  112847. /**
  112848. * Execute the current task
  112849. * @param scene defines the scene where you want your assets to be loaded
  112850. * @param onSuccess is a callback called when the task is successfully executed
  112851. * @param onError is a callback called if an error occurs
  112852. */
  112853. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112854. }
  112855. /**
  112856. * This class can be used to easily import assets into a scene
  112857. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  112858. */
  112859. export class AssetsManager {
  112860. private _scene;
  112861. private _isLoading;
  112862. protected _tasks: AbstractAssetTask[];
  112863. protected _waitingTasksCount: number;
  112864. protected _totalTasksCount: number;
  112865. /**
  112866. * Callback called when all tasks are processed
  112867. */
  112868. onFinish: (tasks: AbstractAssetTask[]) => void;
  112869. /**
  112870. * Callback called when a task is successful
  112871. */
  112872. onTaskSuccess: (task: AbstractAssetTask) => void;
  112873. /**
  112874. * Callback called when a task had an error
  112875. */
  112876. onTaskError: (task: AbstractAssetTask) => void;
  112877. /**
  112878. * Callback called when a task is done (whatever the result is)
  112879. */
  112880. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  112881. /**
  112882. * Observable called when all tasks are processed
  112883. */
  112884. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  112885. /**
  112886. * Observable called when a task had an error
  112887. */
  112888. onTaskErrorObservable: Observable<AbstractAssetTask>;
  112889. /**
  112890. * Observable called when all tasks were executed
  112891. */
  112892. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  112893. /**
  112894. * Observable called when a task is done (whatever the result is)
  112895. */
  112896. onProgressObservable: Observable<IAssetsProgressEvent>;
  112897. /**
  112898. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  112899. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112900. */
  112901. useDefaultLoadingScreen: boolean;
  112902. /**
  112903. * Creates a new AssetsManager
  112904. * @param scene defines the scene to work on
  112905. */
  112906. constructor(scene: Scene);
  112907. /**
  112908. * Add a MeshAssetTask to the list of active tasks
  112909. * @param taskName defines the name of the new task
  112910. * @param meshesNames defines the name of meshes to load
  112911. * @param rootUrl defines the root url to use to locate files
  112912. * @param sceneFilename defines the filename of the scene file
  112913. * @returns a new MeshAssetTask object
  112914. */
  112915. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  112916. /**
  112917. * Add a TextFileAssetTask to the list of active tasks
  112918. * @param taskName defines the name of the new task
  112919. * @param url defines the url of the file to load
  112920. * @returns a new TextFileAssetTask object
  112921. */
  112922. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  112923. /**
  112924. * Add a BinaryFileAssetTask to the list of active tasks
  112925. * @param taskName defines the name of the new task
  112926. * @param url defines the url of the file to load
  112927. * @returns a new BinaryFileAssetTask object
  112928. */
  112929. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  112930. /**
  112931. * Add a ImageAssetTask to the list of active tasks
  112932. * @param taskName defines the name of the new task
  112933. * @param url defines the url of the file to load
  112934. * @returns a new ImageAssetTask object
  112935. */
  112936. addImageTask(taskName: string, url: string): ImageAssetTask;
  112937. /**
  112938. * Add a TextureAssetTask to the list of active tasks
  112939. * @param taskName defines the name of the new task
  112940. * @param url defines the url of the file to load
  112941. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112942. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  112943. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112944. * @returns a new TextureAssetTask object
  112945. */
  112946. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  112947. /**
  112948. * Add a CubeTextureAssetTask to the list of active tasks
  112949. * @param taskName defines the name of the new task
  112950. * @param url defines the url of the file to load
  112951. * @param extensions defines the extension to use to load the cube map (can be null)
  112952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112953. * @param files defines the list of files to load (can be null)
  112954. * @returns a new CubeTextureAssetTask object
  112955. */
  112956. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  112957. /**
  112958. *
  112959. * Add a HDRCubeTextureAssetTask to the list of active tasks
  112960. * @param taskName defines the name of the new task
  112961. * @param url defines the url of the file to load
  112962. * @param size defines the size you want for the cubemap (can be null)
  112963. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112964. * @param generateHarmonics defines if you want to automatically generate (true by default)
  112965. * @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)
  112966. * @param reserved Internal use only
  112967. * @returns a new HDRCubeTextureAssetTask object
  112968. */
  112969. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  112970. /**
  112971. * Remove a task from the assets manager.
  112972. * @param task the task to remove
  112973. */
  112974. removeTask(task: AbstractAssetTask): void;
  112975. private _decreaseWaitingTasksCount;
  112976. private _runTask;
  112977. /**
  112978. * Reset the AssetsManager and remove all tasks
  112979. * @return the current instance of the AssetsManager
  112980. */
  112981. reset(): AssetsManager;
  112982. /**
  112983. * Start the loading process
  112984. * @return the current instance of the AssetsManager
  112985. */
  112986. load(): AssetsManager;
  112987. /**
  112988. * Start the loading process as an async operation
  112989. * @return a promise returning the list of failed tasks
  112990. */
  112991. loadAsync(): Promise<void>;
  112992. }
  112993. }
  112994. declare module BABYLON {
  112995. /**
  112996. * Wrapper class for promise with external resolve and reject.
  112997. */
  112998. export class Deferred<T> {
  112999. /**
  113000. * The promise associated with this deferred object.
  113001. */
  113002. readonly promise: Promise<T>;
  113003. private _resolve;
  113004. private _reject;
  113005. /**
  113006. * The resolve method of the promise associated with this deferred object.
  113007. */
  113008. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  113009. /**
  113010. * The reject method of the promise associated with this deferred object.
  113011. */
  113012. readonly reject: (reason?: any) => void;
  113013. /**
  113014. * Constructor for this deferred object.
  113015. */
  113016. constructor();
  113017. }
  113018. }
  113019. declare module BABYLON {
  113020. /**
  113021. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  113022. */
  113023. export class MeshExploder {
  113024. private _centerMesh;
  113025. private _meshes;
  113026. private _meshesOrigins;
  113027. private _toCenterVectors;
  113028. private _scaledDirection;
  113029. private _newPosition;
  113030. private _centerPosition;
  113031. /**
  113032. * Explodes meshes from a center mesh.
  113033. * @param meshes The meshes to explode.
  113034. * @param centerMesh The mesh to be center of explosion.
  113035. */
  113036. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  113037. private _setCenterMesh;
  113038. /**
  113039. * Get class name
  113040. * @returns "MeshExploder"
  113041. */
  113042. getClassName(): string;
  113043. /**
  113044. * "Exploded meshes"
  113045. * @returns Array of meshes with the centerMesh at index 0.
  113046. */
  113047. getMeshes(): Array<Mesh>;
  113048. /**
  113049. * Explodes meshes giving a specific direction
  113050. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  113051. */
  113052. explode(direction?: number): void;
  113053. }
  113054. }
  113055. declare module BABYLON {
  113056. /**
  113057. * Class used to help managing file picking and drag'n'drop
  113058. */
  113059. export class FilesInput {
  113060. /**
  113061. * List of files ready to be loaded
  113062. */
  113063. static readonly FilesToLoad: {
  113064. [key: string]: File;
  113065. };
  113066. /**
  113067. * Callback called when a file is processed
  113068. */
  113069. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  113070. private _engine;
  113071. private _currentScene;
  113072. private _sceneLoadedCallback;
  113073. private _progressCallback;
  113074. private _additionalRenderLoopLogicCallback;
  113075. private _textureLoadingCallback;
  113076. private _startingProcessingFilesCallback;
  113077. private _onReloadCallback;
  113078. private _errorCallback;
  113079. private _elementToMonitor;
  113080. private _sceneFileToLoad;
  113081. private _filesToLoad;
  113082. /**
  113083. * Creates a new FilesInput
  113084. * @param engine defines the rendering engine
  113085. * @param scene defines the hosting scene
  113086. * @param sceneLoadedCallback callback called when scene is loaded
  113087. * @param progressCallback callback called to track progress
  113088. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  113089. * @param textureLoadingCallback callback called when a texture is loading
  113090. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  113091. * @param onReloadCallback callback called when a reload is requested
  113092. * @param errorCallback callback call if an error occurs
  113093. */
  113094. 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);
  113095. private _dragEnterHandler;
  113096. private _dragOverHandler;
  113097. private _dropHandler;
  113098. /**
  113099. * Calls this function to listen to drag'n'drop events on a specific DOM element
  113100. * @param elementToMonitor defines the DOM element to track
  113101. */
  113102. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  113103. /**
  113104. * Release all associated resources
  113105. */
  113106. dispose(): void;
  113107. private renderFunction;
  113108. private drag;
  113109. private drop;
  113110. private _traverseFolder;
  113111. private _processFiles;
  113112. /**
  113113. * Load files from a drop event
  113114. * @param event defines the drop event to use as source
  113115. */
  113116. loadFiles(event: any): void;
  113117. private _processReload;
  113118. /**
  113119. * Reload the current scene from the loaded files
  113120. */
  113121. reload(): void;
  113122. }
  113123. }
  113124. declare module BABYLON {
  113125. /**
  113126. * Defines the root class used to create scene optimization to use with SceneOptimizer
  113127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113128. */
  113129. export class SceneOptimization {
  113130. /**
  113131. * Defines the priority of this optimization (0 by default which means first in the list)
  113132. */
  113133. priority: number;
  113134. /**
  113135. * Gets a string describing the action executed by the current optimization
  113136. * @returns description string
  113137. */
  113138. getDescription(): string;
  113139. /**
  113140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113141. * @param scene defines the current scene where to apply this optimization
  113142. * @param optimizer defines the current optimizer
  113143. * @returns true if everything that can be done was applied
  113144. */
  113145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113146. /**
  113147. * Creates the SceneOptimization object
  113148. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113149. * @param desc defines the description associated with the optimization
  113150. */
  113151. constructor(
  113152. /**
  113153. * Defines the priority of this optimization (0 by default which means first in the list)
  113154. */
  113155. priority?: number);
  113156. }
  113157. /**
  113158. * Defines an optimization used to reduce the size of render target textures
  113159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113160. */
  113161. export class TextureOptimization extends SceneOptimization {
  113162. /**
  113163. * Defines the priority of this optimization (0 by default which means first in the list)
  113164. */
  113165. priority: number;
  113166. /**
  113167. * 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
  113168. */
  113169. maximumSize: number;
  113170. /**
  113171. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113172. */
  113173. step: number;
  113174. /**
  113175. * Gets a string describing the action executed by the current optimization
  113176. * @returns description string
  113177. */
  113178. getDescription(): string;
  113179. /**
  113180. * Creates the TextureOptimization object
  113181. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113182. * @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
  113183. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113184. */
  113185. constructor(
  113186. /**
  113187. * Defines the priority of this optimization (0 by default which means first in the list)
  113188. */
  113189. priority?: number,
  113190. /**
  113191. * 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
  113192. */
  113193. maximumSize?: number,
  113194. /**
  113195. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113196. */
  113197. step?: number);
  113198. /**
  113199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113200. * @param scene defines the current scene where to apply this optimization
  113201. * @param optimizer defines the current optimizer
  113202. * @returns true if everything that can be done was applied
  113203. */
  113204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113205. }
  113206. /**
  113207. * Defines an optimization used to increase or decrease the rendering resolution
  113208. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113209. */
  113210. export class HardwareScalingOptimization extends SceneOptimization {
  113211. /**
  113212. * Defines the priority of this optimization (0 by default which means first in the list)
  113213. */
  113214. priority: number;
  113215. /**
  113216. * Defines the maximum scale to use (2 by default)
  113217. */
  113218. maximumScale: number;
  113219. /**
  113220. * Defines the step to use between two passes (0.5 by default)
  113221. */
  113222. step: number;
  113223. private _currentScale;
  113224. private _directionOffset;
  113225. /**
  113226. * Gets a string describing the action executed by the current optimization
  113227. * @return description string
  113228. */
  113229. getDescription(): string;
  113230. /**
  113231. * Creates the HardwareScalingOptimization object
  113232. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113233. * @param maximumScale defines the maximum scale to use (2 by default)
  113234. * @param step defines the step to use between two passes (0.5 by default)
  113235. */
  113236. constructor(
  113237. /**
  113238. * Defines the priority of this optimization (0 by default which means first in the list)
  113239. */
  113240. priority?: number,
  113241. /**
  113242. * Defines the maximum scale to use (2 by default)
  113243. */
  113244. maximumScale?: number,
  113245. /**
  113246. * Defines the step to use between two passes (0.5 by default)
  113247. */
  113248. step?: number);
  113249. /**
  113250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113251. * @param scene defines the current scene where to apply this optimization
  113252. * @param optimizer defines the current optimizer
  113253. * @returns true if everything that can be done was applied
  113254. */
  113255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113256. }
  113257. /**
  113258. * Defines an optimization used to remove shadows
  113259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113260. */
  113261. export class ShadowsOptimization extends SceneOptimization {
  113262. /**
  113263. * Gets a string describing the action executed by the current optimization
  113264. * @return description string
  113265. */
  113266. getDescription(): string;
  113267. /**
  113268. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113269. * @param scene defines the current scene where to apply this optimization
  113270. * @param optimizer defines the current optimizer
  113271. * @returns true if everything that can be done was applied
  113272. */
  113273. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113274. }
  113275. /**
  113276. * Defines an optimization used to turn post-processes off
  113277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113278. */
  113279. export class PostProcessesOptimization extends SceneOptimization {
  113280. /**
  113281. * Gets a string describing the action executed by the current optimization
  113282. * @return description string
  113283. */
  113284. getDescription(): string;
  113285. /**
  113286. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113287. * @param scene defines the current scene where to apply this optimization
  113288. * @param optimizer defines the current optimizer
  113289. * @returns true if everything that can be done was applied
  113290. */
  113291. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113292. }
  113293. /**
  113294. * Defines an optimization used to turn lens flares off
  113295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113296. */
  113297. export class LensFlaresOptimization extends SceneOptimization {
  113298. /**
  113299. * Gets a string describing the action executed by the current optimization
  113300. * @return description string
  113301. */
  113302. getDescription(): string;
  113303. /**
  113304. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113305. * @param scene defines the current scene where to apply this optimization
  113306. * @param optimizer defines the current optimizer
  113307. * @returns true if everything that can be done was applied
  113308. */
  113309. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113310. }
  113311. /**
  113312. * Defines an optimization based on user defined callback.
  113313. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113314. */
  113315. export class CustomOptimization extends SceneOptimization {
  113316. /**
  113317. * Callback called to apply the custom optimization.
  113318. */
  113319. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113320. /**
  113321. * Callback called to get custom description
  113322. */
  113323. onGetDescription: () => string;
  113324. /**
  113325. * Gets a string describing the action executed by the current optimization
  113326. * @returns description string
  113327. */
  113328. getDescription(): string;
  113329. /**
  113330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113331. * @param scene defines the current scene where to apply this optimization
  113332. * @param optimizer defines the current optimizer
  113333. * @returns true if everything that can be done was applied
  113334. */
  113335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113336. }
  113337. /**
  113338. * Defines an optimization used to turn particles off
  113339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113340. */
  113341. export class ParticlesOptimization extends SceneOptimization {
  113342. /**
  113343. * Gets a string describing the action executed by the current optimization
  113344. * @return description string
  113345. */
  113346. getDescription(): string;
  113347. /**
  113348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113349. * @param scene defines the current scene where to apply this optimization
  113350. * @param optimizer defines the current optimizer
  113351. * @returns true if everything that can be done was applied
  113352. */
  113353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113354. }
  113355. /**
  113356. * Defines an optimization used to turn render targets off
  113357. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113358. */
  113359. export class RenderTargetsOptimization extends SceneOptimization {
  113360. /**
  113361. * Gets a string describing the action executed by the current optimization
  113362. * @return description string
  113363. */
  113364. getDescription(): string;
  113365. /**
  113366. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113367. * @param scene defines the current scene where to apply this optimization
  113368. * @param optimizer defines the current optimizer
  113369. * @returns true if everything that can be done was applied
  113370. */
  113371. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113372. }
  113373. /**
  113374. * Defines an optimization used to merge meshes with compatible materials
  113375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113376. */
  113377. export class MergeMeshesOptimization extends SceneOptimization {
  113378. private static _UpdateSelectionTree;
  113379. /**
  113380. * Gets or sets a boolean which defines if optimization octree has to be updated
  113381. */
  113382. /**
  113383. * Gets or sets a boolean which defines if optimization octree has to be updated
  113384. */
  113385. static UpdateSelectionTree: boolean;
  113386. /**
  113387. * Gets a string describing the action executed by the current optimization
  113388. * @return description string
  113389. */
  113390. getDescription(): string;
  113391. private _canBeMerged;
  113392. /**
  113393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113394. * @param scene defines the current scene where to apply this optimization
  113395. * @param optimizer defines the current optimizer
  113396. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113397. * @returns true if everything that can be done was applied
  113398. */
  113399. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113400. }
  113401. /**
  113402. * Defines a list of options used by SceneOptimizer
  113403. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113404. */
  113405. export class SceneOptimizerOptions {
  113406. /**
  113407. * Defines the target frame rate to reach (60 by default)
  113408. */
  113409. targetFrameRate: number;
  113410. /**
  113411. * Defines the interval between two checkes (2000ms by default)
  113412. */
  113413. trackerDuration: number;
  113414. /**
  113415. * Gets the list of optimizations to apply
  113416. */
  113417. optimizations: SceneOptimization[];
  113418. /**
  113419. * Creates a new list of options used by SceneOptimizer
  113420. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113421. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113422. */
  113423. constructor(
  113424. /**
  113425. * Defines the target frame rate to reach (60 by default)
  113426. */
  113427. targetFrameRate?: number,
  113428. /**
  113429. * Defines the interval between two checkes (2000ms by default)
  113430. */
  113431. trackerDuration?: number);
  113432. /**
  113433. * Add a new optimization
  113434. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113435. * @returns the current SceneOptimizerOptions
  113436. */
  113437. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113438. /**
  113439. * Add a new custom optimization
  113440. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113441. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113442. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113443. * @returns the current SceneOptimizerOptions
  113444. */
  113445. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113446. /**
  113447. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113448. * @param targetFrameRate defines the target frame rate (60 by default)
  113449. * @returns a SceneOptimizerOptions object
  113450. */
  113451. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113452. /**
  113453. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113454. * @param targetFrameRate defines the target frame rate (60 by default)
  113455. * @returns a SceneOptimizerOptions object
  113456. */
  113457. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113458. /**
  113459. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113460. * @param targetFrameRate defines the target frame rate (60 by default)
  113461. * @returns a SceneOptimizerOptions object
  113462. */
  113463. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113464. }
  113465. /**
  113466. * Class used to run optimizations in order to reach a target frame rate
  113467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113468. */
  113469. export class SceneOptimizer implements IDisposable {
  113470. private _isRunning;
  113471. private _options;
  113472. private _scene;
  113473. private _currentPriorityLevel;
  113474. private _targetFrameRate;
  113475. private _trackerDuration;
  113476. private _currentFrameRate;
  113477. private _sceneDisposeObserver;
  113478. private _improvementMode;
  113479. /**
  113480. * Defines an observable called when the optimizer reaches the target frame rate
  113481. */
  113482. onSuccessObservable: Observable<SceneOptimizer>;
  113483. /**
  113484. * Defines an observable called when the optimizer enables an optimization
  113485. */
  113486. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113487. /**
  113488. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113489. */
  113490. onFailureObservable: Observable<SceneOptimizer>;
  113491. /**
  113492. * Gets a boolean indicating if the optimizer is in improvement mode
  113493. */
  113494. readonly isInImprovementMode: boolean;
  113495. /**
  113496. * Gets the current priority level (0 at start)
  113497. */
  113498. readonly currentPriorityLevel: number;
  113499. /**
  113500. * Gets the current frame rate checked by the SceneOptimizer
  113501. */
  113502. readonly currentFrameRate: number;
  113503. /**
  113504. * Gets or sets the current target frame rate (60 by default)
  113505. */
  113506. /**
  113507. * Gets or sets the current target frame rate (60 by default)
  113508. */
  113509. targetFrameRate: number;
  113510. /**
  113511. * Gets or sets the current interval between two checks (every 2000ms by default)
  113512. */
  113513. /**
  113514. * Gets or sets the current interval between two checks (every 2000ms by default)
  113515. */
  113516. trackerDuration: number;
  113517. /**
  113518. * Gets the list of active optimizations
  113519. */
  113520. readonly optimizations: SceneOptimization[];
  113521. /**
  113522. * Creates a new SceneOptimizer
  113523. * @param scene defines the scene to work on
  113524. * @param options defines the options to use with the SceneOptimizer
  113525. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113526. * @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)
  113527. */
  113528. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113529. /**
  113530. * Stops the current optimizer
  113531. */
  113532. stop(): void;
  113533. /**
  113534. * Reset the optimizer to initial step (current priority level = 0)
  113535. */
  113536. reset(): void;
  113537. /**
  113538. * Start the optimizer. By default it will try to reach a specific framerate
  113539. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113540. */
  113541. start(): void;
  113542. private _checkCurrentState;
  113543. /**
  113544. * Release all resources
  113545. */
  113546. dispose(): void;
  113547. /**
  113548. * Helper function to create a SceneOptimizer with one single line of code
  113549. * @param scene defines the scene to work on
  113550. * @param options defines the options to use with the SceneOptimizer
  113551. * @param onSuccess defines a callback to call on success
  113552. * @param onFailure defines a callback to call on failure
  113553. * @returns the new SceneOptimizer object
  113554. */
  113555. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113556. }
  113557. }
  113558. declare module BABYLON {
  113559. /**
  113560. * Class used to serialize a scene into a string
  113561. */
  113562. export class SceneSerializer {
  113563. /**
  113564. * Clear cache used by a previous serialization
  113565. */
  113566. static ClearCache(): void;
  113567. /**
  113568. * Serialize a scene into a JSON compatible object
  113569. * @param scene defines the scene to serialize
  113570. * @returns a JSON compatible object
  113571. */
  113572. static Serialize(scene: Scene): any;
  113573. /**
  113574. * Serialize a mesh into a JSON compatible object
  113575. * @param toSerialize defines the mesh to serialize
  113576. * @param withParents defines if parents must be serialized as well
  113577. * @param withChildren defines if children must be serialized as well
  113578. * @returns a JSON compatible object
  113579. */
  113580. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113581. }
  113582. }
  113583. declare module BABYLON {
  113584. /**
  113585. * This represents the different options avilable for the video capture.
  113586. */
  113587. export interface VideoRecorderOptions {
  113588. /** Defines the mime type of the video */
  113589. mimeType: string;
  113590. /** Defines the video the video should be recorded at */
  113591. fps: number;
  113592. /** Defines the chunk size for the recording data */
  113593. recordChunckSize: number;
  113594. /** The audio tracks to attach to the record */
  113595. audioTracks?: MediaStreamTrack[];
  113596. }
  113597. /**
  113598. * This can helps recording videos from BabylonJS.
  113599. * This is based on the available WebRTC functionalities of the browser.
  113600. *
  113601. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113602. */
  113603. export class VideoRecorder {
  113604. private static readonly _defaultOptions;
  113605. /**
  113606. * Returns wehther or not the VideoRecorder is available in your browser.
  113607. * @param engine Defines the Babylon Engine to check the support for
  113608. * @returns true if supported otherwise false
  113609. */
  113610. static IsSupported(engine: Engine): boolean;
  113611. private readonly _options;
  113612. private _canvas;
  113613. private _mediaRecorder;
  113614. private _recordedChunks;
  113615. private _fileName;
  113616. private _resolve;
  113617. private _reject;
  113618. /**
  113619. * True wether a recording is already in progress.
  113620. */
  113621. readonly isRecording: boolean;
  113622. /**
  113623. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113624. * a video file.
  113625. * @param engine Defines the BabylonJS Engine you wish to record
  113626. * @param options Defines options that can be used to customized the capture
  113627. */
  113628. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113629. /**
  113630. * Stops the current recording before the default capture timeout passed in the startRecording
  113631. * functions.
  113632. */
  113633. stopRecording(): void;
  113634. /**
  113635. * Starts recording the canvas for a max duration specified in parameters.
  113636. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  113637. * @param maxDuration Defines the maximum recording time in seconds.
  113638. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113639. * @return a promise callback at the end of the recording with the video data in Blob.
  113640. */
  113641. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113642. /**
  113643. * Releases internal resources used during the recording.
  113644. */
  113645. dispose(): void;
  113646. private _handleDataAvailable;
  113647. private _handleError;
  113648. private _handleStop;
  113649. }
  113650. }
  113651. declare module BABYLON {
  113652. /**
  113653. * Helper class to push actions to a pool of workers.
  113654. */
  113655. export class WorkerPool implements IDisposable {
  113656. private _workerInfos;
  113657. private _pendingActions;
  113658. /**
  113659. * Constructor
  113660. * @param workers Array of workers to use for actions
  113661. */
  113662. constructor(workers: Array<Worker>);
  113663. /**
  113664. * Terminates all workers and clears any pending actions.
  113665. */
  113666. dispose(): void;
  113667. /**
  113668. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113669. * pended until a worker has completed its action.
  113670. * @param action The action to perform. Call onComplete when the action is complete.
  113671. */
  113672. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113673. private _execute;
  113674. }
  113675. }
  113676. declare module BABYLON {
  113677. /**
  113678. * Class containing a set of static utilities functions for screenshots
  113679. */
  113680. export class ScreenshotTools {
  113681. /**
  113682. * Captures a screenshot of the current rendering
  113683. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113684. * @param engine defines the rendering engine
  113685. * @param camera defines the source camera
  113686. * @param size This parameter can be set to a single number or to an object with the
  113687. * following (optional) properties: precision, width, height. If a single number is passed,
  113688. * it will be used for both width and height. If an object is passed, the screenshot size
  113689. * will be derived from the parameters. The precision property is a multiplier allowing
  113690. * rendering at a higher or lower resolution
  113691. * @param successCallback defines the callback receives a single parameter which contains the
  113692. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113693. * src parameter of an <img> to display it
  113694. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113695. * Check your browser for supported MIME types
  113696. */
  113697. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113698. /**
  113699. * Generates an image screenshot from the specified camera.
  113700. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113701. * @param engine The engine to use for rendering
  113702. * @param camera The camera to use for rendering
  113703. * @param size This parameter can be set to a single number or to an object with the
  113704. * following (optional) properties: precision, width, height. If a single number is passed,
  113705. * it will be used for both width and height. If an object is passed, the screenshot size
  113706. * will be derived from the parameters. The precision property is a multiplier allowing
  113707. * rendering at a higher or lower resolution
  113708. * @param successCallback The callback receives a single parameter which contains the
  113709. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113710. * src parameter of an <img> to display it
  113711. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113712. * Check your browser for supported MIME types
  113713. * @param samples Texture samples (default: 1)
  113714. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113715. * @param fileName A name for for the downloaded file.
  113716. */
  113717. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113718. }
  113719. }
  113720. declare module BABYLON {
  113721. /**
  113722. * A cursor which tracks a point on a path
  113723. */
  113724. export class PathCursor {
  113725. private path;
  113726. /**
  113727. * Stores path cursor callbacks for when an onchange event is triggered
  113728. */
  113729. private _onchange;
  113730. /**
  113731. * The value of the path cursor
  113732. */
  113733. value: number;
  113734. /**
  113735. * The animation array of the path cursor
  113736. */
  113737. animations: Animation[];
  113738. /**
  113739. * Initializes the path cursor
  113740. * @param path The path to track
  113741. */
  113742. constructor(path: Path2);
  113743. /**
  113744. * Gets the cursor point on the path
  113745. * @returns A point on the path cursor at the cursor location
  113746. */
  113747. getPoint(): Vector3;
  113748. /**
  113749. * Moves the cursor ahead by the step amount
  113750. * @param step The amount to move the cursor forward
  113751. * @returns This path cursor
  113752. */
  113753. moveAhead(step?: number): PathCursor;
  113754. /**
  113755. * Moves the cursor behind by the step amount
  113756. * @param step The amount to move the cursor back
  113757. * @returns This path cursor
  113758. */
  113759. moveBack(step?: number): PathCursor;
  113760. /**
  113761. * Moves the cursor by the step amount
  113762. * If the step amount is greater than one, an exception is thrown
  113763. * @param step The amount to move the cursor
  113764. * @returns This path cursor
  113765. */
  113766. move(step: number): PathCursor;
  113767. /**
  113768. * Ensures that the value is limited between zero and one
  113769. * @returns This path cursor
  113770. */
  113771. private ensureLimits;
  113772. /**
  113773. * Runs onchange callbacks on change (used by the animation engine)
  113774. * @returns This path cursor
  113775. */
  113776. private raiseOnChange;
  113777. /**
  113778. * Executes a function on change
  113779. * @param f A path cursor onchange callback
  113780. * @returns This path cursor
  113781. */
  113782. onchange(f: (cursor: PathCursor) => void): PathCursor;
  113783. }
  113784. }
  113785. declare module BABYLON {
  113786. /** @hidden */
  113787. export var blurPixelShader: {
  113788. name: string;
  113789. shader: string;
  113790. };
  113791. }
  113792. declare module BABYLON {
  113793. /** @hidden */
  113794. export var bones300Declaration: {
  113795. name: string;
  113796. shader: string;
  113797. };
  113798. }
  113799. declare module BABYLON {
  113800. /** @hidden */
  113801. export var instances300Declaration: {
  113802. name: string;
  113803. shader: string;
  113804. };
  113805. }
  113806. declare module BABYLON {
  113807. /** @hidden */
  113808. export var pointCloudVertexDeclaration: {
  113809. name: string;
  113810. shader: string;
  113811. };
  113812. }
  113813. // Mixins
  113814. interface Window {
  113815. mozIndexedDB: IDBFactory;
  113816. webkitIndexedDB: IDBFactory;
  113817. msIndexedDB: IDBFactory;
  113818. webkitURL: typeof URL;
  113819. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  113820. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  113821. WebGLRenderingContext: WebGLRenderingContext;
  113822. MSGesture: MSGesture;
  113823. CANNON: any;
  113824. AudioContext: AudioContext;
  113825. webkitAudioContext: AudioContext;
  113826. PointerEvent: any;
  113827. Math: Math;
  113828. Uint8Array: Uint8ArrayConstructor;
  113829. Float32Array: Float32ArrayConstructor;
  113830. mozURL: typeof URL;
  113831. msURL: typeof URL;
  113832. VRFrameData: any; // WebVR, from specs 1.1
  113833. DracoDecoderModule: any;
  113834. setImmediate(handler: (...args: any[]) => void): number;
  113835. }
  113836. interface HTMLCanvasElement {
  113837. requestPointerLock(): void;
  113838. msRequestPointerLock?(): void;
  113839. mozRequestPointerLock?(): void;
  113840. webkitRequestPointerLock?(): void;
  113841. /** Track wether a record is in progress */
  113842. isRecording: boolean;
  113843. /** Capture Stream method defined by some browsers */
  113844. captureStream(fps?: number): MediaStream;
  113845. }
  113846. interface CanvasRenderingContext2D {
  113847. msImageSmoothingEnabled: boolean;
  113848. }
  113849. interface MouseEvent {
  113850. mozMovementX: number;
  113851. mozMovementY: number;
  113852. webkitMovementX: number;
  113853. webkitMovementY: number;
  113854. msMovementX: number;
  113855. msMovementY: number;
  113856. }
  113857. interface Navigator {
  113858. mozGetVRDevices: (any: any) => any;
  113859. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113860. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113861. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113862. webkitGetGamepads(): Gamepad[];
  113863. msGetGamepads(): Gamepad[];
  113864. webkitGamepads(): Gamepad[];
  113865. }
  113866. interface HTMLVideoElement {
  113867. mozSrcObject: any;
  113868. }
  113869. interface Math {
  113870. fround(x: number): number;
  113871. imul(a: number, b: number): number;
  113872. }
  113873. interface WebGLProgram {
  113874. context?: WebGLRenderingContext;
  113875. vertexShader?: WebGLShader;
  113876. fragmentShader?: WebGLShader;
  113877. isParallelCompiled: boolean;
  113878. onCompiled?: () => void;
  113879. }
  113880. interface WebGLRenderingContext {
  113881. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  113882. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  113883. vertexAttribDivisor(index: number, divisor: number): void;
  113884. createVertexArray(): any;
  113885. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  113886. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  113887. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  113888. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  113889. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  113890. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  113891. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  113892. // Queries
  113893. createQuery(): WebGLQuery;
  113894. deleteQuery(query: WebGLQuery): void;
  113895. beginQuery(target: number, query: WebGLQuery): void;
  113896. endQuery(target: number): void;
  113897. getQueryParameter(query: WebGLQuery, pname: number): any;
  113898. getQuery(target: number, pname: number): any;
  113899. MAX_SAMPLES: number;
  113900. RGBA8: number;
  113901. READ_FRAMEBUFFER: number;
  113902. DRAW_FRAMEBUFFER: number;
  113903. UNIFORM_BUFFER: number;
  113904. HALF_FLOAT_OES: number;
  113905. RGBA16F: number;
  113906. RGBA32F: number;
  113907. R32F: number;
  113908. RG32F: number;
  113909. RGB32F: number;
  113910. R16F: number;
  113911. RG16F: number;
  113912. RGB16F: number;
  113913. RED: number;
  113914. RG: number;
  113915. R8: number;
  113916. RG8: number;
  113917. UNSIGNED_INT_24_8: number;
  113918. DEPTH24_STENCIL8: number;
  113919. /* Multiple Render Targets */
  113920. drawBuffers(buffers: number[]): void;
  113921. readBuffer(src: number): void;
  113922. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  113923. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  113924. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  113925. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  113926. // Occlusion Query
  113927. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  113928. ANY_SAMPLES_PASSED: number;
  113929. QUERY_RESULT_AVAILABLE: number;
  113930. QUERY_RESULT: number;
  113931. }
  113932. interface WebGLBuffer {
  113933. references: number;
  113934. capacity: number;
  113935. is32Bits: boolean;
  113936. }
  113937. interface WebGLProgram {
  113938. transformFeedback?: WebGLTransformFeedback | null;
  113939. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  113940. }
  113941. interface EXT_disjoint_timer_query {
  113942. QUERY_COUNTER_BITS_EXT: number;
  113943. TIME_ELAPSED_EXT: number;
  113944. TIMESTAMP_EXT: number;
  113945. GPU_DISJOINT_EXT: number;
  113946. QUERY_RESULT_EXT: number;
  113947. QUERY_RESULT_AVAILABLE_EXT: number;
  113948. queryCounterEXT(query: WebGLQuery, target: number): void;
  113949. createQueryEXT(): WebGLQuery;
  113950. beginQueryEXT(target: number, query: WebGLQuery): void;
  113951. endQueryEXT(target: number): void;
  113952. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  113953. deleteQueryEXT(query: WebGLQuery): void;
  113954. }
  113955. interface WebGLUniformLocation {
  113956. _currentState: any;
  113957. }
  113958. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  113959. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  113960. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  113961. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113962. interface WebGLRenderingContext {
  113963. readonly RASTERIZER_DISCARD: number;
  113964. readonly DEPTH_COMPONENT24: number;
  113965. readonly TEXTURE_3D: number;
  113966. readonly TEXTURE_2D_ARRAY: number;
  113967. readonly TEXTURE_COMPARE_FUNC: number;
  113968. readonly TEXTURE_COMPARE_MODE: number;
  113969. readonly COMPARE_REF_TO_TEXTURE: number;
  113970. readonly TEXTURE_WRAP_R: number;
  113971. readonly HALF_FLOAT: number;
  113972. readonly RGB8: number;
  113973. readonly RED_INTEGER: number;
  113974. readonly RG_INTEGER: number;
  113975. readonly RGB_INTEGER: number;
  113976. readonly RGBA_INTEGER: number;
  113977. readonly R8_SNORM: number;
  113978. readonly RG8_SNORM: number;
  113979. readonly RGB8_SNORM: number;
  113980. readonly RGBA8_SNORM: number;
  113981. readonly R8I: number;
  113982. readonly RG8I: number;
  113983. readonly RGB8I: number;
  113984. readonly RGBA8I: number;
  113985. readonly R8UI: number;
  113986. readonly RG8UI: number;
  113987. readonly RGB8UI: number;
  113988. readonly RGBA8UI: number;
  113989. readonly R16I: number;
  113990. readonly RG16I: number;
  113991. readonly RGB16I: number;
  113992. readonly RGBA16I: number;
  113993. readonly R16UI: number;
  113994. readonly RG16UI: number;
  113995. readonly RGB16UI: number;
  113996. readonly RGBA16UI: number;
  113997. readonly R32I: number;
  113998. readonly RG32I: number;
  113999. readonly RGB32I: number;
  114000. readonly RGBA32I: number;
  114001. readonly R32UI: number;
  114002. readonly RG32UI: number;
  114003. readonly RGB32UI: number;
  114004. readonly RGBA32UI: number;
  114005. readonly RGB10_A2UI: number;
  114006. readonly R11F_G11F_B10F: number;
  114007. readonly RGB9_E5: number;
  114008. readonly RGB10_A2: number;
  114009. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  114010. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  114011. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  114012. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114013. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  114014. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  114015. 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;
  114016. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  114017. readonly TRANSFORM_FEEDBACK: number;
  114018. readonly INTERLEAVED_ATTRIBS: number;
  114019. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  114020. createTransformFeedback(): WebGLTransformFeedback;
  114021. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  114022. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  114023. beginTransformFeedback(primitiveMode: number): void;
  114024. endTransformFeedback(): void;
  114025. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  114026. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114027. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114028. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  114029. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  114030. }
  114031. interface ImageBitmap {
  114032. readonly width: number;
  114033. readonly height: number;
  114034. close(): void;
  114035. }
  114036. interface WebGLQuery extends WebGLObject {
  114037. }
  114038. declare var WebGLQuery: {
  114039. prototype: WebGLQuery;
  114040. new(): WebGLQuery;
  114041. };
  114042. interface WebGLSampler extends WebGLObject {
  114043. }
  114044. declare var WebGLSampler: {
  114045. prototype: WebGLSampler;
  114046. new(): WebGLSampler;
  114047. };
  114048. interface WebGLSync extends WebGLObject {
  114049. }
  114050. declare var WebGLSync: {
  114051. prototype: WebGLSync;
  114052. new(): WebGLSync;
  114053. };
  114054. interface WebGLTransformFeedback extends WebGLObject {
  114055. }
  114056. declare var WebGLTransformFeedback: {
  114057. prototype: WebGLTransformFeedback;
  114058. new(): WebGLTransformFeedback;
  114059. };
  114060. interface WebGLVertexArrayObject extends WebGLObject {
  114061. }
  114062. declare var WebGLVertexArrayObject: {
  114063. prototype: WebGLVertexArrayObject;
  114064. new(): WebGLVertexArrayObject;
  114065. };
  114066. // Type definitions for WebVR API
  114067. // Project: https://w3c.github.io/webvr/
  114068. // Definitions by: six a <https://github.com/lostfictions>
  114069. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  114070. interface VRDisplay extends EventTarget {
  114071. /**
  114072. * Dictionary of capabilities describing the VRDisplay.
  114073. */
  114074. readonly capabilities: VRDisplayCapabilities;
  114075. /**
  114076. * z-depth defining the far plane of the eye view frustum
  114077. * enables mapping of values in the render target depth
  114078. * attachment to scene coordinates. Initially set to 10000.0.
  114079. */
  114080. depthFar: number;
  114081. /**
  114082. * z-depth defining the near plane of the eye view frustum
  114083. * enables mapping of values in the render target depth
  114084. * attachment to scene coordinates. Initially set to 0.01.
  114085. */
  114086. depthNear: number;
  114087. /**
  114088. * An identifier for this distinct VRDisplay. Used as an
  114089. * association point in the Gamepad API.
  114090. */
  114091. readonly displayId: number;
  114092. /**
  114093. * A display name, a user-readable name identifying it.
  114094. */
  114095. readonly displayName: string;
  114096. readonly isConnected: boolean;
  114097. readonly isPresenting: boolean;
  114098. /**
  114099. * If this VRDisplay supports room-scale experiences, the optional
  114100. * stage attribute contains details on the room-scale parameters.
  114101. */
  114102. readonly stageParameters: VRStageParameters | null;
  114103. /**
  114104. * Passing the value returned by `requestAnimationFrame` to
  114105. * `cancelAnimationFrame` will unregister the callback.
  114106. * @param handle Define the hanle of the request to cancel
  114107. */
  114108. cancelAnimationFrame(handle: number): void;
  114109. /**
  114110. * Stops presenting to the VRDisplay.
  114111. * @returns a promise to know when it stopped
  114112. */
  114113. exitPresent(): Promise<void>;
  114114. /**
  114115. * Return the current VREyeParameters for the given eye.
  114116. * @param whichEye Define the eye we want the parameter for
  114117. * @returns the eye parameters
  114118. */
  114119. getEyeParameters(whichEye: string): VREyeParameters;
  114120. /**
  114121. * Populates the passed VRFrameData with the information required to render
  114122. * the current frame.
  114123. * @param frameData Define the data structure to populate
  114124. * @returns true if ok otherwise false
  114125. */
  114126. getFrameData(frameData: VRFrameData): boolean;
  114127. /**
  114128. * Get the layers currently being presented.
  114129. * @returns the list of VR layers
  114130. */
  114131. getLayers(): VRLayer[];
  114132. /**
  114133. * Return a VRPose containing the future predicted pose of the VRDisplay
  114134. * when the current frame will be presented. The value returned will not
  114135. * change until JavaScript has returned control to the browser.
  114136. *
  114137. * The VRPose will contain the position, orientation, velocity,
  114138. * and acceleration of each of these properties.
  114139. * @returns the pose object
  114140. */
  114141. getPose(): VRPose;
  114142. /**
  114143. * Return the current instantaneous pose of the VRDisplay, with no
  114144. * prediction applied.
  114145. * @returns the current instantaneous pose
  114146. */
  114147. getImmediatePose(): VRPose;
  114148. /**
  114149. * The callback passed to `requestAnimationFrame` will be called
  114150. * any time a new frame should be rendered. When the VRDisplay is
  114151. * presenting the callback will be called at the native refresh
  114152. * rate of the HMD. When not presenting this function acts
  114153. * identically to how window.requestAnimationFrame acts. Content should
  114154. * make no assumptions of frame rate or vsync behavior as the HMD runs
  114155. * asynchronously from other displays and at differing refresh rates.
  114156. * @param callback Define the eaction to run next frame
  114157. * @returns the request handle it
  114158. */
  114159. requestAnimationFrame(callback: FrameRequestCallback): number;
  114160. /**
  114161. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  114162. * Repeat calls while already presenting will update the VRLayers being displayed.
  114163. * @param layers Define the list of layer to present
  114164. * @returns a promise to know when the request has been fulfilled
  114165. */
  114166. requestPresent(layers: VRLayer[]): Promise<void>;
  114167. /**
  114168. * Reset the pose for this display, treating its current position and
  114169. * orientation as the "origin/zero" values. VRPose.position,
  114170. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  114171. * updated when calling resetPose(). This should be called in only
  114172. * sitting-space experiences.
  114173. */
  114174. resetPose(): void;
  114175. /**
  114176. * The VRLayer provided to the VRDisplay will be captured and presented
  114177. * in the HMD. Calling this function has the same effect on the source
  114178. * canvas as any other operation that uses its source image, and canvases
  114179. * created without preserveDrawingBuffer set to true will be cleared.
  114180. * @param pose Define the pose to submit
  114181. */
  114182. submitFrame(pose?: VRPose): void;
  114183. }
  114184. declare var VRDisplay: {
  114185. prototype: VRDisplay;
  114186. new(): VRDisplay;
  114187. };
  114188. interface VRLayer {
  114189. leftBounds?: number[] | Float32Array | null;
  114190. rightBounds?: number[] | Float32Array | null;
  114191. source?: HTMLCanvasElement | null;
  114192. }
  114193. interface VRDisplayCapabilities {
  114194. readonly canPresent: boolean;
  114195. readonly hasExternalDisplay: boolean;
  114196. readonly hasOrientation: boolean;
  114197. readonly hasPosition: boolean;
  114198. readonly maxLayers: number;
  114199. }
  114200. interface VREyeParameters {
  114201. /** @deprecated */
  114202. readonly fieldOfView: VRFieldOfView;
  114203. readonly offset: Float32Array;
  114204. readonly renderHeight: number;
  114205. readonly renderWidth: number;
  114206. }
  114207. interface VRFieldOfView {
  114208. readonly downDegrees: number;
  114209. readonly leftDegrees: number;
  114210. readonly rightDegrees: number;
  114211. readonly upDegrees: number;
  114212. }
  114213. interface VRFrameData {
  114214. readonly leftProjectionMatrix: Float32Array;
  114215. readonly leftViewMatrix: Float32Array;
  114216. readonly pose: VRPose;
  114217. readonly rightProjectionMatrix: Float32Array;
  114218. readonly rightViewMatrix: Float32Array;
  114219. readonly timestamp: number;
  114220. }
  114221. interface VRPose {
  114222. readonly angularAcceleration: Float32Array | null;
  114223. readonly angularVelocity: Float32Array | null;
  114224. readonly linearAcceleration: Float32Array | null;
  114225. readonly linearVelocity: Float32Array | null;
  114226. readonly orientation: Float32Array | null;
  114227. readonly position: Float32Array | null;
  114228. readonly timestamp: number;
  114229. }
  114230. interface VRStageParameters {
  114231. sittingToStandingTransform?: Float32Array;
  114232. sizeX?: number;
  114233. sizeY?: number;
  114234. }
  114235. interface Navigator {
  114236. getVRDisplays(): Promise<VRDisplay[]>;
  114237. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  114238. }
  114239. interface Window {
  114240. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  114241. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  114242. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  114243. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114244. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114245. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  114246. }
  114247. interface Gamepad {
  114248. readonly displayId: number;
  114249. }
  114250. interface XRDevice {
  114251. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  114252. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  114253. }
  114254. interface XRSession {
  114255. getInputSources(): Array<any>;
  114256. baseLayer: XRWebGLLayer;
  114257. requestFrameOfReference(type: string): Promise<void>;
  114258. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  114259. end(): Promise<void>;
  114260. requestAnimationFrame: Function;
  114261. addEventListener: Function;
  114262. }
  114263. interface XRSessionCreationOptions {
  114264. outputContext?: WebGLRenderingContext | null;
  114265. immersive?: boolean;
  114266. environmentIntegration?: boolean;
  114267. }
  114268. interface XRLayer {
  114269. getViewport: Function;
  114270. framebufferWidth: number;
  114271. framebufferHeight: number;
  114272. }
  114273. interface XRView {
  114274. projectionMatrix: Float32Array;
  114275. }
  114276. interface XRFrame {
  114277. getDevicePose: Function;
  114278. getInputPose: Function;
  114279. views: Array<XRView>;
  114280. baseLayer: XRLayer;
  114281. }
  114282. interface XRFrameOfReference {
  114283. }
  114284. interface XRWebGLLayer extends XRLayer {
  114285. framebuffer: WebGLFramebuffer;
  114286. }
  114287. declare var XRWebGLLayer: {
  114288. prototype: XRWebGLLayer;
  114289. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114290. };